Show the queued show and its start time in the index.php sidebar

- Shows get a description and an icon upload; broadcasts get a scheduled_at
  start time. schema.sql adds the columns to existing databases and seeds
  the descriptions from the old hand-written sidebar.
- The dashboard and cli/set_show.php take an optional date and Eastern start
  time when queuing; index.php shows it with the UTC conversion.
- liveBroadcast() and currentShow() ignore broadcasts unseen for longer than
  the grace period, so a stopped poller can't leave a show stuck as live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel MesserandClaude Opus 5.5 committed 2026-10-30 09:30:20 -05:00
1 parent 3fb49e816c
commit f659b09a0b
9 files changed
+297 -77

No files matched your search

+59 -3
View File
@@ -1,3 +1,37 @@
<?php
require __DIR__ . '/includes/db.php';
require __DIR__ . '/includes/broadcasts.php';
// The sidebar falls back to a general note if the database is unavailable
$show = null;
try {
$show = currentShow(getDB());
} catch (Throwable $e) {
}
$icon = '';
$paragraphs = [];
$when = [];
if ($show) {
if ($show['icon_image'] && is_file(__DIR__ . '/images/backgrounds/' . basename($show['icon_image']))) {
$icon = 'images/backgrounds/' . rawurlencode(basename($show['icon_image']));
}
// Blank lines in the description separate paragraphs
if ($show['description']) {
$paragraphs = preg_split('/\n\s*\n/', trim($show['description']));
}
// e.g. "Friday, October 30, 2026" / "7:30pm Eastern" / "(23:30 UTC)", naming the UTC day when it differs
if (!$show['started_at'] && $show['scheduled_at']) {
$local = utcToStationTime($show['scheduled_at']);
$utc = new DateTimeImmutable($show['scheduled_at'], new DateTimeZone('UTC'));
$when = [
$local->format('l, F j, Y'),
$local->format($local->format('i') === '00' ? 'ga' : 'g:ia') . ' ' . STATION_TIMEZONE_LABEL,
'(' . $utc->format('H:i') . ' UTC' . ($utc->format('Y-m-d') !== $local->format('Y-m-d') ? ', ' . $utc->format('l') : '') . ')',
];
}
}
?>
<!DOCTYPE HTML>
<!--
RFE NEW SITE
@@ -71,8 +105,30 @@
<!-- Upcoming & Schedule -->
<section id="one">
<header class="major">
<h3>Upcoming Schedule</h3>
<h3><?= $show && $show['started_at'] ? 'On the Air Now' : 'Upcoming Schedule' ?></h3>
</header>
<!-- The queued (or live) show comes from the database: queue it on the admin dashboard.
The commented-out blocks below are the hand-written history from before that. -->
<?php if ($show): ?>
<div class="show-heading">
<?php if ($icon !== ''): ?>
<span class="image left"><img src="<?= htmlspecialchars($icon, ENT_QUOTES, 'UTF-8') ?>" alt="<?= htmlspecialchars($show['name'], ENT_QUOTES, 'UTF-8') ?> logo" /></span>
<?php endif; ?>
<h3><?= htmlspecialchars($show['name'], ENT_QUOTES, 'UTF-8') ?></h3>
<?php if ($show['started_at']): ?>
<p><strong>Live now</strong></p>
<?php elseif ($when): ?>
<p><strong><?= implode('<br>', array_map(fn($line) => htmlspecialchars($line, ENT_QUOTES, 'UTF-8'), $when)) ?></strong></p>
<?php endif; ?>
</div>
<hr>
<?php foreach ($paragraphs as $paragraph): ?>
<p><?= nl2br(htmlspecialchars($paragraph, ENT_QUOTES, 'UTF-8')) ?></p>
<?php endforeach; ?>
<?php else: ?>
<p>Nothing is scheduled just now. Follow along on <a href="https://masto.hackers.town/@cyberpunklibrarian">Mastodon</a> or <a href="https://bsky.app/profile/cyberpunklibrarian.bsky.social">Bluesky</a> to hear when we're going live next.</p>
<?php endif; ?>
<!-- BEGIN THE SPIN -->
<!--<div class="show-heading">
<span class="image left"><img src="images/the-spin.jpg" alt="The Spin Logo" /></span>
@@ -86,7 +142,7 @@
<!-- END THE SPIN -->
<!-- BEGIN O'MORAIN'S PUB -->
<div class="show-heading">
<!--<div class="show-heading">
<span class="image left"><img src="images/omorains-icon.jpg" alt="O'Morain's Pub Logo" /></span>
<h3>O'Morain's Pub</h3>
<p><strong>Friday, October 30, 2026<br>1pm Eastern<br>(17:00 UTC)</strong></p>
@@ -94,7 +150,7 @@
<hr>
<p>Sit back, have a pint (or two) and listen in on personally curated Celtic folk. Classics, new favourites, and new takes on old songs from all over the world of Celtic music. Cross the Atlantic from Scotland to Nova Scotia, Ireland to Appalachia, and Brittany to Cape Breton &ndash; O’Morain’s Pub has your ticket for fantastic music across the Celtic experience.</p>
<!-- <p>So raise your glass, you’ve found something a little different from the norm. Sláinte!</p> -->
<p>So raise your glass, you’ve found something a little different from the norm. Sláinte!</p> -->
<!-- END O'MORAIN'S PUB -->
<!-- COSMOEUPHORIA --> <!--