Fix embeds to include note content where both exists

This commit is contained in:
Ben Goldsworthy 2022-12-14 22:05:35 +00:00
parent b586687174
commit 802c9398d5
3 changed files with 46 additions and 35 deletions

View file

@ -0,0 +1,7 @@
<p>Of course, the reality of living without an Army is a little more complex than just <q>everyone decided we were too nice to hit</q>. Unlike elsewhere in Latin America, Costa Rica hasn't really ever seen the kind of leftist leader who threatens US corporate profits with the possibility of expropriation and wealth redistribution,* so Washington was never compelled to support right-wing death squads, military dictators or genocides here. It's easy to be a happy little hobbit when you're not drawing Sauron's gaze.</p>
<p>Plus, Costa Rica has had to bend the knee to the US a mumber of times, such as backing the Contras in Nicaragua under Monge. This marked the end of the Reform State period, and since then Costa Rica has followed the neoliberal economic line. Not unrelatedly, the generation of artists and writers stretching from the 1980s to now is known as <q>the generation of disenchantment</q>.</p>
<p>So, Costa Rica's peace and prosperity is a little more complicated than it may first appear, and some of those contradictions are likely to intensify as Chinese investment in the country ramps up, threatening its thusfar successful strategy of <q>play nice with the local nutcase</q>. Like Japan, it will be interesting to see how long it takes for their constitutional pacifism to become a subject of debate.</p>
<p>* There kind of <em>was</em> a leftist leader in Calderón, elite resistance to whom led to the civil war which resulted in the Army's abolition in the first place. His rival Figueres did have some shady dealings with the CIA, but he's a very complicated guy who basically ended up instituting all of Calderón's reforms anyway, plus when the <q>bloodiest event</q> in your Latin American country's history is a war that only saw 2,000 people die, you're doing pretty damn well for yourself.</p>

View file

@ -6,22 +6,30 @@
<p class="checkin__meta">{!! render_date_difference($checkin->date) !!}</p> <p class="checkin__meta">{!! render_date_difference($checkin->date) !!}</p>
</summary> </summary>
@if($checkin->note) @if($checkin->note)
@if(preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) @php
@if(preg_match("/\.webm/", $filepath[1])) if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
<video class="popup__video" controls> if (preg_match("/\.webm/", $filepath[1])) {
<source src="{{ url("/videos/$filepath[1]") }}" type="video/webm"> $embed = '<video class="popup__video" controls>';
<p>Your browser doesn't support HTML video. Here is a <a href="{{ url("/videos/$filepath[1]") }}">link to the video</a> instead.</p> $embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">';
</video> $embed .= '<p>Your browser doesn\'t support HTML video. Here is a <a href="' . url("/videos/" . $filepath[1]) . '">link to the video</a> instead.</p>';
@elseif(preg_match("/\.ogg/", $filepath[1])) $embed .= '</video>';
<audio class="popup__audio" controls> } elseif (preg_match("/\.ogg/", $filepath[1])) {
<source src="{{ url("/audio/$filepath[1]") }}" type="audio/ogg"> $embed = '<audio class="popup__audio" controls>';
<p>Download <a href="{{ url("/audio/$filepath[1]") }}">OGG</a> audio.</p> $embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">';
</audio> $embed .= '<p>Download <a href="' . url("/audio/" . $filepath[1]) . '">OGG</a> audio.</p>';
@endif $embed .= '</audio>';
}
$checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note);
}
@endphp
@if($checkin->id === 3930)
@include('partials.abolition-checkin')
@else @else
{!! $checkin->note !!} {!! $checkin->note !!}
@endif @endif
@endif @endif
@if($checkin->image_url) @if($checkin->image_url)
<img class="popup__image" loading="lazy" src="{{ $checkin->image_url }}"> <img class="popup__image" loading="lazy" src="{{ $checkin->image_url }}">
@endif @endif

View file

@ -91,29 +91,25 @@
}).addTo(map); }).addTo(map);
@php $popupContent = null; @endphp @php $popupContent = null; @endphp
@if(preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) @php
@if(preg_match("/\.webm/", $filepath[1])) $embed = null;
@php if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
$popupContent = '<video class="popup__video" controls><source src="/videos/'; if (preg_match("/\.webm/", $filepath[1])) {
$popupContent .= $filepath[1]; $embed = '<video class="popup__video" controls>';
$popupContent .= '" type="video/webm">'; $embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">';
$popupContent .= '<p>Your browser doesn\'t support HTML video. Here is a <a href="/'; $embed .= '<p>Your browser doesn\'t support HTML video. Here is a <a href="' . url("/videos/" . $filepath[1]) . '">link to the video</a> instead.</p>';
$popupContent .= $filepath[1]; $embed .= '</video>';
$popupContent .= '">link to the video</a> instead.</p></video>'; } elseif (preg_match("/\.ogg/", $filepath[1])) {
@endphp $embed = '<audio class="popup__audio" controls>';
@elseif(preg_match("/\.ogg/", $filepath[1])) $embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">';
@php $embed .= '<p>Download <a href="' . url("/audio/" . $filepath[1]) . '">OGG</a> audio.</p>';
$popupContent = '<audio class="popup__audio" controls><source src="/audio/'; $embed .= '</audio>';
$popupContent .= $filepath[1]; }
$popupContent .= '" type="audio/ogg">'; $checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note);
$popupContent .= '<p>Download <a href="/'; }
$popupContent .= $filepath[1]; @endphp
$popupContent .= '">OGG</a> audio.</p></audio>';
@endphp
@endif
@else
@php $popupContent ='<p class="popup__note">' . $checkin->note . '</p>'; @endphp @php $popupContent ='<p class="popup__note">' . $checkin->note . '</p>'; @endphp
@endif
popupMarkup = `<h2 class="popup__title">{!! $checkin->title ?? "<i>Untitled</i>" !!}</h2>`; popupMarkup = `<h2 class="popup__title">{!! $checkin->title ?? "<i>Untitled</i>" !!}</h2>`;
popupMarkup += `{!! $popupContent !!}`; popupMarkup += `{!! $popupContent !!}`;