Add icons to checkins to show media

This commit is contained in:
Ben Goldsworthy 2023-03-02 17:10:55 -05:00
parent 7a39bfd7d5
commit 79f57e6a11
2 changed files with 50 additions and 25 deletions

View file

@ -351,3 +351,11 @@ body {
margin-top: 1em; margin-top: 1em;
} }
} }
.checkin-icon {
color: black;
}
.checkin-icon--missing {
opacity: 0.4;
}

View file

@ -1,14 +1,11 @@
@foreach($checkinsList as $checkin) @foreach($checkinsList as $checkin)
<li> <li>
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
<summary class="checkin__summary">
<h2 class="checkin__title">{!! $checkin->title ?? "<i>Untitled</i>" !!}</h2>
<p class="checkin__meta">{!! render_date_difference($checkin->date) !!}</p>
</summary>
@if($checkin->note)
@php @php
$hasEmbed = null;
$embedMissing = null;
if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) { if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
if (preg_match("/\.webm/", $filepath[1])) { if (preg_match("/\.webm/", $filepath[1])) {
$hasEmbed = 'video';
if (file_exists(public_path() . "/videos/" . $filepath[1])) { if (file_exists(public_path() . "/videos/" . $filepath[1])) {
$embed = '<video class="popup__video" controls>'; $embed = '<video class="popup__video" controls>';
$embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">'; $embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">';
@ -16,8 +13,10 @@
$embed .= '</video>'; $embed .= '</video>';
} else { } else {
$embed = '<p>[The video \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>'; $embed = '<p>[The video \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';
$embedMissing = true;
} }
} elseif (preg_match("/\.ogg/", $filepath[1])) { } elseif (preg_match("/\.ogg/", $filepath[1])) {
$hasEmbed = 'audio';
if (file_exists(public_path() . "/audio/" . $filepath[1])) { if (file_exists(public_path() . "/audio/" . $filepath[1])) {
$embed = '<audio class="popup__audio" controls>'; $embed = '<audio class="popup__audio" controls>';
$embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">'; $embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">';
@ -25,11 +24,29 @@
$embed .= '</audio>'; $embed .= '</audio>';
} else { } else {
$embed = '<p>[The recording \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>'; $embed = '<p>[The recording \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';
$embedMissing = true;
} }
} }
$checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note); $checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note);
} }
@endphp @endphp
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
<summary class="checkin__summary">
<h2 class="checkin__title">
{!! $checkin->title ?? "<i>Untitled</i>" !!}
@if($hasEmbed)
@if($hasEmbed === 'video')
<span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128249;</span>
@endif
@if($hasEmbed === 'audio')
<span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128264;</span>
@endif
@endif
</h2>
<p class="checkin__meta">{!! render_date_difference($checkin->date) !!}</p>
</summary>
@if($checkin->note)
@if($checkin->id === 3930) @if($checkin->id === 3930)
@include('partials.abolition-checkin') @include('partials.abolition-checkin')