Routing and Rendering
Routing-and-Rendering.mdRouting and Rendering
Route Structure
most pages are folder routes:
/feed->feed/index.php+feed/content.html/journal/posts/12->journal/posts/index.php/settings->settings/index.php+settings/content.html
static error pages are the main exception:
error/403/index.htmlerror/404/index.htmlerror/50x/index.htmlerror/wip/index.html
Upward File Lookup
most PHP routes define a local find_template_file() helper that walks up parent directories until it finds a requested file.
that means nested routes can still find:
template.htmltemplate_mobile.htmlcontent.htmllib/render.php- root-level assets or data paths
admin account pages use equivalent helpers in account/admin/helpers.php.
Standard Render Flow
typical route flow:
- start session
- optionally enforce auth/admin checks
- load render helper from
lib/render.php - choose template with
get_preferred_template_name(__DIR__) - load local
content.html - inject placeholders like
{content},wiki - routing and rendering,browse the internal developer wiki for fridg3.org., - optionally swap account footer button to logout when logged in
Homepage Special Case
root index.php is more dynamic than the wrapper routes.
it injects:
- latest feed post from
data/feed/*.txt - latest journal post from
data/journal/*.txt - up to 3 music cards from
data/music/frdg3/*.json
it also contains older bookmark-loading logic that still points at /data/users, which is legacy behavior and worth keeping an eye on.
Wrapper Routes vs Data Routes
wrapper routes are mostly just shell + static content:
discord/merch/- parts of
others/ - many email status pages
data-backed routes do real work:
feed/journal/guestbook/bookmarks/music/gallery/account/*api/*
WIP / Maintenance Behavior
maintenance mode is driven by data/etc/wip.
main.js:
- loads the flag
- shows the maintenance banner
- redirects non-admins to
/error/wip - allows
/account/loginand/error/wip
the admin bypass depends on either:
is_admincookie/api/account/is-admin
Page View Counting
page views are not baked in by PHP. the footer view count is hydrated by main.js, which posts the current path to /api/page-view.