From 13d17e2e51503db21c017fe6e69ceb61a4c4d1ee Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Fri, 13 Jun 2025 16:31:36 -0700 Subject: [PATCH] feat(*): refactor dynamic vs. static structure and distinctions; make additional elements dynamic --- Dockerfile | 5 +- api/Classes/ApiHandler.php | 3 - api/Classes/BaseHandler.php | 2 - api/Classes/LatestListenHandler.php | 69 ++++++++ api/Classes/MusicDataHandler.php | 26 +++ api/Classes/PageFetcher.php | 12 +- api/Classes/RecentMediaHandler.php | 36 ++++ api/artist-import.php | 2 +- api/book-import.php | 2 +- api/contact.php | 2 +- api/mastodon.php | 2 +- api/oembed.php | 3 +- api/og-image.php | 2 +- api/playing.php | 78 --------- api/query.php | 5 +- api/scrobble.php | 3 +- api/search.php | 3 +- api/seasons-import.php | 2 +- api/umami.php | 154 +++++++++--------- api/watching-import.php | 2 +- bootstrap.php | 6 + cli/package-lock.json | 64 ++++---- cli/package.json | 2 +- config/dynamic/icons.php | 22 +++ {server/utils => config/dynamic}/init.php | 0 config/dynamic/media.php | 147 +++++++++++++++++ config/dynamic/metadata.php | 39 +++++ config/dynamic/paginator.php | 41 +++++ config/dynamic/routing.php | 11 ++ config/dynamic/strings.php | 84 ++++++++++ config/dynamic/tags.php | 17 ++ eleventy.config.js | 4 +- package-lock.json | 82 +++++----- package.json | 2 +- queries/views/globals/pages.sql | 1 - queries/views/media/music/week/summary.sql | 34 ++++ scripts/templates/apache_vhost.conf.template | 2 +- server/utils/icons.php | 20 --- server/utils/media.php | 112 ------------- server/utils/metadata.php | 33 ---- server/utils/paginator.php | 40 ----- server/utils/routing.php | 8 - server/utils/strings.php | 71 -------- server/utils/tags.php | 14 -- src/assets/scripts/components/now-playing.js | 41 ----- src/assets/scripts/sw.js | 1 - src/assets/styles/base/index.css | 6 - src/data/nowPlaying.js | 42 ----- src/data/recentMedia.js | 33 ---- src/includes/blocks/now-playing.liquid | 7 - .../{ => dynamic}/fetchers/artist.php.liquid | 3 +- .../{ => dynamic}/fetchers/book.php.liquid | 3 +- .../{ => dynamic}/fetchers/genre.php.liquid | 3 +- .../{ => dynamic}/fetchers/movie.php.liquid | 3 +- .../{ => dynamic}/fetchers/show.php.liquid | 3 +- .../{ => dynamic}/fetchers/tags.php.liquid | 4 +- .../dynamic/media/now-playing.php.liquid | 15 ++ .../dynamic/media/recent-media.php.liquid | 15 ++ .../dynamic/media/recent-tracks.php.liquid | 41 +++++ .../metadata/index.php.liquid} | 0 src/includes/home/recent-media.liquid | 15 -- src/includes/layout/footer.liquid | 22 --- src/includes/media/music/charts/recent.liquid | 30 ---- .../blocks/associated-media.liquid | 2 +- .../blocks/banners/calendar.liquid | 0 .../blocks/banners/forgejo.liquid | 0 .../{ => static}/blocks/banners/github.liquid | 0 .../{ => static}/blocks/banners/npm.liquid | 0 .../blocks/banners/old-post.liquid | 0 .../{ => static}/blocks/banners/rss.liquid | 0 .../blocks/banners/warning.liquid | 0 .../{ => static}/blocks/dialog.liquid | 0 src/includes/{ => static}/blocks/hero.liquid | 0 src/includes/{ => static}/blocks/index.liquid | 14 +- src/includes/{ => static}/blocks/tags.liquid | 0 .../{ => static}/blocks/top-tags.liquid | 0 .../{ => static}/blocks/youtube-player.liquid | 0 src/includes/{ => static}/home/intro.liquid | 3 +- .../{ => static}/home/recent-activity.liquid | 4 +- src/includes/static/layout/footer.liquid | 13 ++ .../{ => static}/layout/header.liquid | 4 +- src/includes/{ => static}/media/grid.liquid | 2 +- .../media/music/charts/item.liquid | 2 +- .../media/music/charts/rank.liquid | 6 +- .../media/music/tables/all-time/albums.liquid | 0 .../music/tables/all-time/artists.liquid | 0 .../{ => static}/media/progress-bar.liquid | 0 .../{ => static}/media/watching/hero.liquid | 2 +- .../{ => static}/metadata/base.liquid | 0 .../{ => static}/metadata/index.liquid | 8 +- .../{ => static}/metadata/static.liquid | 0 src/includes/{ => static}/nav/link.liquid | 3 +- src/includes/{ => static}/nav/menu.liquid | 2 +- .../{ => static}/nav/paginator.liquid | 0 src/layouts/base.liquid | 6 +- src/meta/vendor.htaccess.liquid | 7 + src/pages/dynamic/index.php.liquid | 19 +++ src/pages/dynamic/{ => media}/book.php.liquid | 2 +- .../dynamic/{ => media}/movie.php.liquid | 2 +- .../{ => media/music}/artist.php.liquid | 0 .../{ => media/music}/genre.php.liquid | 0 .../dynamic/media/music/index.php.liquid | 77 +++++++++ src/pages/dynamic/{ => media}/show.php.liquid | 2 +- src/pages/index.html | 21 --- src/pages/media/music/index.html | 76 --------- .../{ => static}/media/music/concerts.html | 4 +- .../{ => static}/media/music/releases.html | 5 +- .../media/music/this-month/albums.html | 3 +- .../media/music/this-month/artists.html | 3 +- .../media/music/this-month/index.html | 7 +- .../media/music/this-week/albums.html | 3 +- .../media/music/this-week/artists.html | 3 +- .../media/music/this-week/tracks.html | 3 +- .../{ => static}/media/reading/index.html | 7 +- .../{ => static}/media/reading/year.html | 2 +- .../media/watching/favorites/movies.html | 4 +- .../media/watching/favorites/shows.html | 4 +- .../{ => static}/media/watching/index.html | 15 +- .../media/watching/recent/movies.html | 4 +- .../media/watching/recent/shows.html | 4 +- .../media/watching/upcoming-shows.html | 7 +- src/pages/{ => static}/page.html | 3 +- src/pages/static/search.html | 2 +- src/pages/{ => static}/sections/links.html | 8 +- .../{ => static}/sections/posts/index.html | 8 +- .../{ => static}/sections/posts/post.html | 8 +- src/pages/{ => static}/sections/tags.html | 0 src/pages/static/stats.html | 1 - 128 files changed, 982 insertions(+), 959 deletions(-) create mode 100644 api/Classes/LatestListenHandler.php create mode 100644 api/Classes/MusicDataHandler.php create mode 100644 api/Classes/RecentMediaHandler.php delete mode 100644 api/playing.php create mode 100644 bootstrap.php create mode 100644 config/dynamic/icons.php rename {server/utils => config/dynamic}/init.php (100%) create mode 100644 config/dynamic/media.php create mode 100644 config/dynamic/metadata.php create mode 100644 config/dynamic/paginator.php create mode 100644 config/dynamic/routing.php create mode 100644 config/dynamic/strings.php create mode 100644 config/dynamic/tags.php create mode 100644 queries/views/media/music/week/summary.sql delete mode 100644 server/utils/icons.php delete mode 100644 server/utils/media.php delete mode 100644 server/utils/metadata.php delete mode 100644 server/utils/paginator.php delete mode 100644 server/utils/routing.php delete mode 100644 server/utils/strings.php delete mode 100644 server/utils/tags.php delete mode 100644 src/assets/scripts/components/now-playing.js delete mode 100644 src/data/nowPlaying.js delete mode 100644 src/data/recentMedia.js delete mode 100644 src/includes/blocks/now-playing.liquid rename src/includes/{ => dynamic}/fetchers/artist.php.liquid (85%) rename src/includes/{ => dynamic}/fetchers/book.php.liquid (86%) rename src/includes/{ => dynamic}/fetchers/genre.php.liquid (85%) rename src/includes/{ => dynamic}/fetchers/movie.php.liquid (86%) rename src/includes/{ => dynamic}/fetchers/show.php.liquid (86%) rename src/includes/{ => dynamic}/fetchers/tags.php.liquid (94%) create mode 100644 src/includes/dynamic/media/now-playing.php.liquid create mode 100644 src/includes/dynamic/media/recent-media.php.liquid create mode 100644 src/includes/dynamic/media/recent-tracks.php.liquid rename src/includes/{metadata/dynamic.php.liquid => dynamic/metadata/index.php.liquid} (100%) delete mode 100644 src/includes/home/recent-media.liquid delete mode 100644 src/includes/layout/footer.liquid delete mode 100644 src/includes/media/music/charts/recent.liquid rename src/includes/{ => static}/blocks/associated-media.liquid (98%) rename src/includes/{ => static}/blocks/banners/calendar.liquid (100%) rename src/includes/{ => static}/blocks/banners/forgejo.liquid (100%) rename src/includes/{ => static}/blocks/banners/github.liquid (100%) rename src/includes/{ => static}/blocks/banners/npm.liquid (100%) rename src/includes/{ => static}/blocks/banners/old-post.liquid (100%) rename src/includes/{ => static}/blocks/banners/rss.liquid (100%) rename src/includes/{ => static}/blocks/banners/warning.liquid (100%) rename src/includes/{ => static}/blocks/dialog.liquid (100%) rename src/includes/{ => static}/blocks/hero.liquid (100%) rename src/includes/{ => static}/blocks/index.liquid (67%) rename src/includes/{ => static}/blocks/tags.liquid (100%) rename src/includes/{ => static}/blocks/top-tags.liquid (100%) rename src/includes/{ => static}/blocks/youtube-player.liquid (100%) rename src/includes/{ => static}/home/intro.liquid (55%) rename src/includes/{ => static}/home/recent-activity.liquid (95%) create mode 100644 src/includes/static/layout/footer.liquid rename src/includes/{ => static}/layout/header.liquid (91%) rename src/includes/{ => static}/media/grid.liquid (97%) rename src/includes/{ => static}/media/music/charts/item.liquid (89%) rename src/includes/{ => static}/media/music/charts/rank.liquid (73%) rename src/includes/{ => static}/media/music/tables/all-time/albums.liquid (100%) rename src/includes/{ => static}/media/music/tables/all-time/artists.liquid (100%) rename src/includes/{ => static}/media/progress-bar.liquid (100%) rename src/includes/{ => static}/media/watching/hero.liquid (91%) rename src/includes/{ => static}/metadata/base.liquid (100%) rename src/includes/{ => static}/metadata/index.liquid (92%) rename src/includes/{ => static}/metadata/static.liquid (100%) rename src/includes/{ => static}/nav/link.liquid (90%) rename src/includes/{ => static}/nav/menu.liquid (84%) rename src/includes/{ => static}/nav/paginator.liquid (100%) create mode 100644 src/meta/vendor.htaccess.liquid create mode 100644 src/pages/dynamic/index.php.liquid rename src/pages/dynamic/{ => media}/book.php.liquid (94%) rename src/pages/dynamic/{ => media}/movie.php.liquid (94%) rename src/pages/dynamic/{ => media/music}/artist.php.liquid (100%) rename src/pages/dynamic/{ => media/music}/genre.php.liquid (100%) create mode 100644 src/pages/dynamic/media/music/index.php.liquid rename src/pages/dynamic/{ => media}/show.php.liquid (94%) delete mode 100644 src/pages/index.html delete mode 100644 src/pages/media/music/index.html rename src/pages/{ => static}/media/music/concerts.html (95%) rename src/pages/{ => static}/media/music/releases.html (89%) rename src/pages/{ => static}/media/music/this-month/albums.html (95%) rename src/pages/{ => static}/media/music/this-month/artists.html (95%) rename src/pages/{ => static}/media/music/this-month/index.html (90%) rename src/pages/{ => static}/media/music/this-week/albums.html (95%) rename src/pages/{ => static}/media/music/this-week/artists.html (95%) rename src/pages/{ => static}/media/music/this-week/tracks.html (94%) rename src/pages/{ => static}/media/reading/index.html (92%) rename src/pages/{ => static}/media/reading/year.html (97%) rename src/pages/{ => static}/media/watching/favorites/movies.html (92%) rename src/pages/{ => static}/media/watching/favorites/shows.html (92%) rename src/pages/{ => static}/media/watching/index.html (86%) rename src/pages/{ => static}/media/watching/recent/movies.html (92%) rename src/pages/{ => static}/media/watching/recent/shows.html (92%) rename src/pages/{ => static}/media/watching/upcoming-shows.html (90%) rename src/pages/{ => static}/page.html (77%) rename src/pages/{ => static}/sections/links.html (87%) rename src/pages/{ => static}/sections/posts/index.html (87%) rename src/pages/{ => static}/sections/posts/post.html (86%) rename src/pages/{ => static}/sections/tags.html (100%) diff --git a/Dockerfile b/Dockerfile index d9dc57c..199ed5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,6 +59,9 @@ CMD bash -c "\ echo \"${SSH_PRIVATE_KEY}\" > ~/.ssh/id_rsa && \ chmod 600 ~/.ssh/id_rsa && \ ssh-keyscan -H \"${SERVER_IP}\" >> ~/.ssh/known_hosts && \ - rsync -avz --delete dist/ root@\"${SERVER_IP}\":/var/www/coryd.dev/ && \ + rsync -avz --delete dist/ root@\"${SERVER_IP}\":/var/www/coryd.dev/public/ && \ + rsync -avz --delete vendor/ root@\"${SERVER_IP}\":/var/www/coryd.dev/vendor/ && \ + rsync -avz --delete composer.json root@\"${SERVER_IP}\":/var/www/coryd.dev/composer.json && \ + rsync -avz --delete bootstrap.php root@\"${SERVER_IP}\":/var/www/coryd.dev/bootstrap.php && \ echo \"✅ Deployed successfully\" && \ tail -f /dev/null" diff --git a/api/Classes/ApiHandler.php b/api/Classes/ApiHandler.php index d7b22d9..732f154 100644 --- a/api/Classes/ApiHandler.php +++ b/api/Classes/ApiHandler.php @@ -2,9 +2,6 @@ namespace App\Classes; - require __DIR__ . "/BaseHandler.php"; - require __DIR__ . '/../../server/utils/init.php'; - abstract class ApiHandler extends BaseHandler { protected function ensureCliAccess(): void diff --git a/api/Classes/BaseHandler.php b/api/Classes/BaseHandler.php index bed8f40..e6318fb 100644 --- a/api/Classes/BaseHandler.php +++ b/api/Classes/BaseHandler.php @@ -2,8 +2,6 @@ namespace App\Classes; - require __DIR__ . "/../../vendor/autoload.php"; - use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; diff --git a/api/Classes/LatestListenHandler.php b/api/Classes/LatestListenHandler.php new file mode 100644 index 0000000..e903f8d --- /dev/null +++ b/api/Classes/LatestListenHandler.php @@ -0,0 +1,69 @@ +initializeCache(); + } + + public function handleRequest(): void + { + $data = $this->getLatestListen(); + + if (!$data) { + $this->sendResponse(["message" => "No recent tracks found"], 404); + + return; + } + + $this->sendResponse($data); + } + + public function getLatestListen(): ?array + { + try { + $cachedData = $this->cache ? $this->cache->get("latest_listen") : null; + + if ($cachedData) return json_decode($cachedData, true); + + $data = $this->makeRequest("GET", "optimized_latest_listen?select=*"); + + if (!is_array($data) || empty($data[0])) return null; + + $latestListen = $this->formatLatestListen($data[0]); + + if ($this->cache) $this->cache->set("latest_listen", json_encode($latestListen), $this->cacheTTL); + + return $latestListen; + } catch (\Exception $e) { + error_log("LatestListenHandler::getLatestListen error: " . $e->getMessage()); + return null; + } + } + + private function formatLatestListen(array $latestListen): array + { + $emoji = $latestListen["artist_emoji"] ?? ($latestListen["genre_emoji"] ?? "🎧"); + $trackName = htmlspecialchars($latestListen["track_name"] ?? "Unknown Track", ENT_QUOTES, "UTF-8"); + $artistName = htmlspecialchars($latestListen["artist_name"] ?? "Unknown Artist", ENT_QUOTES, "UTF-8"); + $url = htmlspecialchars($latestListen["url"] ?? "/", ENT_QUOTES, "UTF-8"); + + return [ + "content" => sprintf( + '%s %s by %s', + $emoji, + $trackName, + $url, + $artistName + ), + ]; + } +} diff --git a/api/Classes/MusicDataHandler.php b/api/Classes/MusicDataHandler.php new file mode 100644 index 0000000..7588f61 --- /dev/null +++ b/api/Classes/MusicDataHandler.php @@ -0,0 +1,26 @@ +cache ? $this->cache->get($cacheKey) : null; + + if ($cached) return json_decode($cached, true); + + $response = $this->makeRequest('GET', 'optimized_week_music?select=*'); + $music = $response[0]['week_music'] ?? []; + $music['total_tracks'] = $music['week_summary']['total_tracks'] ?? 0; + $music['total_artists'] = $music['week_summary']['total_artists'] ?? 0; + $music['total_albums'] = $music['week_summary']['total_albums'] ?? 0; + + if ($this->cache) $this->cache->set($cacheKey, json_encode($music), $this->cacheTTL); + + return $music; + } +} diff --git a/api/Classes/PageFetcher.php b/api/Classes/PageFetcher.php index aa6b1f3..b57ac67 100644 --- a/api/Classes/PageFetcher.php +++ b/api/Classes/PageFetcher.php @@ -11,21 +11,18 @@ abstract class PageFetcher extends BaseHandler protected function cacheGet(string $key): mixed { - return $this->cache && $this->cache->exists($key) - ? json_decode($this->cache->get($key), true) - : null; + return $this->cache && $this->cache->exists($key) ? json_decode($this->cache->get($key), true) : null; } - protected function cacheSet(string $key, mixed $value, int $ttl = 3600): void + protected function cacheSet(string $key, mixed $value, int $ttl = 300): void { - if ($this->cache) { - $this->cache->setex($key, $ttl, json_encode($value)); - } + if ($this->cache) $this->cache->setex($key, $ttl, json_encode($value)); } protected function fetchSingleFromApi(string $endpoint, string $url): ?array { $data = $this->fetchFromApi($endpoint, "url=eq./{$url}"); + return $data[0] ?? null; } @@ -39,6 +36,7 @@ abstract class PageFetcher extends BaseHandler if ($this->globals !== null) return $this->globals; $fetcher = new GlobalsFetcher(); + $this->globals = $fetcher->fetch(); return $this->globals; diff --git a/api/Classes/RecentMediaHandler.php b/api/Classes/RecentMediaHandler.php new file mode 100644 index 0000000..bb4ecad --- /dev/null +++ b/api/Classes/RecentMediaHandler.php @@ -0,0 +1,36 @@ +cache) { + $cached = $this->cache->get($cacheKey); + + if ($cached) return json_decode($cached, true); + } + + $response = $this->makeRequest("GET", "optimized_recent_media?select=*"); + $activity = $response[0]['recent_activity'] ?? []; + $data = [ + 'recentMusic' => $activity['recentMusic'] ?? [], + 'recentWatchedRead' => $activity['recentWatchedRead'] ?? [], + ]; + + if ($this->cache) $this->cache->set($cacheKey, json_encode($data), $this->cacheTTL); + + return $data; + } catch (\Exception $e) { + error_log("RecentMediaHandler error: " . $e->getMessage()); + + return ['recentMusic' => [], 'recentWatchedRead' => []]; + } + } +} diff --git a/api/artist-import.php b/api/artist-import.php index ca4b803..108bff4 100644 --- a/api/artist-import.php +++ b/api/artist-import.php @@ -1,6 +1,6 @@ initializeCache(); - } - - public function handleRequest(): void - { - try { - $cachedData = $this->cache ? $this->cache->get("latest_listen") : null; - - if ($cachedData) { - $this->sendResponse(json_decode($cachedData, true)); - return; - } - - $data = $this->makeRequest("GET", "optimized_latest_listen?select=*"); - - if (!is_array($data) || empty($data[0])) { - $this->sendResponse(["message" => "No recent tracks found"], 404); - return; - } - - $latestListen = $this->formatLatestListen($data[0]); - - if ($this->cache) $this->cache->set( - "latest_listen", - json_encode($latestListen), - $this->cacheTTL - ); - - $this->sendResponse($latestListen); - } catch (\Exception $e) { - error_log("LatestListenHandler Error: " . $e->getMessage()); - - $this->sendErrorResponse("Internal Server Error: " . $e->getMessage(), 500); - } - } - - private function formatLatestListen(array $latestListen): array - { - $emoji = $latestListen["artist_emoji"] ?? ($latestListen["genre_emoji"] ?? "🎧"); - $trackName = htmlspecialchars( - $latestListen["track_name"] ?? "Unknown Track", - ENT_QUOTES, - "UTF-8" - ); - $artistName = htmlspecialchars( - $latestListen["artist_name"] ?? "Unknown Artist", - ENT_QUOTES, - "UTF-8" - ); - $url = htmlspecialchars($latestListen["url"] ?? "/", ENT_QUOTES, "UTF-8"); - - return [ - "content" => sprintf( - '%s %s by %s', - $emoji, - $trackName, - $url, - $artistName - ), - ]; - } -} - -$handler = new LatestListenHandler(); -$handler->handleRequest(); diff --git a/api/query.php b/api/query.php index f302a12..657df5e 100644 --- a/api/query.php +++ b/api/query.php @@ -1,7 +1,6 @@ in_array(parse_url($url, PHP_URL_HOST), $allowedHosts, true); - if (!$hostAllowed($origin) && !$hostAllowed($referer)) $this->sendErrorResponse("Forbidden — invalid origin", 403); + if (!$hostAllowed($origin) && !$hostAllowed($referer)) $this->sendErrorResponse("Forbidden: invalid origin", 403); $allowedSource = $origin ?: $referer; $scheme = parse_url($allowedSource, PHP_URL_SCHEME) ?? 'https'; diff --git a/api/scrobble.php b/api/scrobble.php index 1ce21da..d12c8d6 100644 --- a/api/scrobble.php +++ b/api/scrobble.php @@ -1,7 +1,6 @@ connect('127.0.0.1', 6379); + try { + if (extension_loaded('redis')) { + $redis = new Redis(); + $redis->connect('127.0.0.1', 6379); - if ($redis->exists($cacheKey)) $js = $redis->get($cacheKey); + if ($redis->exists($cacheKey)) $js = $redis->get($cacheKey); + } + } catch (Exception $e) { + error_log("Redis unavailable: " . $e->getMessage()); } - } catch (Exception $e) { - error_log("Redis unavailable: " . $e->getMessage()); + + if (!is_string($js)) { + $ch = curl_init($remoteUrl); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HEADER, false); + + $js = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + curl_close($ch); + + if ($redis && $code === 200 && $js) $redis->setex($cacheKey, $ttl, $js); + } + + if (!is_string($js) || trim($js) === '') { + $js = '// Failed to fetch remote script'; + $code = 502; + } + + http_response_code($code); + header('Content-Type: application/javascript; charset=UTF-8'); + echo $js; + exit; } - if (!is_string($js)) { - $ch = curl_init($remoteUrl); + $headers = [ + 'Content-Type: application/json', + 'Accept: application/json', + ]; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, false); + if (isset($_SERVER['HTTP_USER_AGENT'])) $headers[] = 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT']; - $js = curl_exec($ch); - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $ch = curl_init($targetUrl); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_close($ch); + if ($method === 'POST') { + $body = file_get_contents('php://input'); + $data = json_decode($body, true); - if ($redis && $code === 200 && $js) $redis->setex($cacheKey, $ttl, $js); + if (strpos($forwardPath, '/api/send') === 0 && is_array($data)) $data['payload'] = array_merge($data['payload'] ?? [], [ + 'ip' => $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0', + ]); + + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } else { + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } - if (!is_string($js) || trim($js) === '') { - $js = '// Failed to fetch remote script'; - $code = 502; - } + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); - http_response_code($code); - header('Content-Type: application/javascript; charset=UTF-8'); - echo $js; - exit; -} + curl_close($ch); + http_response_code($httpCode); -$headers = [ - 'Content-Type: application/json', - 'Accept: application/json', -]; + if ($contentType) header("Content-Type: $contentType"); -if (isset($_SERVER['HTTP_USER_AGENT'])) $headers[] = 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT']; - -$ch = curl_init($targetUrl); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - -if ($method === 'POST') { - $body = file_get_contents('php://input'); - $data = json_decode($body, true); - - if (strpos($forwardPath, '/api/send') === 0 && is_array($data)) $data['payload'] = array_merge($data['payload'] ?? [], [ - 'ip' => $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0', - ]); - - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); -} else { - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); -} - -$response = curl_exec($ch); -$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); -$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); - -curl_close($ch); -http_response_code($httpCode); - -if ($contentType) header("Content-Type: $contentType"); - -echo $response ?: ''; + echo $response ?: ''; diff --git a/api/watching-import.php b/api/watching-import.php index 09d44f2..40ccb95 100644 --- a/api/watching-import.php +++ b/api/watching-import.php @@ -1,6 +1,6 @@ =22" + } + }, + "node_modules/@isaacs/brace-expansion": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", + "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "license": "MIT", + "dependencies": { + "@isaacs/balanced-match": "^4.0.1" + }, + "engines": { + "node": "20 || >=22" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -425,27 +446,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/balanced-match": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-3.0.1.tgz", - "integrity": "sha512-vjtV3hiLqYDNRoiAv0zC4QaGAMPomEoq83PRmYIofPswwZurCeWR5LByXm7SyoL0Zh5+2z0+HC7jG8gSZJUh0w==", - "license": "MIT", - "engines": { - "node": ">= 16" - } - }, - "node_modules/brace-expansion": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-4.0.1.tgz", - "integrity": "sha512-YClrbvTCXGe70pU2JiEiPLYXO9gQkyxYeKpJIQHVS/gOs6EWMQP2RYBwjFLNT322Ji8TOC3IMPfsYCedNpzKfA==", - "license": "MIT", - "dependencies": { - "balanced-match": "^3.0.0" - }, - "engines": { - "node": ">= 18" - } - }, "node_modules/chalk": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", @@ -673,14 +673,14 @@ } }, "node_modules/glob": { - "version": "11.0.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.2.tgz", - "integrity": "sha512-YT7U7Vye+t5fZ/QMkBFrTJ7ZQxInIUjwyAjVj84CYXqgBdv30MFUPGnBR6sQaVq6Is15wYJUsnzTuWaGRBhBAQ==", + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", "license": "ISC", "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^4.0.1", - "minimatch": "^10.0.0", + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" @@ -791,12 +791,12 @@ } }, "node_modules/minimatch": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.2.tgz", - "integrity": "sha512-+9TJCIYXgZ2Dm5LxVCFsa8jOm+evMwXHFI0JM1XROmkfkpz8/iLLDh+TwSmyIBrs6C6Xu9294/fq8cBA+P6AqA==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", + "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", "license": "ISC", "dependencies": { - "brace-expansion": "^4.0.1" + "@isaacs/brace-expansion": "^5.0.0" }, "engines": { "node": "20 || >=22" diff --git a/cli/package.json b/cli/package.json index 9f23676..9adea6d 100644 --- a/cli/package.json +++ b/cli/package.json @@ -16,7 +16,7 @@ "commander": "^14.0.0", "figlet": "^1.8.1", "fs-extra": "^11.3.0", - "glob": "^11.0.2", + "glob": "^11.0.3", "inquirer": "^12.6.3", "transliteration": "^2.3.5" } diff --git a/config/dynamic/icons.php b/config/dynamic/icons.php new file mode 100644 index 0000000..be31c95 --- /dev/null +++ b/config/dynamic/icons.php @@ -0,0 +1,22 @@ + '', + 'arrow-right' => '', + 'article' => '', + 'books' => '', + 'device-tv-old' => '', + 'headphones' => '', + 'movie' => '', + 'star' => '', + 'vinyl' => '' + ]; + + return $icons[$iconName] ?? '[Missing: ' . htmlspecialchars($iconName) . ']'; + } + } + +?> diff --git a/server/utils/init.php b/config/dynamic/init.php similarity index 100% rename from server/utils/init.php rename to config/dynamic/init.php diff --git a/config/dynamic/media.php b/config/dynamic/media.php new file mode 100644 index 0000000..dfe208a --- /dev/null +++ b/config/dynamic/media.php @@ -0,0 +1,147 @@ + 0 ? $count : count($items); + $firstType = $items[0]['type'] ?? ($items[0]['grid']['type'] ?? ''); + $shapeClass = in_array($firstType, ['books', 'movies', 'tv']) ? 'vertical' : 'square'; + + echo '
'; + + foreach (array_slice($items, 0, $limit) as $item) { + $grid = $item['grid'] ?? $item; + $alt = htmlspecialchars($grid['alt'] ?? ''); + $image = htmlspecialchars($grid['image'] ?? ''); + $title = htmlspecialchars($grid['title'] ?? ''); + $subtext = htmlspecialchars($grid['subtext'] ?? ''); + $url = $grid['url'] ?? null; + $type = $item['type'] ?? ''; + $isVertical = in_array($type, ['books', 'movies', 'tv']); + $imageClass = $isVertical ? 'vertical' : 'square'; + $width = $isVertical ? 120 : 150; + $height = $isVertical ? 184 : 150; + + $openLink = $url ? '' : ''; + $closeLink = $url ? '' : ''; + + echo $openLink; + echo '
'; + + if ($title || $subtext) { + echo '
'; + if ($title) echo '
' . $title . '
'; + if ($subtext) echo '
' . $subtext . '
'; + echo '
'; + } + + echo '' . $alt . ''; + echo '
'; + echo $closeLink; + } + + echo '
'; + } + } + + if (!function_exists('renderAssociatedMedia')) { + function renderAssociatedMedia( + array $artists = [], + array $books = [], + array $genres = [], + array $movies = [], + array $posts = [], + array $shows = [], + ) + { + $sections = [ + "artists" => ["icon" => "headphones", "css_class" => "music", "label" => "Related artist(s)", "hasGrid" => true], + "books" => ["icon" => "books", "css_class" => "books", "label" => "Related book(s)", "hasGrid" => true], + "genres" => ["icon" => "headphones", "css_class" => "music", "label" => "Related genre(s)", "hasGrid" => false], + "movies" => ["icon" => "movie", "css_class" => "movies", "label" => "Related movie(s)", "hasGrid" => true], + "posts" => ["icon" => "article", "css_class" => "article", "label" => "Related post(s)", "hasGrid" => false], + "shows" => ["icon" => "device-tv-old", "css_class" => "tv", "label" => "Related show(s)", "hasGrid" => true] + ]; + + $allMedia = compact('artists', 'books', 'genres', 'movies', 'posts', 'shows'); + + echo '
'; + + foreach ($sections as $key => $section) { + $items = $allMedia[$key]; + + if (empty($items)) continue; + + echo '

