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

View File

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