diff --git a/.gitignore b/.gitignore index 61a2f04..c574055 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -repos/ebook-fonts +public/repos/ebook-fonts .env diff --git a/README.md b/README.md index 8e00f4c..b9ae325 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,26 @@ -# ebook-fonts showcase +# Showcase for ebook-fonts -A website to showcase my [font collection](https://github.com/nicoverbruggen/ebook-fonts). +**This repository is just to make the source code available.** You can visit the interactive showcase here: [ebook-fonts.nicoverbruggen.be](https://ebook-fonts.nicoverbruggen.be). -You can visit the website at: https://ebook-fonts.nicoverbruggen.be. \ No newline at end of file +A website to showcase my [font collection](https://github.com/nicoverbruggen/ebook-fonts). Browse and preview fonts with adjustable size, line height, dark mode, and bezel color. + +## Project structure + +``` +public/ Web root (served to browsers) + assets/ CSS, JS, SVGs, favicons +src/ PHP includes (not web-accessible) + load_fonts.php Scans the font repo and builds the font list +``` + +## Local development + +```bash +./serve-locally.sh +``` + +Starts a PHP dev server on `http://localhost:8888`. Set `PORT` to use a different port. + +## Deployment + +Fonts are cloned from [ebook-fonts](https://github.com/nicoverbruggen/ebook-fonts) during the build phase (see `nixpacks.toml`). diff --git a/nixpacks.toml b/nixpacks.toml index 1f9d8c2..0a28c14 100644 --- a/nixpacks.toml +++ b/nixpacks.toml @@ -1,6 +1,6 @@ [phases.setup] nixPkgs = ["php84"] -cmds = ["git clone --branch trunk --depth 1 https://github.com/nicoverbruggen/ebook-fonts.git ./repos/ebook-fonts"] +cmds = ["git clone --branch trunk --depth 1 https://github.com/nicoverbruggen/ebook-fonts.git ./public/repos/ebook-fonts"] [start] -cmd = "php -S 0.0.0.0:${PORT:-8080} -t ." +cmd = "php -S 0.0.0.0:${PORT:-8080} -t public" diff --git a/assets/app.js b/public/assets/app.js similarity index 100% rename from assets/app.js rename to public/assets/app.js diff --git a/public/assets/favicon/apple-touch-icon.png b/public/assets/favicon/apple-touch-icon.png new file mode 100644 index 0000000..a9a1fb4 Binary files /dev/null and b/public/assets/favicon/apple-touch-icon.png differ diff --git a/public/assets/favicon/favicon-96x96.png b/public/assets/favicon/favicon-96x96.png new file mode 100644 index 0000000..84cbd2c Binary files /dev/null and b/public/assets/favicon/favicon-96x96.png differ diff --git a/public/assets/favicon/favicon.ico b/public/assets/favicon/favicon.ico new file mode 100644 index 0000000..cf1d9b7 Binary files /dev/null and b/public/assets/favicon/favicon.ico differ diff --git a/assets/showcase.svg b/public/assets/favicon/favicon.svg similarity index 100% rename from assets/showcase.svg rename to public/assets/favicon/favicon.svg diff --git a/public/assets/favicon/site.webmanifest b/public/assets/favicon/site.webmanifest new file mode 100644 index 0000000..8db9ab0 --- /dev/null +++ b/public/assets/favicon/site.webmanifest @@ -0,0 +1,21 @@ +{ + "name": "eBook Fonts Showcase", + "short_name": "Font Showcase", + "icons": [ + { + "src": "assets/favicon/web-app-manifest-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "assets/favicon/web-app-manifest-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any" + } + ], + "theme_color": "#f6e9de", + "background_color": "#fffdf8", + "display": "standalone" +} diff --git a/public/assets/favicon/web-app-manifest-192x192.png b/public/assets/favicon/web-app-manifest-192x192.png new file mode 100644 index 0000000..43c05a1 Binary files /dev/null and b/public/assets/favicon/web-app-manifest-192x192.png differ diff --git a/public/assets/favicon/web-app-manifest-512x512.png b/public/assets/favicon/web-app-manifest-512x512.png new file mode 100644 index 0000000..7f61431 Binary files /dev/null and b/public/assets/favicon/web-app-manifest-512x512.png differ diff --git a/assets/ofl.svg b/public/assets/ofl.svg similarity index 100% rename from assets/ofl.svg rename to public/assets/ofl.svg diff --git a/assets/sample.html b/public/assets/sample.html similarity index 100% rename from assets/sample.html rename to public/assets/sample.html diff --git a/public/assets/showcase.svg b/public/assets/showcase.svg new file mode 100644 index 0000000..affc451 --- /dev/null +++ b/public/assets/showcase.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/styles.css b/public/assets/styles.css similarity index 100% rename from assets/styles.css rename to public/assets/styles.css diff --git a/index.php b/public/index.php similarity index 95% rename from index.php rename to public/index.php index 7477140..c1a1218 100644 --- a/index.php +++ b/public/index.php @@ -1,6 +1,6 @@ @@ -12,7 +12,11 @@ require __DIR__ . '/web/load_fonts.php'; - + + + + + eBook Fonts Showcase diff --git a/serve-locally.sh b/serve-locally.sh new file mode 100755 index 0000000..94c15de --- /dev/null +++ b/serve-locally.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail + +PORT="${PORT:-8888}" +echo "Starting server on http://localhost:${PORT}" +php -S "0.0.0.0:${PORT}" -t public diff --git a/web/load_fonts.php b/src/load_fonts.php similarity index 83% rename from web/load_fonts.php rename to src/load_fonts.php index bf8d66a..3d17f24 100644 --- a/web/load_fonts.php +++ b/src/load_fonts.php @@ -4,7 +4,8 @@ if (!defined('APP_ROOT')) { exit; } -$fontRoot = APP_ROOT . '/repos/ebook-fonts/fonts'; +$fontRoot = APP_ROOT . '/public/repos/ebook-fonts/fonts'; +$webRoot = APP_ROOT . '/public'; $fontEntries = []; $iterator = new RecursiveIteratorIterator( @@ -21,7 +22,7 @@ foreach ($iterator as $fileInfo) { if (str_contains($fileInfo->getFilename(), 'NV_OpenDyslexic')) { continue; } - $relative = str_replace(APP_ROOT . '/', '', $fileInfo->getPathname()); + $relative = str_replace($webRoot . '/', '', $fileInfo->getPathname()); $relative = str_replace(DIRECTORY_SEPARATOR, '/', $relative); $fontEntries[] = $relative; }