'; + echo getTablerIcon($section['icon']); + echo htmlspecialchars($section['label']); + echo '

'; + + if ($section['hasGrid']) { + renderMediaGrid($items); + } else { + echo ''; + } + } + + echo '
'; + } + } + + if (!function_exists('renderMediaLinks')) { + function renderMediaLinks(array $data, string $type, int $count = 10): string { + if (empty($data) || empty($type)) return ""; + + $slice = array_slice($data, 0, $count); + + if (count($slice) === 0) return ""; + + $buildLink = function ($item) use ($type) { + switch ($type) { + case "genre": + return '' . htmlspecialchars($item['genre_name']) . ''; + case "artist": + return '' . htmlspecialchars($item['name']) . ''; + case "book": + return '' . htmlspecialchars($item['title']) . ''; + default: + return ''; + } + }; + + if (count($slice) === 1) return $buildLink($slice[0]); + + $links = array_map($buildLink, $slice); + $last = array_pop($links); + return implode(', ', $links) . ' and ' . $last; + } + } + +?> diff --git a/config/dynamic/metadata.php b/config/dynamic/metadata.php new file mode 100644 index 0000000..d9d1e5c --- /dev/null +++ b/config/dynamic/metadata.php @@ -0,0 +1,39 @@ + $title, + 'pageDescription' => $description, + 'ogImage' => $image, + 'fullUrl' => $fullUrl, + 'oembedUrl' => $oembedUrl, + 'globals' => $globals + ]; + } + } + + if (!function_exists('cleanMeta')) { + function cleanMeta($value) + { + $value = trim($value ?? ''); + $value = str_replace(["\r", "\n"], ' ', $value); + $value = preg_replace('/\s+/', ' ', $value); + return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); + } + } + +?> diff --git a/config/dynamic/paginator.php b/config/dynamic/paginator.php new file mode 100644 index 0000000..aa85661 --- /dev/null +++ b/config/dynamic/paginator.php @@ -0,0 +1,41 @@ + + + + + + diff --git a/config/dynamic/strings.php b/config/dynamic/strings.php new file mode 100644 index 0000000..63ec308 --- /dev/null +++ b/config/dynamic/strings.php @@ -0,0 +1,84 @@ + true, + "linkify" => true, + ]); + + $md->plugin(new MarkdownItFootnote()); + + return $md->render($markdown); + } + } + + if (!function_exists('parseCountryField')) { + function parseCountryField($countryField) + { + if (empty($countryField)) return null; + + $delimiters = [',', '/', '&', ' and ']; + $countries = [$countryField]; + + foreach ($delimiters as $delimiter) { + $tempCountries = []; + + foreach ($countries as $country) { + $tempCountries = array_merge($tempCountries, explode($delimiter, $country)); + } + + $countries = $tempCountries; + } + + $countries = array_map('trim', $countries); + $countries = array_map('getCountryName', $countries); + $countries = array_filter($countries); + + return implode(', ', array_unique($countries)); + } + } + + if (!function_exists('getCountryName')) { + function getCountryName($countryName) + { + $isoCodes = new \Sokil\IsoCodes\IsoCodesFactory(); + $countries = $isoCodes->getCountries(); + $country = $countries->getByAlpha2($countryName); + + if ($country) return $country->getName(); + + return ucfirst(strtolower($countryName)); + } + } + + if (!function_exists('pluralize')) { + function pluralize($count, $string, $trailing = '') + { + if ((int)$count === 1) return $string; + + return $string . 's' . ($trailing ? $trailing : ''); + } + } + +?> diff --git a/config/dynamic/tags.php b/config/dynamic/tags.php new file mode 100644 index 0000000..d3dd791 --- /dev/null +++ b/config/dynamic/tags.php @@ -0,0 +1,17 @@ +'; + + foreach ($tags as $tag) { + $slug = strtolower(trim($tag)); + echo '#' . htmlspecialchars($slug) . ''; + } + + echo ''; + } + } diff --git a/eleventy.config.js b/eleventy.config.js index 805e0a9..977d61b 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -22,8 +22,8 @@ export default async function (eleventyConfig) { eleventyConfig.addPassthroughCopy("src/assets"); eleventyConfig.addPassthroughCopy("api"); - eleventyConfig.addPassthroughCopy("vendor"); - eleventyConfig.addPassthroughCopy("server"); + eleventyConfig.addPassthroughCopy("bootstrap.php"); + eleventyConfig.addPassthroughCopy("config/dynamic"); eleventyConfig.addPassthroughCopy({ "node_modules/minisearch/dist/umd/index.js": "assets/scripts/components/minisearch.js", diff --git a/package-lock.json b/package-lock.json index 61373bf..35ca968 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "9.2.9", + "version": "10.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "9.2.9", + "version": "10.0.0", "license": "MIT", "dependencies": { "minisearch": "^7.1.2", @@ -251,6 +251,29 @@ "dev": true, "license": "MIT" }, + "node_modules/@isaacs/balanced-match": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", + "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/brace-expansion": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", + "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@isaacs/balanced-match": "^4.0.1" + }, + "engines": { + "node": "20 || >=22" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -756,9 +779,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001722", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001722.tgz", - "integrity": "sha512-DCQHBBZtiK6JVkAGw7drvAMK0Q0POD/xZvEmDp6baiMMP6QXXk9HpD6mNYBZWhOPG6LvIDb82ITqtWjhDckHCA==", + "version": "1.0.30001723", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001723.tgz", + "integrity": "sha512-1R/elMjtehrFejxwmexeXAtae5UO9iSyFn6G/I806CYC/BLyyBk1EPhrKBkWhy6wM6Xnm47dSJQec+tLJ39WHw==", "dev": true, "funding": [ { @@ -1385,9 +1408,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.166", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.166.tgz", - "integrity": "sha512-QPWqHL0BglzPYyJJ1zSSmwFFL6MFXhbACOCcsCdUMCkzPdS9/OIBVxg516X/Ado2qwAq8k0nJJ7phQPCqiaFAw==", + "version": "1.5.167", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.167.tgz", + "integrity": "sha512-LxcRvnYO5ez2bMOFpbuuVuAI5QNeY1ncVytE/KXaL6ZNfzX1yPlAO0nSOyIHx2fVAuUprMqPs/TdVhUFZy7SIQ==", "dev": true, "license": "ISC" }, @@ -1720,15 +1743,15 @@ } }, "node_modules/glob": { - "version": "11.0.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.2.tgz", - "integrity": "sha512-YT7U7Vye+t5fZ/QMkBFrTJ7ZQxInIUjwyAjVj84CYXqgBdv30MFUPGnBR6sQaVq6Is15wYJUsnzTuWaGRBhBAQ==", + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", "dev": true, "license": "ISC", "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^4.0.1", - "minimatch": "^10.0.0", + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" @@ -1756,37 +1779,14 @@ "node": ">= 6" } }, - "node_modules/glob/node_modules/balanced-match": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-3.0.1.tgz", - "integrity": "sha512-vjtV3hiLqYDNRoiAv0zC4QaGAMPomEoq83PRmYIofPswwZurCeWR5LByXm7SyoL0Zh5+2z0+HC7jG8gSZJUh0w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 16" - } - }, - "node_modules/glob/node_modules/brace-expansion": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-4.0.1.tgz", - "integrity": "sha512-YClrbvTCXGe70pU2JiEiPLYXO9gQkyxYeKpJIQHVS/gOs6EWMQP2RYBwjFLNT322Ji8TOC3IMPfsYCedNpzKfA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^3.0.0" - }, - "engines": { - "node": ">= 18" - } - }, "node_modules/glob/node_modules/minimatch": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.2.tgz", - "integrity": "sha512-+9TJCIYXgZ2Dm5LxVCFsa8jOm+evMwXHFI0JM1XROmkfkpz8/iLLDh+TwSmyIBrs6C6Xu9294/fq8cBA+P6AqA==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", + "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", "dev": true, "license": "ISC", "dependencies": { - "brace-expansion": "^4.0.1" + "@isaacs/brace-expansion": "^5.0.0" }, "engines": { "node": "20 || >=22" diff --git a/package.json b/package.json index 2798a97..34110f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "9.2.9", + "version": "10.0.0", "description": "The source for my personal site. Built using 11ty (and other tools).", "type": "module", "engines": { diff --git a/queries/views/globals/pages.sql b/queries/views/globals/pages.sql index 12b7e85..947f3ee 100644 --- a/queries/views/globals/pages.sql +++ b/queries/views/globals/pages.sql @@ -24,7 +24,6 @@ SELECT 'url', CONCAT(globals.url, p.permalink), 'type', 'page' ) AS metadata, - p.updated, ( SELECT json_agg( diff --git a/queries/views/media/music/week/summary.sql b/queries/views/media/music/week/summary.sql new file mode 100644 index 0000000..7cad661 --- /dev/null +++ b/queries/views/media/music/week/summary.sql @@ -0,0 +1,34 @@ +CREATE OR REPLACE VIEW optimized_week_music AS +SELECT json_build_object( + 'week_artists', ( + SELECT json_agg(a ORDER BY a.plays DESC) + FROM ( + SELECT * FROM week_artists ORDER BY plays DESC LIMIT 8 + ) a + ), + 'week_albums', ( + SELECT json_agg(al ORDER BY al.plays DESC) + FROM ( + SELECT * FROM week_albums ORDER BY plays DESC LIMIT 8 + ) al + ), + 'week_genres', ( + SELECT json_agg(g ORDER BY g.plays DESC) + FROM ( + SELECT * FROM week_genres ORDER BY plays DESC LIMIT 5 + ) g + ), + 'recent_tracks', ( + SELECT json_agg(r ORDER BY r.listened_at DESC) + FROM ( + SELECT * FROM recent_tracks ORDER BY listened_at DESC LIMIT 10 + ) r + ), + 'week_summary', ( + SELECT json_build_object( + 'total_tracks', (SELECT COUNT(*) FROM week_tracks), + 'total_artists', (SELECT COUNT(*) FROM week_artists), + 'total_albums', (SELECT COUNT(*) FROM week_albums) + ) + ) +) AS week_music; diff --git a/scripts/templates/apache_vhost.conf.template b/scripts/templates/apache_vhost.conf.template index 58ea764..2b4588d 100644 --- a/scripts/templates/apache_vhost.conf.template +++ b/scripts/templates/apache_vhost.conf.template @@ -17,7 +17,7 @@ ServerAdmin hi@coryd.dev ServerName www.coryd.dev - DocumentRoot /var/www/coryd.dev + DocumentRoot /var/www/coryd.dev/public ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined diff --git a/server/utils/icons.php b/server/utils/icons.php deleted file mode 100644 index 1b39e12..0000000 --- a/server/utils/icons.php +++ /dev/null @@ -1,20 +0,0 @@ - '', - 'arrow-right' => '', - 'article' => '', - 'books' => '', - 'device-tv-old' => '', - 'headphones' => '', - 'movie' => '', - 'star' => '', - 'vinyl' => '' - ]; - - return $icons[$iconName] ?? '[Missing: ' . htmlspecialchars($iconName) . ']'; - } - -?> diff --git a/server/utils/media.php b/server/utils/media.php deleted file mode 100644 index 15700c1..0000000 --- a/server/utils/media.php +++ /dev/null @@ -1,112 +0,0 @@ - 0 ? $count : count($items); - $firstType = $items[0]['type'] ?? ($items[0]['grid']['type'] ?? ''); - $shapeClass = in_array($firstType, ['books', 'movies', 'tv']) ? 'vertical' : 'square'; - - echo '
'; - - foreach (array_slice($items, 0, $limit) as $item) { - $grid = $item['grid'] ?? $item; - $alt = htmlspecialchars($grid['alt'] ?? ''); - $image = htmlspecialchars($grid['image'] ?? ''); - $title = htmlspecialchars($grid['title'] ?? ''); - $subtext = htmlspecialchars($grid['subtext'] ?? ''); - $url = $grid['url'] ?? null; - $type = $item['type'] ?? ''; - $isVertical = in_array($type, ['books', 'movies', 'tv']); - $imageClass = $isVertical ? 'vertical' : 'square'; - $width = $isVertical ? 120 : 150; - $height = $isVertical ? 184 : 150; - - $openLink = $url ? '' : ''; - $closeLink = $url ? '' : ''; - - echo $openLink; - echo '
'; - - if ($title || $subtext) { - echo '
'; - if ($title) echo '
' . $title . '
'; - if ($subtext) echo '
' . $subtext . '
'; - echo '
'; - } - - echo '' . $alt . ''; - echo '
'; - echo $closeLink; - } - - echo '
'; - } - - function renderAssociatedMedia( - array $artists = [], - array $books = [], - array $genres = [], - array $movies = [], - array $posts = [], - array $shows = [], - ) { - $sections = [ - "artists" => ["icon" => "headphones", "css_class" => "music", "label" => "Related artist(s)", "hasGrid" => true], - "books" => ["icon" => "books", "css_class" => "books", "label" => "Related book(s)", "hasGrid" => true], - "genres" => ["icon" => "headphones", "css_class" => "music", "label" => "Related genre(s)", "hasGrid" => false], - "movies" => ["icon" => "movie", "css_class" => "movies", "label" => "Related movie(s)", "hasGrid" => true], - "posts" => ["icon" => "article", "css_class" => "article", "label" => "Related post(s)", "hasGrid" => false], - "shows" => ["icon" => "device-tv-old", "css_class" => "tv", "label" => "Related show(s)", "hasGrid" => true] - ]; - - $allMedia = compact('artists', 'books', 'genres', 'movies', 'posts', 'shows'); - - echo '
'; - - foreach ($sections as $key => $section) { - $items = $allMedia[$key]; - - if (empty($items)) continue; - - echo '

'; - echo getTablerIcon($section['icon']); - echo htmlspecialchars($section['label']); - echo '

'; - - if ($section['hasGrid']) { - renderMediaGrid($items); - } else { - echo '
    '; - foreach ($items as $item) { - echo '
  • '; - echo '' . htmlspecialchars($item['title'] ?? $item['name'] ?? '') . ''; - - if ($key === "artists" && isset($item['total_plays']) && $item['total_plays'] > 0) { - echo ' (' . htmlspecialchars($item['total_plays']) . ' play' . ($item['total_plays'] > 1 ? 's' : '') . ')'; - } elseif ($key === "books" && isset($item['author'])) { - echo ' by ' . htmlspecialchars($item['author']); - } elseif (($key === "movies" || $key === "shows") && isset($item['year'])) { - echo ' (' . htmlspecialchars($item['year']) . ')'; - } elseif ($key === "posts" && isset($item['date'])) { - echo ' (' . date("F j, Y", strtotime($item['date'])) . ')'; - } - - echo '
  • '; - } - echo '
'; - } - } - - echo '
'; - } - -?> diff --git a/server/utils/metadata.php b/server/utils/metadata.php deleted file mode 100644 index 0f78a4e..0000000 --- a/server/utils/metadata.php +++ /dev/null @@ -1,33 +0,0 @@ - $title, - 'pageDescription' => $description, - 'ogImage' => $image, - 'fullUrl' => $fullUrl, - 'oembedUrl' => $oembedUrl, - 'globals' => $globals - ]; - } - - function cleanMeta($value) { - $value = trim($value ?? ''); - $value = str_replace(["\r", "\n"], ' ', $value); - $value = preg_replace('/\s+/', ' ', $value); - return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); - } - -?> diff --git a/server/utils/paginator.php b/server/utils/paginator.php deleted file mode 100644 index 7215a29..0000000 --- a/server/utils/paginator.php +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - diff --git a/server/utils/strings.php b/server/utils/strings.php deleted file mode 100644 index fc7f85c..0000000 --- a/server/utils/strings.php +++ /dev/null @@ -1,71 +0,0 @@ - true, - "linkify" => true, - ]); - - $md->plugin(new MarkdownItFootnote()); - - return $md->render($markdown); - } - - function parseCountryField($countryField) { - if (empty($countryField)) return null; - - $delimiters = [',', '/', '&', ' and ']; - $countries = [$countryField]; - - foreach ($delimiters as $delimiter) { - $tempCountries = []; - - foreach ($countries as $country) { - $tempCountries = array_merge($tempCountries, explode($delimiter, $country)); - } - - $countries = $tempCountries; - } - - $countries = array_map('trim', $countries); - $countries = array_map('getCountryName', $countries); - $countries = array_filter($countries); - - return implode(', ', array_unique($countries)); - } - - function getCountryName($countryName) { - $isoCodes = new \Sokil\IsoCodes\IsoCodesFactory(); - $countries = $isoCodes->getCountries(); - $country = $countries->getByAlpha2($countryName); - - if ($country) return $country->getName(); - - return ucfirst(strtolower($countryName)); - } - - function pluralize($count, $string, $trailing = '') { - if ((int)$count === 1) return $string; - - return $string . 's' . ($trailing ? $trailing : ''); - } - -?> diff --git a/server/utils/tags.php b/server/utils/tags.php deleted file mode 100644 index 868459a..0000000 --- a/server/utils/tags.php +++ /dev/null @@ -1,14 +0,0 @@ -'; - - foreach ($tags as $tag) { - $slug = strtolower(trim($tag)); - echo '#' . htmlspecialchars($slug) . ''; - } - - echo ''; -} diff --git a/src/assets/scripts/components/now-playing.js b/src/assets/scripts/components/now-playing.js deleted file mode 100644 index ec49118..0000000 --- a/src/assets/scripts/components/now-playing.js +++ /dev/null @@ -1,41 +0,0 @@ -class NowPlaying extends HTMLElement { - static tagName = "now-playing"; - - static register(tagName = this.tagName, registry = globalThis.customElements) { - registry.define(tagName, this); - } - - async connectedCallback() { - this.contentElement = this.querySelector(".content"); - if (!this.contentElement) return; - - const cache = localStorage.getItem("now-playing-cache"); - if (cache) this.updateHTML(JSON.parse(cache)); - - await this.fetchAndUpdate(); - } - - async fetchAndUpdate() { - try { - const data = await this.fetchData(); - const newHTML = data?.content; - - if (newHTML && newHTML !== this.contentElement.innerHTML) { - this.updateHTML(newHTML); - localStorage.setItem("now-playing-cache", JSON.stringify(newHTML)); - } - } catch {} - } - - updateHTML(value) { - this.contentElement.innerHTML = value; - } - - async fetchData() { - return fetch(`/api/playing.php?nocache=${Date.now()}`) - .then(response => response.json()) - .catch(() => ({})); - } -} - -NowPlaying.register(); diff --git a/src/assets/scripts/sw.js b/src/assets/scripts/sw.js index 56c7c3d..a3421dd 100644 --- a/src/assets/scripts/sw.js +++ b/src/assets/scripts/sw.js @@ -7,7 +7,6 @@ const staticAssets = [ '/assets/fonts/dmi.woff2', '/assets/fonts/ml.woff2', '/assets/scripts/index.js', - '/assets/scripts/components/now-playing.js', '/assets/scripts/components/select-pagination.js', ]; diff --git a/src/assets/styles/base/index.css b/src/assets/styles/base/index.css index aac80b3..8fa2775 100644 --- a/src/assets/styles/base/index.css +++ b/src/assets/styles/base/index.css @@ -501,10 +501,4 @@ footer { footer { margin: var(--sizing-3xl) auto 0; - - .updated { - font-size: var(--font-size-sm); - text-align: center; - margin-top: 0; - } } diff --git a/src/data/nowPlaying.js b/src/data/nowPlaying.js deleted file mode 100644 index d6905b0..0000000 --- a/src/data/nowPlaying.js +++ /dev/null @@ -1,42 +0,0 @@ -import EleventyFetch from "@11ty/eleventy-fetch"; - -const { POSTGREST_URL, POSTGREST_API_KEY } = process.env; - -const fetchLatestListen = async () => { - try { - const data = await EleventyFetch( - `${POSTGREST_URL}/optimized_latest_listen?select=*`, - { - duration: "1h", - type: "json", - fetchOptions: { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${POSTGREST_API_KEY}`, - }, - }, - }, - ); - - const trackData = data[0]; - if (!trackData) { - return { content: "🎧 No recent listens found" }; - } - - const emoji = trackData.artist_emoji || trackData.genre_emoji || "🎧"; - - return { - content: `${emoji} ${ - trackData.track_name - } by ${trackData.artist_name}`, - }; - } catch (error) { - console.error("Error fetching the latest listen:", error); - return {}; - } -}; - -export default async function () { - return await fetchLatestListen(); -} diff --git a/src/data/recentMedia.js b/src/data/recentMedia.js deleted file mode 100644 index 173b10e..0000000 --- a/src/data/recentMedia.js +++ /dev/null @@ -1,33 +0,0 @@ -import EleventyFetch from "@11ty/eleventy-fetch"; - -const { POSTGREST_URL, POSTGREST_API_KEY } = process.env; - -const fetchRecentMedia = async () => { - try { - const data = await EleventyFetch( - `${POSTGREST_URL}/optimized_recent_media?select=*`, - { - duration: "1h", - type: "json", - fetchOptions: { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${POSTGREST_API_KEY}`, - }, - }, - }, - ); - - const [{ recent_activity } = {}] = data; - - return recent_activity || []; - } catch (error) { - console.error("Error fetching recent media data:", error); - return []; - } -}; - -export default async function () { - return await fetchRecentMedia(); -} diff --git a/src/includes/blocks/now-playing.liquid b/src/includes/blocks/now-playing.liquid deleted file mode 100644 index ff63256..0000000 --- a/src/includes/blocks/now-playing.liquid +++ /dev/null @@ -1,7 +0,0 @@ - -

- Now playing  - - {{ nowPlaying }} - -

diff --git a/src/includes/fetchers/artist.php.liquid b/src/includes/dynamic/fetchers/artist.php.liquid similarity index 85% rename from src/includes/fetchers/artist.php.liquid rename to src/includes/dynamic/fetchers/artist.php.liquid index 4432139..0355758 100644 --- a/src/includes/fetchers/artist.php.liquid +++ b/src/includes/dynamic/fetchers/artist.php.liquid @@ -1,7 +1,6 @@ getLatestListen(); + + if (!empty($data['content'])): + +?> +

+ Now playing  + +

+ diff --git a/src/includes/dynamic/media/recent-media.php.liquid b/src/includes/dynamic/media/recent-media.php.liquid new file mode 100644 index 0000000..c96b34d --- /dev/null +++ b/src/includes/dynamic/media/recent-media.php.liquid @@ -0,0 +1,15 @@ +getRecentMedia(); + + if (!empty($media['recentMusic'])) echo renderMediaGrid($media['recentMusic'], 0, 'eager'); + if (!empty($media['recentWatchedRead'])) echo renderMediaGrid($media['recentWatchedRead'], 0, 'eager'); + +?> +{% render "static/blocks/banners/rss.liquid", + url:"/feeds", + text:"Subscribe to my posts, movies, books, links or activity feed(s)" +%} diff --git a/src/includes/dynamic/media/recent-tracks.php.liquid b/src/includes/dynamic/media/recent-tracks.php.liquid new file mode 100644 index 0000000..b1ae846 --- /dev/null +++ b/src/includes/dynamic/media/recent-tracks.php.liquid @@ -0,0 +1,41 @@ + +
+ + +
+
+ + <?= htmlspecialchars($chart['alt'] ?? '') ?> + +
+ + + + +
+
+ + setTimezone(new DateTimeZone('America/Los_Angeles')); + ?> + + +
+ +
+ diff --git a/src/includes/metadata/dynamic.php.liquid b/src/includes/dynamic/metadata/index.php.liquid similarity index 100% rename from src/includes/metadata/dynamic.php.liquid rename to src/includes/dynamic/metadata/index.php.liquid diff --git a/src/includes/home/recent-media.liquid b/src/includes/home/recent-media.liquid deleted file mode 100644 index 46c1011..0000000 --- a/src/includes/home/recent-media.liquid +++ /dev/null @@ -1,15 +0,0 @@ -{% render "media/grid.liquid", - globals:globals, - data:media.recentMusic, - loading:"eager" -%} -{% render "media/grid.liquid", - globals:globals, - data:media.recentWatchedRead, - shape:"vertical", - loading:"eager" -%} -{% render "blocks/banners/rss.liquid", - url:"/feeds", - text:"Subscribe to my posts, movies, books, links or activity feed(s)" -%} diff --git a/src/includes/layout/footer.liquid b/src/includes/layout/footer.liquid deleted file mode 100644 index ce86c18..0000000 --- a/src/includes/layout/footer.liquid +++ /dev/null @@ -1,22 +0,0 @@ -{%- assign updateTime = "" -%} -{%- if updated == "now" -%} - {%- assign updateTime = "now" | date:"%B %-d, %l:%M %P", "America/Los_Angeles" -%} -{%- elsif pageUpdated -%} - {%- assign updateTime = page.updated | date:"%B %-d, %l:%M %P", "America/Los_Angeles" -%} -{%- endif -%} -
- {%- if updateTime -%} -

This page was last updated on {{ updateTime | strip }}.

- {%- endif -%} - {% render "nav/menu.liquid", - page:page, - nav:nav.footer_icons - class:"social" - %} - {% render "nav/menu.liquid", - page:page, - nav:nav.footer_text - class:"sub-pages" - separator:true - %} -
diff --git a/src/includes/media/music/charts/recent.liquid b/src/includes/media/music/charts/recent.liquid deleted file mode 100644 index 6a2040d..0000000 --- a/src/includes/media/music/charts/recent.liquid +++ /dev/null @@ -1,30 +0,0 @@ -
- {%- for item in data limit:10 -%} -
-
- - {{ item.chart.alt | replaceQuotes }} - -
- {{ item.chart.title }} - {{ item.chart.subtext }} -
-
- -
- {%- endfor -%} -
diff --git a/src/includes/blocks/associated-media.liquid b/src/includes/static/blocks/associated-media.liquid similarity index 98% rename from src/includes/blocks/associated-media.liquid rename to src/includes/static/blocks/associated-media.liquid index 679a913..0e5ea3a 100644 --- a/src/includes/blocks/associated-media.liquid +++ b/src/includes/static/blocks/associated-media.liquid @@ -35,7 +35,7 @@ {% if key == "books" or key == "movies" or key == "shows" %} {% assign shape = "vertical" %} {% endif %} - {% render "media/grid.liquid", + {% render "static/media/grid.liquid", data:items, shape:shape %} diff --git a/src/includes/blocks/banners/calendar.liquid b/src/includes/static/blocks/banners/calendar.liquid similarity index 100% rename from src/includes/blocks/banners/calendar.liquid rename to src/includes/static/blocks/banners/calendar.liquid diff --git a/src/includes/blocks/banners/forgejo.liquid b/src/includes/static/blocks/banners/forgejo.liquid similarity index 100% rename from src/includes/blocks/banners/forgejo.liquid rename to src/includes/static/blocks/banners/forgejo.liquid diff --git a/src/includes/blocks/banners/github.liquid b/src/includes/static/blocks/banners/github.liquid similarity index 100% rename from src/includes/blocks/banners/github.liquid rename to src/includes/static/blocks/banners/github.liquid diff --git a/src/includes/blocks/banners/npm.liquid b/src/includes/static/blocks/banners/npm.liquid similarity index 100% rename from src/includes/blocks/banners/npm.liquid rename to src/includes/static/blocks/banners/npm.liquid diff --git a/src/includes/blocks/banners/old-post.liquid b/src/includes/static/blocks/banners/old-post.liquid similarity index 100% rename from src/includes/blocks/banners/old-post.liquid rename to src/includes/static/blocks/banners/old-post.liquid diff --git a/src/includes/blocks/banners/rss.liquid b/src/includes/static/blocks/banners/rss.liquid similarity index 100% rename from src/includes/blocks/banners/rss.liquid rename to src/includes/static/blocks/banners/rss.liquid diff --git a/src/includes/blocks/banners/warning.liquid b/src/includes/static/blocks/banners/warning.liquid similarity index 100% rename from src/includes/blocks/banners/warning.liquid rename to src/includes/static/blocks/banners/warning.liquid diff --git a/src/includes/blocks/dialog.liquid b/src/includes/static/blocks/dialog.liquid similarity index 100% rename from src/includes/blocks/dialog.liquid rename to src/includes/static/blocks/dialog.liquid diff --git a/src/includes/blocks/hero.liquid b/src/includes/static/blocks/hero.liquid similarity index 100% rename from src/includes/blocks/hero.liquid rename to src/includes/static/blocks/hero.liquid diff --git a/src/includes/blocks/index.liquid b/src/includes/static/blocks/index.liquid similarity index 67% rename from src/includes/blocks/index.liquid rename to src/includes/static/blocks/index.liquid index 94d9b5a..e6a2375 100644 --- a/src/includes/blocks/index.liquid +++ b/src/includes/static/blocks/index.liquid @@ -1,22 +1,22 @@ {%- for block in blocks -%} {%- case block.type -%} {%- when "calendar_banner" -%} - {% render "blocks/banners/calendar.liquid", + {% render "static/blocks/banners/calendar.liquid", url:block.url, text:block.text %} {%- when "divider" -%} {{ block.markup | markdown }} {%- when "forgejo_banner" -%} - {% render "blocks/banners/forgejo.liquid", + {% render "static/blocks/banners/forgejo.liquid", url:block.url %} {%- when "github_banner" -%} - {% render "blocks/banners/github.liquid", + {% render "static/blocks/banners/github.liquid", url:block.url %} {%- when "hero" -%} - {% render "blocks/hero.liquid", + {% render "static/blocks/hero.liquid", globals:globals, image:block.image, alt:block.alt @@ -24,17 +24,17 @@ {%- when "markdown" -%} {{ block.text | markdown }} {%- when "npm_banner" -%} - {% render "blocks/banners/npm.liquid", + {% render "static/blocks/banners/npm.liquid", url:block.url, command:block.command %} {%- when "rss_banner" -%} - {% render "blocks/banners/rss.liquid", + {% render "static/blocks/banners/rss.liquid", url:block.url, text:block.text %} {%- when "youtube_player" -%} - {% render "blocks/youtube-player.liquid", + {% render "static/blocks/youtube-player.liquid", url:block.url %} {%- endcase -%} diff --git a/src/includes/blocks/tags.liquid b/src/includes/static/blocks/tags.liquid similarity index 100% rename from src/includes/blocks/tags.liquid rename to src/includes/static/blocks/tags.liquid diff --git a/src/includes/blocks/top-tags.liquid b/src/includes/static/blocks/top-tags.liquid similarity index 100% rename from src/includes/blocks/top-tags.liquid rename to src/includes/static/blocks/top-tags.liquid diff --git a/src/includes/blocks/youtube-player.liquid b/src/includes/static/blocks/youtube-player.liquid similarity index 100% rename from src/includes/blocks/youtube-player.liquid rename to src/includes/static/blocks/youtube-player.liquid diff --git a/src/includes/home/intro.liquid b/src/includes/static/home/intro.liquid similarity index 55% rename from src/includes/home/intro.liquid rename to src/includes/static/home/intro.liquid index 5b8626b..42492bc 100644 --- a/src/includes/home/intro.liquid +++ b/src/includes/static/home/intro.liquid @@ -1,7 +1,6 @@
{{ intro }} - {% render "blocks/now-playing.liquid", - nowPlaying:nowPlaying + {% render "dynamic/media/now-playing.php.liquid", section:"music" %}
diff --git a/src/includes/home/recent-activity.liquid b/src/includes/static/home/recent-activity.liquid similarity index 95% rename from src/includes/home/recent-activity.liquid rename to src/includes/static/home/recent-activity.liquid index bc0731b..0f85091 100644 --- a/src/includes/home/recent-activity.liquid +++ b/src/includes/static/home/recent-activity.liquid @@ -10,7 +10,7 @@ • {{ item.label }} {%- if item.notes -%} {% assign notes = item.notes | markdown %} - {% render "blocks/dialog.liquid", + {% render "static/blocks/dialog.liquid", icon:"info-circle", label:"View info about this concert" dynamic:"optimized_concerts", @@ -49,7 +49,7 @@ {%- endif -%} {%- endif -%} - {% render "blocks/tags.liquid", + {% render "static/blocks/tags.liquid", tags:item.tags %}
diff --git a/src/includes/static/layout/footer.liquid b/src/includes/static/layout/footer.liquid new file mode 100644 index 0000000..3372c55 --- /dev/null +++ b/src/includes/static/layout/footer.liquid @@ -0,0 +1,13 @@ +
+ {% render "static/nav/menu.liquid", + page:page, + nav:nav.footer_icons + class:"social" + %} + {% render "static/nav/menu.liquid", + page:page, + nav:nav.footer_text + class:"sub-pages" + separator:true + %} +
diff --git a/src/includes/layout/header.liquid b/src/includes/static/layout/header.liquid similarity index 91% rename from src/includes/layout/header.liquid rename to src/includes/static/layout/header.liquid index 9db8826..e15f394 100644 --- a/src/includes/layout/header.liquid +++ b/src/includes/static/layout/header.liquid @@ -20,13 +20,13 @@ {{ headerContent }} {%- endif -%} - {% render "nav/menu.liquid", + {% render "static/nav/menu.liquid", page:page, nav:nav.primary_icons class:"icons" %} -{% render "nav/menu.liquid", +{% render "static/nav/menu.liquid", page:page, nav:nav.primary class:"primary" diff --git a/src/includes/media/grid.liquid b/src/includes/static/media/grid.liquid similarity index 97% rename from src/includes/media/grid.liquid rename to src/includes/static/media/grid.liquid index 1ab07fa..e9a50f7 100644 --- a/src/includes/media/grid.liquid +++ b/src/includes/static/media/grid.liquid @@ -42,6 +42,6 @@ {%- endfor -%} -{% render "nav/paginator.liquid", +{% render "static/nav/paginator.liquid", pagination:pagination %} diff --git a/src/includes/media/music/charts/item.liquid b/src/includes/static/media/music/charts/item.liquid similarity index 89% rename from src/includes/media/music/charts/item.liquid rename to src/includes/static/media/music/charts/item.liquid index 861421a..ae21916 100644 --- a/src/includes/media/music/charts/item.liquid +++ b/src/includes/static/media/music/charts/item.liquid @@ -6,7 +6,7 @@ {{ item.chart.plays }} {{ playsLabel }}
- {% render "media/progress-bar.liquid", + {% render "static/media/progress-bar.liquid", percentage:item.chart.percentage %}
diff --git a/src/includes/media/music/charts/rank.liquid b/src/includes/static/media/music/charts/rank.liquid similarity index 73% rename from src/includes/media/music/charts/rank.liquid rename to src/includes/static/media/music/charts/rank.liquid index 2e9b77c..5324d99 100644 --- a/src/includes/media/music/charts/rank.liquid +++ b/src/includes/static/media/music/charts/rank.liquid @@ -3,7 +3,7 @@ {%- if count -%} {%- for item in data limit:count -%}
  • - {% render "media/music/charts/item.liquid", + {% render "static/media/music/charts/item.liquid", item:item %}
  • @@ -11,7 +11,7 @@ {%- else -%} {%- for item in pagination.items -%}
  • - {% render "media/music/charts/item.liquid", + {% render "static/media/music/charts/item.liquid", item:item %}
  • @@ -19,6 +19,6 @@ {%- endif -%} -{% render "nav/paginator.liquid", +{% render "static/nav/paginator.liquid", pagination:pagination %} diff --git a/src/includes/media/music/tables/all-time/albums.liquid b/src/includes/static/media/music/tables/all-time/albums.liquid similarity index 100% rename from src/includes/media/music/tables/all-time/albums.liquid rename to src/includes/static/media/music/tables/all-time/albums.liquid diff --git a/src/includes/media/music/tables/all-time/artists.liquid b/src/includes/static/media/music/tables/all-time/artists.liquid similarity index 100% rename from src/includes/media/music/tables/all-time/artists.liquid rename to src/includes/static/media/music/tables/all-time/artists.liquid diff --git a/src/includes/media/progress-bar.liquid b/src/includes/static/media/progress-bar.liquid similarity index 100% rename from src/includes/media/progress-bar.liquid rename to src/includes/static/media/progress-bar.liquid diff --git a/src/includes/media/watching/hero.liquid b/src/includes/static/media/watching/hero.liquid similarity index 91% rename from src/includes/media/watching/hero.liquid rename to src/includes/static/media/watching/hero.liquid index 349658f..3b4bde8 100644 --- a/src/includes/media/watching/hero.liquid +++ b/src/includes/static/media/watching/hero.liquid @@ -9,7 +9,7 @@ ({{ movie.year }}) - {% render "blocks/hero.liquid", + {% render "static/blocks/hero.liquid", globals:globals, image:movie.backdrop, alt:movie.title diff --git a/src/includes/metadata/base.liquid b/src/includes/static/metadata/base.liquid similarity index 100% rename from src/includes/metadata/base.liquid rename to src/includes/static/metadata/base.liquid diff --git a/src/includes/metadata/index.liquid b/src/includes/static/metadata/index.liquid similarity index 92% rename from src/includes/metadata/index.liquid rename to src/includes/static/metadata/index.liquid index 7c2cb4a..c79194b 100644 --- a/src/includes/metadata/index.liquid +++ b/src/includes/static/metadata/index.liquid @@ -2,7 +2,7 @@ {%- assign source = page -%} {%- case schema -%} {%- when 'artist', 'genre', 'book', 'movie', 'show', 'tags' -%} - {% render "fetchers/{{ schema }}.php.liquid" %} + {% render "dynamic/fetchers/{{ schema }}.php.liquid" %} {%- when 'blog' -%} {%- assign source = post -%} {%- when 'music-index', 'music-week-artists' -%} @@ -37,7 +37,7 @@ {%- assign fullUrl = meta.url -%} {%- assign oembedUrl = globals.url | append: "/oembed" | append: page.url -%} {%- if type == 'dynamic' -%} - {% render "metadata/dynamic.php.liquid" + {% render "dynamic/metadata/index.php.liquid" fullUrl: fullUrl, oembedUrl: oembedUrl, pageTitle: meta.title, @@ -46,7 +46,7 @@ globals: globals, %} {%- else -%} - {% render "metadata/static.liquid" + {% render "static/metadata/static.liquid" fullUrl: fullUrl, oembedUrl: oembedUrl, pageTitle: meta.title, @@ -55,7 +55,7 @@ globals: globals, %} {%- endif %} -{% render "metadata/base.liquid" +{% render "static/metadata/base.liquid" pageTitle: meta.title, globals: globals, eleventy: eleventy, diff --git a/src/includes/metadata/static.liquid b/src/includes/static/metadata/static.liquid similarity index 100% rename from src/includes/metadata/static.liquid rename to src/includes/static/metadata/static.liquid diff --git a/src/includes/nav/link.liquid b/src/includes/static/nav/link.liquid similarity index 90% rename from src/includes/nav/link.liquid rename to src/includes/static/nav/link.liquid index ef3130e..bb3c6fc 100644 --- a/src/includes/nav/link.liquid +++ b/src/includes/static/nav/link.liquid @@ -1,6 +1,7 @@ {%- assign categoryUrl = link.permalink | downcase -%} {%- assign isHttp = categoryUrl contains "http" -%} -{%- if categoryUrl | isLinkActive:page.url -%} +{%- assign url = page.activeUrl | default: page.url -%} +{%- if categoryUrl | isLinkActive:url -%} {%- capture linkClass -%} {%- if link.section -%}button{%- endif -%} {%- if link.icon -%}icon{%- endif -%} diff --git a/src/includes/nav/menu.liquid b/src/includes/static/nav/menu.liquid similarity index 84% rename from src/includes/nav/menu.liquid rename to src/includes/static/nav/menu.liquid index 399aa9d..6b25bdc 100644 --- a/src/includes/nav/menu.liquid +++ b/src/includes/static/nav/menu.liquid @@ -1,6 +1,6 @@