diff options
Diffstat (limited to 'include/prelude.php')
-rw-r--r-- | include/prelude.php | 120 |
1 files changed, 116 insertions, 4 deletions
diff --git a/include/prelude.php b/include/prelude.php index e7d6324..bebcdf5 100644 --- a/include/prelude.php +++ b/include/prelude.php @@ -1,5 +1,17 @@ <?php - function readConfig($key) { + function maybe_use_cache($addr, $lifetime = 0xE10) { + if (file_exists($addr) && filemtime($addr) > time() - $lifetime) { + echo file_get_contents($addr); + + exit; + } + } + + function dump_cache($addr, $buffer) { + file_put_contents($addr, $buffer); + } + + function read_config($key) { if (isset($_GET[$key])) { return htmlspecialchars($_GET[$key], ENT_SUBSTITUTE, "UTF-8"); } else { @@ -7,7 +19,7 @@ } } - function pageColours($page) { + function page_colours($page) { return match ($page) { "achernar" => ["#007B34", "#FFFFFF"], "agbsum" => ["#4D4084", "#FFFFFF"], @@ -26,13 +38,113 @@ }; } - function addHeading($title, $anchor) { + function page_metadata($page) { + return match ($page) { + "achernar" => [ + "Achernar", + "Achernar is a Danish indie studio developing video games and open-source software.", + "achernar, fractals, game, open source, open-source, software, video game", + ], + + "agbsum" => [ + "agbsum | Achernar", + "agbsum is a CLI utility for patching AGB images.", + "achernar, advance, agb, agbsum, cli, console, embedded, game, patch, terminal", + ], + + "ax" => [ + "AX | Achernar", + "AX is a C framework for developing AGB apps.", + "achernar, advance, agb, arm, assembly, ax, c, c++, cpp, cxx, thumb", + ], + + "backspace" => [ + "Backspace | Achernar", + "About the Backspace game engine.", + "achernar, backspace, game engine, rust, udp, webgpu", + ], + + "benoit" => [ + "Benoit | Achernar", + "Benoit is a Rust-written fractal renderer.", + "achernar, benoit, burning ship, cli, console, fractal, julia, mandelbrot, rust, terminal, tricorn, webgpu", + ], + + "bowshock" => [ + "Bowshock | Achernar", + "About Bowshock.", + "achernar, bowshock, dangerous, frontier, game, rust, open world, sci-fi, science fiction, space, video game", + ], + + "bzipper" => [ + "bzipper | Achernar", + "bzipper is a Rust crate for serialisation and deserialisation of binary streams.", + "achernar, binary, bzipper, deserialise, deserialiser, deserialize, deserializer, octet, serialize, serializer, serialize, serializer, tcp, udp", + ], + + "deltaWorld" => [ + "Delta·World | Achernar", + "About Delta World.", + "achernar, adventure, delta world, open world, rust, webgpu", + ], + + "dux" => [ + "Dux | Achernar", + "Dux is a cross-platform widgeting library for developing GUI applications.", + "achernar, dux, multimedia, rust, webgpu, widget", + ], + + "eas" => [ + "eAS | Achernar", + "eAS is an assembler for cross-compiling to Arm ISAs.", + "achernar, agb, arm, as, asm, assembler, assembly, eas, embedded, risc, thumb", + ], + + "luma" => [ + "Luma | Achernar", + "Luma is an emulator for the AGB line of devices.", + "achernar, agb, arm, emulator, luma, rust, thumb", + ], + + "pollex" => [ + "Pollex | Achernar", + "Pollex is a Rust crate for manipulating Arm ISA instructions.", + "achernar, agb, arm, pollex, rust, thumb", + ], + + "u8c" => [ + "u8c | Achernar", + "u8c is a library for handling Unicode sequences in C.", + "achernar, u8c, unicode, utf, utf-16, utf-32, utf-8, utf16, utf32, utf8", + ], + + default => die(), + }; + } + + function add_nav_bar_link($title, $page) { + global $current_page; + + $ariaCurrent = match ($page) { + $current_page => "page", + default => "false", + }; + + $id = match ($page) { + "achernar" => "home", + default => "", + }; + + echo "<a aria-current=\"$ariaCurrent\" href=\"?p=$page\" id=\"$id\">$title</a>"; + } + + function add_heading($title, $anchor) { $anchor = "anchor." . $anchor; echo "<h1 id=\"$anchor\"><a class=\"anchor\" href=\"#$anchor\" title=\"Anchor\"></a> $title</h1>"; } - function addImage($image, $alt) { + function add_image($image, $alt) { $sourceAddr = "/image/source/" . $image . ".webp"; $thumbnailAddr = "/image/thumbnail/" . $image . ".avif"; |