summaryrefslogtreecommitdiff
path: root/include/prelude.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/prelude.php')
-rw-r--r--include/prelude.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/prelude.php b/include/prelude.php
new file mode 100644
index 0000000..e782a48
--- /dev/null
+++ b/include/prelude.php
@@ -0,0 +1,60 @@
+<?php
+ function readConfig($key) {
+ if (isset($_GET[$key])) {
+ return htmlspecialchars($_GET[$key], ENT_SUBSTITUTE, "UTF-8");
+ } else {
+ return null;
+ }
+ }
+
+ function pageColours($page) {
+ return match ($page) {
+ "achernar" => ["#007B34", "#FFFFFF"],
+ "agbsum" => ["#422984", "#FFFFFF"],
+ "ax" => ["#422984", "#FFFFFF"],
+ "backspace" => ["#000000", "#FFFFFF"],
+ "benoit" => ["#BA0035", "#FFFFFF"],
+ "bowshock" => ["#B61833", "#FFEEE0"],
+ "bzipper" => ["#FFFFFF", "#B4202D"],
+ "deltaWorld" => ["#000000", "#FFFFFF"],
+ "dux" => ["#131313", "#06FBB2"],
+ "eas" => ["#01CD93", "#00291B"],
+ "luma" => ["#6051B2", "#FFFFFF"],
+ "pollex" => ["#4D4084", "#FFFFFF"],
+ "u8c" => ["#444747", "#A9E13D"],
+ default => die(),
+ };
+ }
+
+ function pageBackgroundImage($page) {
+ return match ($page) {
+ "benoit" => "/svg/benoitBackground.svg",
+ "dux" => "/image/duxBackground.webp",
+ default => null,
+ };
+ }
+
+ function pageGlyph($page) {
+ return "/svg/glyph/" . $page . ".svg";
+ }
+
+ function addHeading($title, $anchor) {
+ $anchor = "anchor." . $anchor;
+
+ echo "<h1 id=\"$anchor\"><a class=\"anchor\" href=\"#$anchor\" title=\"Anchor\"></a> $title</h1>";
+ }
+
+ function addImage($image, $alt) {
+ $sourceAddr = "/image/source/" . $image . ".webp";
+ $thumbnailAddr = "/image/thumbnail/" . $image . ".avif";
+
+ echo <<<HTML
+ <div class="image">
+ <img class="blur" src="$thumbnailAddr">
+ <a href="$sourceAddr" rel="noopener noreferrer" target="_blank" title="Click to view image source.">
+ <img alt="$alt" src="$thumbnailAddr">
+ </a>
+ </div>
+ HTML;
+ }
+?>