Where-in-the-World-is-Ben/resources/views/partials/checkins-list.blade.php

79 lines
3.9 KiB
PHP
Raw Permalink Normal View History

2022-11-28 19:46:12 +00:00
@foreach($checkinsList as $checkin)
<li>
2023-03-02 22:10:55 +00:00
@php
$hasEmbed = null;
$embedMissing = null;
if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
if (preg_match("/\.webm/", $filepath[1])) {
2023-07-20 17:10:16 +00:00
$hasEmbed = 'videos';
2024-08-27 14:57:33 +00:00
$trip_slug = preg_replace( '/[^A-Za-z0-9-]+/', '-', strtolower( $trip->name ) );
2023-07-20 16:39:48 +00:00
if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) {
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
2024-08-27 14:57:33 +00:00
$embed = '<video class="popup__video" preload="none" controls>';
2024-06-09 20:29:37 +00:00
$embed .= '<source src="' . secure_url( $path ) . '" type="video/webm">';
$embed .= '<p>Your client doesn\'t support HTML video. Here is a <a href="' . secure_url( $path ) . '">link to the video</a> instead.</p>';
2024-08-27 14:57:33 +00:00
$embed .= '</video>';
2023-03-03 04:35:44 +00:00
if (isset($email)) {
2024-06-09 20:29:37 +00:00
$embed .= '<p><i>If your email client doesn\'t support video embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>';
2023-03-03 04:19:13 +00:00
}
2023-03-02 22:10:55 +00:00
} else {
$embed = '<p>[The video \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';
$embedMissing = true;
}
} elseif (preg_match("/\.ogg/", $filepath[1])) {
$hasEmbed = 'audio';
2024-08-27 14:57:33 +00:00
$trip_slug = preg_replace( '/[^A-Za-z0-9-]+/', '-', strtolower( $trip->name ) );
2023-07-20 16:39:48 +00:00
if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) {
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
2024-08-27 14:57:33 +00:00
$embed = '<audio class="popup__audio" preload="none" controls>';
2024-06-09 20:29:37 +00:00
$embed .= '<source src="' . secure_url( $path ) . '" type="audio/ogg">';
$embed .= '<p>Download <a href="' . secure_url( $path ) . '">OGG</a> audio.</p>';
2024-08-27 14:57:33 +00:00
$embed .= '</audio>';
2023-03-03 04:35:44 +00:00
if (isset($email)) {
2024-06-09 20:29:37 +00:00
$embed .= '<p><i>If your email client doesn\' support audio embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>';
2023-03-03 04:19:13 +00:00
}
2023-03-02 22:10:55 +00:00
} else {
$embed = '<p>[The recording \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';
$embedMissing = true;
}
}
$checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note);
}
@endphp
2022-11-28 19:46:12 +00:00
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
<summary class="checkin__summary">
2023-03-02 22:10:55 +00:00
<h2 class="checkin__title">
{!! $checkin->title ?? "<i>Untitled</i>" !!}
2023-03-03 00:42:38 +00:00
@if($checkin->image_url)
2024-08-27 14:57:33 +00:00
<span class="checkin-icon">🖼️</span>
2023-03-03 00:42:38 +00:00
@endif
2023-03-02 22:10:55 +00:00
@if($hasEmbed)
2023-07-20 17:10:16 +00:00
@if($hasEmbed === 'videos')
2024-08-27 14:57:33 +00:00
<span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128249;</span>
2023-03-02 22:10:55 +00:00
@endif
@if($hasEmbed === 'audio')
2024-08-27 14:57:33 +00:00
<span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128264;</span>
2023-03-02 22:10:55 +00:00
@endif
@endif
</h2>
2022-11-28 19:46:12 +00:00
<p class="checkin__meta">{!! render_date_difference($checkin->date) !!}</p>
</summary>
@if($checkin->note)
@if($checkin->id === 3930)
@include('partials.abolition-checkin')
2022-11-28 20:26:16 +00:00
@else
{!! $checkin->note !!}
2022-11-28 20:26:16 +00:00
@endif
2022-11-28 19:46:12 +00:00
@endif
2022-11-28 19:46:12 +00:00
@if($checkin->image_url)
<img class="popup__image" loading="lazy" src="{{ $checkin->image_url }}">
@endif
</details>
</li>
@endforeach