diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89302c5..6410c3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,9 @@ jobs: - name: Set up ripgrep run: sudo apt-get update && sudo apt-get install -y ripgrep + - name: Install Composer dependencies + run: composer install --no-interaction --no-progress --prefer-dist + - name: Run PHP syntax checks run: scripts/php-lint.sh @@ -32,3 +35,9 @@ jobs: - name: Verify public JavaScript assets parse run: scripts/check-assets.sh + + - name: Verify video media rendering + run: php scripts/check-video-support.php + + - name: Run PHPStan + run: scripts/phpstan.sh diff --git a/.gitignore b/.gitignore index 7e1e47c..7c0700c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ /images/ /thumbs/ +# Composer dependencies are installed locally and in CI. +/vendor/ + # Local utility/debug files. /audit.php diff --git a/AGENTS.md b/AGENTS.md index 5941fe8..0bcabfe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -53,6 +53,8 @@ scripts/php-lint.sh scripts/check-source-only.sh scripts/check-file-modes.sh scripts/check-assets.sh +php scripts/check-video-support.php +scripts/phpstan.sh ``` For browser smoke tests, check: diff --git a/app/includes/conditions.php b/app/includes/conditions.php index 0325fec..e9fabde 100644 --- a/app/includes/conditions.php +++ b/app/includes/conditions.php @@ -18,6 +18,8 @@ $safePageUrl = htmlspecialchars("{$baseUrl}{$_SERVER['REQUEST_URI']}", ENT_QUOTES, 'UTF-8'); $safeTitle = htmlspecialchars($entry['title'] ?? '', ENT_QUOTES, 'UTF-8'); $safeDesc = htmlspecialchars($entry['explanation'] ?? '', ENT_QUOTES, 'UTF-8'); +$mediaType = apod_media_type($entry ?? []); +$safeVideoUrl = $mediaType === 'video' ? apod_h(apod_video_embed_url($entry ?? [])) : ''; $dt = $date; //$safeFullUrl = htmlspecialchars($fullUrl, ENT_QUOTES, 'UTF-8'); @@ -30,7 +32,27 @@ switch ($page) { case 'image': - $jsonLd = << + { + "@context":"https://schema.org", + "@type":"VideoObject", + "name":"{$t}", + "description":"{$d}", + "thumbnailUrl":["{$u}"], + "embedUrl":"{$safeVideoUrl}", + "url":"{$p}", + "uploadDate":"{$dt}", + "datePublished":"{$dt}", + "dateModified":"{$dt}", + "author":{"@type":"Organization","name":"NASA"}, + "license":"https://apod.nasa.gov/apod/lib/ApodCopyright.php" + } + + JSONLD; + } else { + $jsonLd = << { "@context":"https://schema.org", @@ -46,6 +68,7 @@ } JSONLD; + } $metaTags = << @@ -76,7 +99,11 @@ HTML; echo $metaTags; - echo ''; + if ($mediaType === 'video') { + echo ''; + } else { + echo ''; + } break; case 'home': diff --git a/app/includes/lightbox.php b/app/includes/lightbox.php index 62b9d6a..a82e56b 100644 --- a/app/includes/lightbox.php +++ b/app/includes/lightbox.php @@ -1,26 +1,27 @@ src—here I’m defaulting to the 640px version -$imgSrc = htmlspecialchars($entry['url_main'][640] ?? $entry['url_thumb']); +$imgSrc = apod_h($entry['url_main'][640] ?? ($entry['url_thumb'] ?? '')); ?>
@@ -28,6 +29,7 @@ href="#!" class="lightbox-trigger" data-full="" + data-alt="" aria-label="View full-size image of "> @@ -60,7 +62,7 @@ class="lightbox-trigger"

JavaScript is disabled. Displaying standard image.

<?= htmlspecialchars($title ?: 'Astronomy Picture of the Day') ?> @@ -130,4 +132,4 @@ function onKeyDown(e) { backdrop.addEventListener('click', closeLightbox); })(); }) - \ No newline at end of file + diff --git a/app/includes/media.php b/app/includes/media.php new file mode 100644 index 0000000..ba05e63 --- /dev/null +++ b/app/includes/media.php @@ -0,0 +1,151 @@ + + + Load video player + +HTML; + + $frame = << + +
+HTML; + + $fallback = << +

+ JavaScript is disabled. Open the video for {$safeTitle}. +

+ +HTML; + } + + return << +
+ {$safeTitle} video poster +{$button} +
+ +{$frame} +{$fallback} + +HTML; +} diff --git a/app/pages/gallery.php b/app/pages/gallery.php index 9eecd1e..b622309 100644 --- a/app/pages/gallery.php +++ b/app/pages/gallery.php @@ -1,10 +1,10 @@