feat(*): refactor dynamic vs. static structure and distinctions; make additional elements dynamic
This commit is contained in:
parent
7a0b808f24
commit
203012eef7
129 changed files with 983 additions and 960 deletions
25
src/includes/dynamic/fetchers/artist.php.liquid
Normal file
25
src/includes/dynamic/fetchers/artist.php.liquid
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
use App\Classes\ArtistFetcher;
|
||||
|
||||
$requestUri = $_SERVER["REQUEST_URI"];
|
||||
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
||||
|
||||
if (strpos($url, "music/artists/") !== 0) redirectTo404();
|
||||
|
||||
$fetcher = new ArtistFetcher();
|
||||
$artist = $fetcher->fetch($url);
|
||||
|
||||
if (!$artist) redirectTo404();
|
||||
|
||||
$artist["description_html"] = parseMarkdown($artist["description"]);
|
||||
$artist["globals"] = $fetcher->getGlobals();
|
||||
$page = $artist;
|
||||
|
||||
extract(setupPageMetadata($page, $requestUri));
|
||||
header("Cache-Control: public, max-age=3600");
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
|
||||
|
||||
?>
|
26
src/includes/dynamic/fetchers/book.php.liquid
Normal file
26
src/includes/dynamic/fetchers/book.php.liquid
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
use App\Classes\BookFetcher;
|
||||
|
||||
$requestUri = $_SERVER["REQUEST_URI"];
|
||||
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
||||
|
||||
if (!preg_match('/^reading\/books\/([\dXx-]+)$/', $url)) redirectTo404();
|
||||
|
||||
$fetcher = new BookFetcher();
|
||||
$book = $fetcher->fetch($url);
|
||||
|
||||
if (!$book) redirectTo404();
|
||||
|
||||
$book["description_html"] = parseMarkdown($book["description"]);
|
||||
$book["globals"] = $fetcher->getGlobals();
|
||||
$page = $book;
|
||||
$globals = $page["globals"];
|
||||
|
||||
extract(setupPageMetadata($page, $requestUri));
|
||||
header("Cache-Control: public, max-age=3600");
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
|
||||
|
||||
?>
|
25
src/includes/dynamic/fetchers/genre.php.liquid
Normal file
25
src/includes/dynamic/fetchers/genre.php.liquid
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
use App\Classes\GenreFetcher;
|
||||
|
||||
$requestUri = $_SERVER["REQUEST_URI"];
|
||||
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
||||
|
||||
if (!preg_match('/^music\/genres\/[\w-]+$/', $url)) redirectTo404();
|
||||
|
||||
$fetcher = new GenreFetcher();
|
||||
$genre = $fetcher->fetch($url);
|
||||
|
||||
if (!$genre) redirectTo404();
|
||||
|
||||
$genre["globals"] = $fetcher->getGlobals();
|
||||
$page = $genre;
|
||||
$globals = $page["globals"];
|
||||
|
||||
extract(setupPageMetadata($page, $requestUri));
|
||||
header("Cache-Control: public, max-age=3600");
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
|
||||
|
||||
?>
|
26
src/includes/dynamic/fetchers/movie.php.liquid
Normal file
26
src/includes/dynamic/fetchers/movie.php.liquid
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
use App\Classes\MovieFetcher;
|
||||
|
||||
$requestUri = $_SERVER["REQUEST_URI"];
|
||||
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
||||
|
||||
if (!preg_match('/^watching\/movies\/[\w-]+$/', $url)) redirectTo404();
|
||||
|
||||
$fetcher = new MovieFetcher();
|
||||
$movie = $fetcher->fetch($url);
|
||||
|
||||
if (!$movie) redirectTo404();
|
||||
|
||||
$movie["description_html"] = parseMarkdown($movie["description"]);
|
||||
$movie["globals"] = $fetcher->getGlobals();
|
||||
$page = $movie;
|
||||
$globals = $page["globals"];
|
||||
|
||||
extract(setupPageMetadata($page, $requestUri));
|
||||
header("Cache-Control: public, max-age=3600");
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
|
||||
|
||||
?>
|
26
src/includes/dynamic/fetchers/show.php.liquid
Normal file
26
src/includes/dynamic/fetchers/show.php.liquid
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
use App\Classes\ShowFetcher;
|
||||
|
||||
$requestUri = $_SERVER["REQUEST_URI"];
|
||||
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
||||
|
||||
if (!preg_match('/^watching\/shows\/[\w-]+$/', $url)) redirectTo404();
|
||||
|
||||
$fetcher = new ShowFetcher();
|
||||
$show = $fetcher->fetch($url);
|
||||
|
||||
if (!$show) redirectTo404();
|
||||
|
||||
$show["description_html"] = parseMarkdown($show["description"]);
|
||||
$show["globals"] = $fetcher->getGlobals();
|
||||
$page = $show;
|
||||
$globals = $page["globals"];
|
||||
|
||||
extract(setupPageMetadata($page, $requestUri));
|
||||
header("Cache-Control: public, max-age=3600");
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
|
||||
|
||||
?>
|
68
src/includes/dynamic/fetchers/tags.php.liquid
Normal file
68
src/includes/dynamic/fetchers/tags.php.liquid
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
require __DIR__ . "/../../vendor/autoload.php";
|
||||
require __DIR__ . "/../../config/dynamic/init.php";
|
||||
|
||||
use App\Classes\TagFetcher;
|
||||
use App\Classes\GlobalsFetcher;
|
||||
|
||||
$requestUri = $_SERVER["REQUEST_URI"];
|
||||
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
||||
|
||||
if ($url === "tags") {
|
||||
readfile("index.html");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!preg_match('/^tags\/(.+?)(?:\/(\d+))?$/', $url, $matches)) redirectTo404();
|
||||
|
||||
if (isset($matches[2]) && (int)$matches[2] === 1) {
|
||||
header("Location: /tags/{$matches[1]}", true, 301);
|
||||
exit();
|
||||
}
|
||||
|
||||
$tag = strtolower(urldecode($matches[1]));
|
||||
|
||||
if (!preg_match('/^[\p{L}\p{N} _\.\-\&]+$/u', $tag)) redirectTo404();
|
||||
|
||||
$pageNum = isset($matches[2]) ? max(1, (int)$matches[2]) : 1;
|
||||
$pageSize = 20;
|
||||
$fetcher = new TagFetcher();
|
||||
$tagged = $fetcher->fetch($tag, $pageNum, $pageSize);
|
||||
|
||||
if (!$tagged || count($tagged) === 0) {
|
||||
header("Location: /404/", true, 302);
|
||||
exit();
|
||||
}
|
||||
|
||||
$totalCount = $tagged[0]['total_count'] ?? 0;
|
||||
$totalPages = max(ceil($totalCount / $pageSize), 1);
|
||||
$pagination = [
|
||||
'pageNumber' => $pageNum,
|
||||
'pages' => range(1, $totalPages),
|
||||
'href' => [
|
||||
'previous' => $pageNum > 1 ? "/tags/{$tag}/" . ($pageNum - 1) : null,
|
||||
'next' => $pageNum < $totalPages ? "/tags/{$tag}/" . ($pageNum + 1) : null
|
||||
],
|
||||
'links' => range(1, $totalPages)
|
||||
];
|
||||
$globals = (new GlobalsFetcher())->fetch();
|
||||
$page = [
|
||||
'tag' => $tag,
|
||||
'items' => $tagged,
|
||||
'pagination' => $pagination,
|
||||
'metadata' => [
|
||||
'title' => '#' . ucfirst($tag) . ' • ' . $globals['site_name'],
|
||||
'description' => 'All content tagged with #' . ucfirst($tag) . '.',
|
||||
'open_graph_image' => $globals['metadata']['open_graph_image'],
|
||||
'url' => $globals['url'] . $requestUri,
|
||||
'type' => 'tag'
|
||||
],
|
||||
'globals' => $globals
|
||||
];
|
||||
|
||||
extract(setupPageMetadata($page, $requestUri));
|
||||
header("Cache-Control: public, max-age=3600");
|
||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue