diff options
-rw-r--r-- | CHANGELOG.md | 11 | ||||
-rw-r--r-- | css/main.scss | 3 | ||||
-rw-r--r-- | css/navBar.scss | 49 | ||||
-rw-r--r-- | css/overview.scss | 5 | ||||
-rw-r--r-- | css/page.scss | 5 | ||||
-rw-r--r-- | html/404.html | 65 | ||||
-rw-r--r-- | include/achernar.php | 80 | ||||
-rw-r--r-- | include/agbsum.php | 6 | ||||
-rw-r--r-- | include/ax.php | 4 | ||||
-rw-r--r-- | include/benoit.php | 18 | ||||
-rw-r--r-- | include/bzipper.php | 8 | ||||
-rw-r--r-- | include/dux.php | 4 | ||||
-rw-r--r-- | include/eas.php | 4 | ||||
-rw-r--r-- | include/luma.php | 4 | ||||
-rw-r--r-- | include/pollex.php | 4 | ||||
-rw-r--r-- | include/prelude.php | 120 | ||||
-rw-r--r-- | include/u8c.php | 6 | ||||
-rw-r--r-- | index.php | 183 | ||||
-rwxr-xr-x | install.sh | 2 |
19 files changed, 341 insertions, 240 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4efa05d..fae4b4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 11.8 + +* Update overview styling +* Refactor stylesheets +* Elaborate pages +* Cache pages +* Refactor server scripts +* Disallow invalid pages +* Add our own `404` page +* Update touch styling + ## 11.7 * Fix separators diff --git a/css/main.scss b/css/main.scss index 730347c..615ef99 100644 --- a/css/main.scss +++ b/css/main.scss @@ -50,7 +50,8 @@ body { } a, a:visited { - color: var(--textColour); + color: var(--textColour); + cursor: pointer; } code { diff --git a/css/navBar.scss b/css/navBar.scss index 136b592..b311992 100644 --- a/css/navBar.scss +++ b/css/navBar.scss @@ -1,22 +1,19 @@ #navBar { - align-items: center; - display: flex; - font-family: $specialFont; - justify-content: space-between; - left: 50%; - max-width: calc($contentWidth + $padding * 2); - padding: $padding; - position: absolute; - top: 0; - transform: translateX(-50%); - width: 100%; + display: flex; + font-family: $specialFont; + left: 50%; + max-width: calc($contentWidth + $padding * 2); + padding: $padding; + position: absolute; + top: 0; + transform: translateX(-50%); + width: 100%; section { - display: flex; - flex: 1 1 0; - gap: $gap; - justify-content: center; - text-align: center; + display: flex; + flex: 1 1 0; + gap: $gap; + text-align: center; &:first-of-type { justify-content: start; @@ -35,26 +32,26 @@ text-decoration: underline; text-decoration-color: #00000000; - &[aria-current = "page"]::after { - @include separator; - - left: 50%; - position: absolute; - top: calc(100% + $separatorWidth); - transform: translateX(-50%); - } - @media not (prefers-reduced-motion) { transition: text-decoration-color 0.125s; transition-timing-function: ease-in-out; } - @media (orientation: portrait) or (pointer: coarse) { + @media (orientation: portrait) { &:not(#home, #themeToggler) { display: none; } } + &[aria-current = "page"]::after { + @include separator; + + left: 50%; + position: absolute; + top: calc(100% + $separatorWidth); + transform: translateX(-50%); + } + &:hover { text-decoration-color: var(--textColour); } diff --git a/css/overview.scss b/css/overview.scss index d67bd4b..ea8466b 100644 --- a/css/overview.scss +++ b/css/overview.scss @@ -1,7 +1,6 @@ #overview { - $cardsPerRow: 3; + $cardsPerRow: 4; - align-items: center; background-color: var(--foregroundColour); border-radius: calc($padding / 2); display: flex; @@ -21,8 +20,6 @@ display: flex; flex-basis: calc((100% - $padding * ($cardsPerRow - 1)) / $cardsPerRow); justify-content: center; - padding: $padding; - width: $padding; @media not (prefers-reduced-motion) { transition: box-shadow 0.25s; diff --git a/css/page.scss b/css/page.scss index 77bcdf5..fd71b5b 100644 --- a/css/page.scss +++ b/css/page.scss @@ -3,11 +3,6 @@ max-width: calc($contentWidth + $padding * 2); padding: $padding; - a, a:visited { - cursor: pointer; - text-decoration: underline; - } - h1 { font-family: $specialFont; font-size: 2em; diff --git a/html/404.html b/html/404.html new file mode 100644 index 0000000..c06882f --- /dev/null +++ b/html/404.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="UTF-8"> + <meta name="author" content="Gabriel Bjørnager Jensen"> + <meta name="darkreader-lock"> + <meta name="robots" content="noindex"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + <link href="/favicon.ico" rel="icon" type="image/vnd.microsoft.icon"> + <link href="/apple-touch-icon.png" rel="apple-touch-icon" type="image/png"> + + <link href="/css/normalise.css" rel="stylesheet" type="text/css"> + <link href="/css/font.css" rel="stylesheet" type="text/css"> + + <style> + :root { + font-family: "Martian Mono", "monospace"; + } + + * { + margin: 0; + padding: 0; + + box-sizing: border-box; + } + + body { + align-items: center; + background-color: black; + color: white; + display: flex; + flex-direction: column; + height: 100vh; + justify-content: center; + width: 100vw; + } + + p { + animation-duration: 8s; + animation-iteration-count: infinite; + animation-name: glow; + animation-timing-function: ease-in-out; + display: block; + font-size: 16rem; + font-weight: bold; + width: fit-content; + } + + @keyframes glow { + 0% { + text-shadow: 0 0 0 white; + } + + 50% { + text-shadow: 0 0 0.125em white; + } + } + </style> + </head> + + <body> + <p>404</p> + </body> +</html> diff --git a/include/achernar.php b/include/achernar.php index b54d189..1530e98 100644 --- a/include/achernar.php +++ b/include/achernar.php @@ -1,4 +1,26 @@ -<?php addHeading("The future is <em>now</em>", "about"); ?> +<?php + function add_overview_card($page, $title) { + [$background_colour, $text_colour] = page_colours($page); + + $glyph_addr = match ($page) { + "benoit", + "pollex", + => "/svg/glyph/" . $page . "Small.svg", + + default => "/svg/glyph/" . $page . ".svg", + }; + + $card_style = "--backgroundColour: $background_colour; --textColour: $text_colour;"; + + echo <<<HTML + <a href="?p=$page" style="$card_style" title="$title"> + <img alt="$page" src="$glyph_addr"> + </a> + HTML; + } +?> + +<?php add_heading("The future is now", "about"); ?> <section> <p><em>Achernar</em> is a European indie development studio based in the Capital Region of Denmark. 🇩🇰</p> @@ -8,7 +30,7 @@ <p class="note">See footer for contact information.</p> </section> -<?php addHeading("Projects", "projects"); ?> +<?php add_heading("Projects", "projects"); ?> <section class="fullWidth"> <p>The following is a list of our current projects. Click on a card to view the project's page.</p> @@ -17,43 +39,23 @@ <br> <div id="overview"> <?php - function addCard($page, $title) { - [$backgroundColour, $textColour] = pageColours($page); - - $glyphAddr = match ($page) { - "benoit", - "pollex", - => "/svg/glyph/" . $page . "Small.svg", - - default => "/svg/glyph/" . $page . ".svg", - }; - - $cardStyle = "--backgroundColour: $backgroundColour; --textColour: $textColour;"; - - echo <<<HTML - <a href="?p=$page" style="$cardStyle" title="$title"> - <img alt="$page" src="$glyphAddr"> - </a> - HTML; - } - - addCard("agbsum", "agbsum"); - addCard("ax", "AX"); - //addCard("backspace", "Backspace"); - addCard("benoit", "Benoit"); - addCard("bowshock", "Bowshock"); - addCard("bzipper", "Bzipper"); - //addCard("deltaWorld", "Delta·World"); - addCard("dux", "Dux"); - addCard("eas", "eAS"); - addCard("luma", "Luma"); - addCard("pollex", "Pollex"); - addCard("u8c", "u8c"); + add_overview_card("agbsum", "agbsum"); + add_overview_card("ax", "AX"); + //add_overview_card("backspace", "Backspace"); + add_overview_card("benoit", "Benoit"); + add_overview_card("bowshock", "Bowshock"); + add_overview_card("bzipper", "Bzipper"); + //add_overview_card("deltaWorld", "Delta·World"); + add_overview_card("dux", "Dux"); + add_overview_card("eas", "eAS"); + add_overview_card("luma", "Luma"); + add_overview_card("pollex", "Pollex"); + add_overview_card("u8c", "u8c"); ?> </div> </section> -<?php addHeading("Vision", "vision"); ?> +<?php add_heading("Vision", "vision"); ?> <section> <p>The goal of Achernar is to promote modern and robust software for everyone. In other words, our vision is to develop a human and clean industry and community for technology.</p> @@ -61,7 +63,7 @@ <p>We believe in a society free of patents, and as such we release our scientific software in open-source form. For our games, we try to keep the base engine as open as possible whilst still keeping in mind that they yield our main income.</p> </section> -<?php addHeading("Roadmap", "roadmap"); ?> +<?php add_heading("Roadmap", "roadmap"); ?> <section> <p>Currently, our roadmap is as follows:</p> @@ -84,13 +86,13 @@ <p>This roadmap is, however, also subject to change, altough we do strive to live up to it.</p> </section> -<?php addHeading("Team", "team"); ?> +<?php add_heading("Team", "team"); ?> <section> <p>As Achernar is currently registered as a PMV (lesser sole proprietorship), Gabriel Bjørnager Jensen is currently our only member.</p> </section> -<?php addHeading("Inception", "inception"); ?> +<?php add_heading("Inception", "inception"); ?> <section> <p><em>Achernar</em> was incorporated on the first july of 2024 by current sole proprietor Gabriel Bjørnager Jensen.</p> @@ -104,7 +106,7 @@ <p>Shortly after being incorporated, we registered the domain <code>achernar.io</code>. At that time, we also set up mail services using our domain.</p> </section> -<?php addHeading("Credits", "credits"); ?> +<?php add_heading("Credits", "credits"); ?> <section class="fullWidth"> <p>Thanks to <strong>Nicolas Gallagher</strong> for the <a href="https://necolas.github.io/normalize.css/"><code>normalize.css</code></a> stylesheet. Additionally thanks to the following creators for the fonts which we use on our website:</p> diff --git a/include/agbsum.php b/include/agbsum.php index afe3ebe..344930e 100644 --- a/include/agbsum.php +++ b/include/agbsum.php @@ -1,10 +1,10 @@ -<?php addHeading("agbsum", "about"); ?> +<?php add_heading("agbsum", "about"); ?> <section> <p><em>agbsum</em> is a command line utility for patching AGB images.</p> </section> -<?php addHeading("Specs", "specs"); ?> +<?php add_heading("Specs", "specs"); ?> <section> <p>All AGB images have a header at offsets <code>0x00-0xE3</code> (inclusive), of which (29) bytes in <code>0xA0-0xBD</code> denote metadata.</p> @@ -12,7 +12,7 @@ <p>The first byte after this sequence holds a checksum of the metadata, which if invalid, the device bootloader will usually reject the entire image.</p> </section> -<?php addHeading("Compatibility", "compatibility"); ?> +<?php add_heading("Compatibility", "compatibility"); ?> <section> <p><em>agbsum</em> is written in <strong>C99</strong> and uses makefiles as its build system. It has been tested to compile under Clang, GCC, and the <a href="https://bellard.org/tcc/">Tiny C Compiler</a> (altough the latter may have problems with the standard library). Both GNU Make (<code>gmake</code>) and BSD Make (<code>bmake</code>).</p> diff --git a/include/ax.php b/include/ax.php index bc7cdc4..75d13a3 100644 --- a/include/ax.php +++ b/include/ax.php @@ -1,10 +1,10 @@ -<?php addHeading("Advanced X", "about"); ?> +<?php add_heading("Advanced X", "about"); ?> <section> <p><em>Advanced X</em> (or just <em>AX</em>) is a C library for developing apps for the <em>AGB</em> line of hardware.</p> </section> -<?php addHeading("Status", "status"); ?> +<?php add_heading("Status", "status"); ?> <section> <p>The development of <em>AX</em> is currently on hold to prioritise <a href="?p=luma"><em>Luma</em></a> and <a href="?p=eas"><em>eAS</em></a>.</p> diff --git a/include/benoit.php b/include/benoit.php index 7d0013b..79e4bd9 100644 --- a/include/benoit.php +++ b/include/benoit.php @@ -1,29 +1,29 @@ -<?php addHeading("Benoit", "about"); ?> +<?php add_heading("Benoit", "about"); ?> <section> <p><em>Benoit</em> is a Rust-written programme for visualising complex functions, e.g. <a href="https://en.wikipedia.org/wiki/Mandelbrot_set/"><em>the Mandelbrot Set</em></a> and similar fractals.</p> <br> - <?php addImage("benoit_2024-04-06_11-35-23", "A render of a single Minibrot on a green background. The render is coloures so that it resembles lightning coming from the Minibrot.") ?> + <?php add_image("benoit_2024-04-06_11-35-23", "A render of a single Minibrot on a green background. The render is coloures so that it resembles lightning coming from the Minibrot.") ?> <br> <p>The project consists of the core <a href="https://crates.io/crates/benoit/"><code>benoit</code></a> crate, from which the front-ends <code>benoit-cli</code> and (in the future) <code>benoit-gui</code> derive.</p> </section> -<?php addHeading("Features", "features"); ?> +<?php add_heading("Features", "features"); ?> <section> <p>The core library uses multi-threading for rendering the provided scenes. Internally, the <a href="https://crates.io/crates/rayon/">Rayon</a> crate is used for threadpooling and such, where each pixel on the canvas is a job in and of itself.</p> <br> - <?php addImage("inverseJulia20231009200744", "An inverse Julia Set outside the Burning Ship fractal, resembling circles intertwined in a diamond shape with a dark red colour scheme.") ?> + <?php add_image("inverseJulia20231009200744", "An inverse Julia Set outside the Burning Ship fractal, resembling circles intertwined in a diamond shape with a dark red colour scheme.") ?> <br> <p>The <code><a href="#anchor.benoitCli">benoit-cli</a></code> front-end supports exporting to PNG. These images are saved with transparency and with sixteen bits per channel.</p> </section> -<?php addHeading("benoit-cli", "benoitCli"); ?> +<?php add_heading("benoit-cli", "benoitCli"); ?> <section> <p>The <code>benoit-cli</code> executable can render and animate using <a href="https://en.wikipedia.org/wiki/TOML/">TOML</a> files right from the commandline.</p> <br> - <?php addImage("benoit_2024-04-05_20-55-13", "A Julia Set centred on a point inside the Mandelbrot Set. The resulting image resembles creeping, black vines with rainbows around.") ?> + <?php add_image("benoit_2024-04-05_20-55-13", "A Julia Set centred on a point inside the Mandelbrot Set. The resulting image resembles creeping, black vines with rainbows around.") ?> <br> <p>The main use of <code>benoit-cli</code> is to render still images or animations of fractals, e.g. zoom-ins. An example configuration could look like the following:</p> <br> @@ -34,17 +34,17 @@ <p class="codeblock">$ benoit-cli "benoit.toml"</p> </section> -<?php addHeading("benoit-gui", "benoitGui"); ?> +<?php add_heading("benoit-gui", "benoitGui"); ?> <section> <p>The <code>benoit-gui</code> executable, on the other hand, allows viewing fractals in realtime. Do note, however, that this front-end is currently unimplemented.</p> <br> - <?php addImage("inverseJulia", "An inverse Julia Set just outside the Mandelbrot Set, with a surface resembling the bulb figures on the main cardioid's exterior.") ?> + <?php add_image("inverseJulia", "An inverse Julia Set just outside the Mandelbrot Set, with a surface resembling the bulb figures on the main cardioid's exterior.") ?> <br> <p>Until this front-end is implemented, please use version <a href="https://mandelbrot.dk/benoit/tag/?h=2.7.1"><code>2.7.1</code></a> of Benoit instead.</p> </section> -<?php addHeading("Docs", "docs"); ?> +<?php add_heading("Docs", "docs"); ?> <section> <p>Documentation is written in source. Documentation for the main library is hosted on <a href="https://docs.rs/benoit/latest/benoit/"><code>docs.rs</code></a>.</p> diff --git a/include/bzipper.php b/include/bzipper.php index 8b6b677..023f30b 100644 --- a/include/bzipper.php +++ b/include/bzipper.php @@ -1,4 +1,4 @@ -<?php addHeading("bzipper", "about"); ?> +<?php add_heading("bzipper", "about"); ?> <section> <p><em>bzipper</em> is a Rust crate for serialisation and deserialisation of binary streams.</p> @@ -6,13 +6,13 @@ <p>See more at <code><a href="https://crates.io/crates/bzipper/">crates.io</a></code>.</p> </section> -<?php addHeading("rationale", "rationale"); ?> +<?php add_heading("rationale", "rationale"); ?> <section> <p>Contrary to <a href="https://crates.io/crates/serde/">Serde</a>/<a href="https://crates.io/crates/bincode/">Bincode</a>, the goal of this crate is to serialise data with a known size limit. Therefore, this crate may be more suited for networking or other cases where a fixed-sized buffer is needed.</p> </section> -<?php addHeading("data model", "dataModel"); ?> +<?php add_heading("data model", "dataModel"); ?> <section> <p>Most primitive types serialise losslessly, with the exception being <code>usize</code> and <code>isize</code>. These serialise as <code>u16</code> and <code>u32</code>, respectively, for portability reasons.</p> @@ -20,7 +20,7 @@ <p>Unsized types, such as <code>str</code> and slices, are not supported. Instead, array should be used. For strings, the <code>FixedString</code> type is also provided.</p> </section> -<?php addHeading("docs", "docs"); ?> +<?php add_heading("docs", "docs"); ?> <section> <p>Documentation is written in-source. See <a href="https://docs.rs/pollex/latest/pollex/"><code>docs.rs</code></a> for a rendered instance.</p> diff --git a/include/dux.php b/include/dux.php index 409ae2a..64c7838 100644 --- a/include/dux.php +++ b/include/dux.php @@ -1,10 +1,10 @@ -<?php addHeading("Dux", "about"); ?> +<?php add_heading("Dux", "about"); ?> <section> <p><em>Dux</em> is a cross-platform widgeting library for developing GUI applications.</p> </section> -<?php addHeading("Status", "status"); ?> +<?php add_heading("Status", "status"); ?> <section> <p>Dux is currently on standby and therefore unmaintained.</p> diff --git a/include/eas.php b/include/eas.php index ef51325..33805fa 100644 --- a/include/eas.php +++ b/include/eas.php @@ -1,4 +1,4 @@ -<?php addHeading("The Embedded Assembler", "about"); ?> +<?php add_heading("The Embedded Assembler", "about"); ?> <section> <p>The <em>Embedded Assembler</em> (or simply <em>eAS</em>; as in <i>ease</i>) is an assembler for cross-compiling to Arm ISAs.</p> @@ -6,7 +6,7 @@ <p>The assembler is intended as a drop-in replacement for the official <em>armasm</em> assembler by Arm Limited. It therefore imitates the same syntax.</p> </section> -<?php addHeading("Status", "status"); ?> +<?php add_heading("Status", "status"); ?> <section> <p>Like <a href="?p=luma"><em>Luma</em></a>, the development of <em>eAS</em> is currently on hold in favour of the <a href="?p=pollex"><em>Pollex</em></a> library, which will be used as a backend.</p> diff --git a/include/luma.php b/include/luma.php index a8192ea..3af80af 100644 --- a/include/luma.php +++ b/include/luma.php @@ -1,10 +1,10 @@ -<?php addHeading("Luma", "about"); ?> +<?php add_heading("Luma", "about"); ?> <section> <p><em>Luma</em> is an emulator for the <em>AGB</em> line of game consoles by Nintendo Co.</p> </section> -<?php addHeading("Status", "status"); ?> +<?php add_heading("Status", "status"); ?> <section> <p>The development of <em>Luma</em> is currently on hold in favour of <a href="?p=pollex"><em>Pollex</em></a>, which is to be used as a backend.</p> diff --git a/include/pollex.php b/include/pollex.php index d4b9e69..6056aad 100644 --- a/include/pollex.php +++ b/include/pollex.php @@ -1,4 +1,4 @@ -<?php addHeading("Pollex", "about"); ?> +<?php add_heading("Pollex", "about"); ?> <section> <p><em>Pollex</em> is a Rust crate for manipulating Arm ISA instructions. Its goal is to be used as a backend for Arm emulators, assemblers etc.</p> @@ -8,7 +8,7 @@ <p>See more at <a href="https://crates.io/crates/pollex/"><code>crates.io</code></a>.</p> </section> -<?php addHeading("Docs", "docs"); ?> +<?php add_heading("Docs", "docs"); ?> <section> <p>As per usual, documentation for <em>Pollex</em> can be found on <a href="https://docs.rs/pollex/latest/pollex/"><code>docs.rs</code></a>.</p> 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"; diff --git a/include/u8c.php b/include/u8c.php index c0ded80..9b04dd0 100644 --- a/include/u8c.php +++ b/include/u8c.php @@ -1,10 +1,10 @@ -<?php addHeading("u8c", "about"); ?> +<?php add_heading("u8c", "about"); ?> <section> <p><em>u8c</em> is a library for handling Unicode sequences in C.</p> </section> -<?php addHeading("Features", "features"); ?> +<?php add_heading("Features", "features"); ?> <section> <p><em>u8c</em> supports the following facilities:</p> @@ -17,7 +17,7 @@ <p>Encoding and decoding <em>UTF-16</em></p> </li> <li> - <p>Manipulation of <em>UTF-32</em> strings.</p> + <p>Manipulating <em>UTF-32</em> strings.</p> </li> </ul> <br> @@ -1,28 +1,41 @@ -<?php require "include/prelude.php" ?> - <?php - $currentPage = readConfig("p"); + namespace ach; + + require "include/prelude.php"; + + $current_page = read_config("p"); // Remember to sanitise unsafe values. - $currentPage = match ($currentPage) { - "achernar", - "agbsum", - "ax", - "backspace", - "benoit", - "bowshock", - "bzipper", - "deltaWorld", - "dux", - "eas", - "luma", - "pollex", - "u8c", - => $currentPage, - - default => "achernar", + switch ($current_page) { + case "achernar": + case "agbsum": + case "ax": + case "backspace": + case "benoit": + case "bowshock": + case "bzipper": + case "deltaWorld": + case "dux": + case "eas": + case "luma": + case "pollex": + case "u8c": + break; + + default: + http_response_code(404); + require "html/404.html"; + + exit; }; + + // Set up cache now. + + $cache_addr = "cache/" . $current_page . ".cache"; + maybe_use_cache($cache_addr); + + ob_start(); ?> <!DOCTYPE html> @@ -34,87 +47,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> <?php - [$title, $description, $keywords] = match ($currentPage) { - "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(), - }; + [$title, $description, $keywords] = page_metadata($current_page); echo <<<HTML <meta name="description" content="$description"> @@ -138,18 +71,18 @@ <style type="text/css"> #header { - --backgroundColour: <?php echo pageColours($currentPage)[0x0] ?>; - --textColour: <?php echo pageColours($currentPage)[0x1] ?>; + --backgroundColour: <?php echo page_colours($current_page)[0x0] ?>; + --textColour: <?php echo page_colours($current_page)[0x1] ?>; <?php - $backgroundImage = match ($currentPage) { + $background_image = match ($current_page) { "benoit" => "/svg/benoitBackground.svg", "dux" => "/image/duxBackground.webp", default => null, }; - if (!is_null($backgroundImage)) { - echo 'background-image: url("' . $backgroundImage . '");'; + if (!is_null($background_image)) { + echo 'background-image: url("' . $background_image . '");'; } ?> } @@ -159,34 +92,16 @@ <body> <header id="header"> <div id="navBar"> - <?php - function addNavBarLink($title, $page) { - global $currentPage; - - $ariaCurrent = "false"; - if ($page == $currentPage) { - $ariaCurrent = "page"; - } - - $id = match ($page) { - "achernar" => "home", - default => "", - }; - - echo "<a aria-current=\"$ariaCurrent\" href=\"?p=$page\" id=\"$id\">$title</a>"; - } - ?> - <section> - <?php addNavBarLink("ACHERNAR", "achernar"); ?> + <?php add_nav_bar_link("ACHERNAR", "achernar"); ?> </section> <section> <?php - addNavBarLink("BENOIT", "benoit"); - addNavBarLink("BOWSHOCK", "bowshock"); - addNavBarLink("DELTA·WORLD", "deltaWorld"); - addNavBarLink("eAS", "eas"); + add_nav_bar_link("BENOIT", "benoit"); + add_nav_bar_link("BOWSHOCK", "bowshock"); + add_nav_bar_link("DELTA·WORLD", "deltaWorld"); + add_nav_bar_link("eAS", "eas"); ?> </section> @@ -196,14 +111,14 @@ </div> <?php - $glyphAddr = "/svg/glyph/" . $currentPage . ".svg"; + $glyphAddr = "/svg/glyph/" . $current_page . ".svg"; - echo "<img alt=\"$currentPage\" id=\"glyph\" src=\"$glyphAddr\" />"; + echo "<img alt=\"$current_page\" id=\"glyph\" src=\"$glyphAddr\" />"; ?> </header> <div id="page"> - <?php require "include/" . $currentPage . ".php" ?> + <?php require "include/" . $current_page . ".php" ?> </div> <footer id="footer"> @@ -232,3 +147,7 @@ Ach.init(); </script> </html> + +<?php + dump_cache($cache_addr, ob_get_contents()); +?> @@ -21,10 +21,12 @@ cp "favicon.ico" "${DESTINATION}" cp "index.php" "${DESTINATION}" cp -r "font" "${DESTINATION}" +cp -r "html" "${DESTINATION}" cp -r "image" "${DESTINATION}" cp -r "include" "${DESTINATION}" cp -r "svg" "${DESTINATION}" +mkdir -p "${DESTINATION}/cache" mkdir -p "${DESTINATION}/css" mkdir -p "${DESTINATION}/js" |