- Sidebar renders the section's whole subtree as nested lists (third level and deeper, article-list-style markers); the one-item sidebar rule yields when that item has children of its own; only the viewed page is highlighted (navbar keeps ancestor highlighting); first_leaf skips unpublished branches - Banner design selector: inherit option names the resolved design and its true source (backend banner_design_source excludes the node's own setting; doc payload carries banner_design_inherited) - Article editor: fenced code block on empty lines, table size picker popup, borderless save icon disabled by saturate(0) alone - While editing, window scroll is locked and only #main scrolls; the panel exactly fills the available window height; editor scroll drives the article
22 KiB
22 KiB
AGENTS.md
- Do NOT test, run the server, write tests etc.
- ESPECIALLY DO NOT make repros, do NOT install Playwright etc.
Please instead ask the user to see from dev tools what you need, e.g. to look up something in DOM or log. Use console.log for debugging where needed (and otherwise for permanently kept useful messages in the app).
What this is
Pagerite: a single-user CMS/blog. FastAPI serves HTML rendered in Python
with html5tagger; content is persisted in a kanta database and rendered on
the fly per request. Vue is used only for interactive bits (editing tools),
not for the public pages. See docs/design-principles.md for the design.
Layout
pagerite/— the Python backend package (hatchling build target).- Server run by CLI entry point
uv run pagerite(no auto reloads, build needed) - Dev mode
scripts/devserver.py(which the user mostly uses for auto reloads, no build needed) - Avoid running the server yourself, ask the user to test
app.py— the FastAPI app. FastAPI's built-in API docs are disabled (docs_url/redoc_url/openapi_url=None) because/docsbelongs to our content. Our own routes (content pages,/_api/...,/_f/...) are registered BEFOREfrontend.route(app, "/")is called: fastapi-vue inserts its file routes at the position whereroute()was called (duringload()in the lifespan), so anything defined earlier wins. The one exception is the content catch-all/{path:path}, registered AFTERfrontend.route()so that built frontend assets still take priority over content slugs. TheFrontendis constructed withspa=Falseexplicitly: it only serves the built files without a catch-all. The build mirrors the URL space — hashed immutable assets under/_assets/,favicon.icoat the site root — and anindex.htmlin the build would become a/route, so leave it out of the build to keep/ours.data.py— msgspec Structs for the kanta database. The site structure is a tree:Data.menumaps top-level slugs toNodes, each withchildrenkeyed by slug — the URL path is the slug chain. The front page is whichever top-level node has slug "" (parallel to the other main level pages, not their parent); it cannot have children, and renaming its slug away leaves no front page ("/" redirects to the first nav item).Node.contentis the Markdown page, or None for a pure category label whose URL renders a placeholder page (while nav links to it point at its first child); every label's title and slug are editable. Siblings order by the fractionalNode.orderkey: a moved item gets a fresh key relative to its new siblings, all others keep theirs.resolve/find_slotwalk the tree by path; moves are slot detach/attach carrying the whole subtree. Legacy flatData.pages(pre-tree databases) migrates intomenuon startup. The app owns theDataobject; reads are plain attribute access, writes inkanta.transaction(...).Data.filesis a content-addressed store (blake3[:12] + extension) mapping file names to bytes, served at/_f/{name}with immutable caching; pages reference files by absolute/_f/URLs so hierarchy moves never break them.Node.banneris a raw trusted HTML snippet for the header banner (img, styled div, canvas+script...); empty inherits from the node's ancestors (front page last). It is rendered AFTER the banner design's artwork, so author code (e.g. a<style>override) always wins over the design's own styles.Node.banner_designpicks a banner design: a theme folder name whosebanner.cssstyles it and whosebanner.html(arbitrary markup: canvas + style + script) orbanner.svgsupplies the inline artwork (wrapped indiv[data-design]); "" = explicitly no design, None = inherit (nearest ancestor, front page last, then the active theme's own design if it ships banner.css/banner.svg/banner.html). The design's banner.css is linked in<head>(idpagerite-banner) between the theme and the custom CSS.Data.versionis bumped on every write and embedded in page ETags so nav-affecting changes invalidate caches.Data.brandis the site name (header link +<title>suffix), editable in the site editor via/_api/settings; empty = no header link and no<title>suffix.Data.brand_htmlis raw trusted HTML replacing the brand link entirely (rendered in a#branddiv on top of the banner, next to the nav) — site-wide, not per-page like banners; edited in the site editor with image/video upload intoData.files.Data.themeis the active theme name (empty = none/base only); themes are folders inpagerite/themes/{name}containingtheme.cssand/orbanner.css(+banner.svgartwork and any extra assets the CSS references, like summer'sgrass.svg), served by the backend at/_themes/{name}/...— read from disk per request (etag by mtime), never built, so on-disk edits show on the next page load even in prod. The theme selector and banner-design selector enumerate these folders viaGET /_api/settings.Data.custom_cssis raw trusted CSS injected inline in every page<head>(idpagerite-user) and swapped during fetch-navigation; editable in the site editor. Font picks (heading/body/brand) in the site editor are stored as plain:rootrows incustom_css(--font-body: var(--font-source-sans);format — parsed out and rewritten on change, the:rootblock added/removed as needed), referencing the per-family variables (--font-source-sansetc.) from pagerite.css; the base stylesheet's--font-branddefaults tovar(--font-heading).Data.faviconnames a file in the content-addressedfilesstore, uploaded/cleared in the site editor viaPUT/DELETE /_api/settings/favicon; when set it is linked as<link rel="icon">on every page, otherwise browsers fall back to the build's/favicon.icoby convention.markdown.py— markdown-it-py renderer (html passthrough + attrs, footnote, deflist, tasklists, admon, gfm_autolink, sub/superscript plugins; typographer + breaks on). Custom image rule: relative srcs resolve against the page path; an image standing alone in its paragraph becomes a figure (captioned when titled), while inline-with-text images and rawHTML stay plain. A
{dates}line expands to the article's published/updated dateline (p.dateline, fromNode.created/modified; left literal in previews of unsaved pages).views.py— the shared page layout as an html5taggerTemplatewith placeholders (Title,Brand,Banner,Nav,Sidebar,Main), nav rendering straight from theData.menutree (siblings sorted byNode.order; nav links to content-less labels point at their first child viafirst_leaf, the first published descendant with content), and page/404 rendering. If the markdown contains its own h1, the page title is NOT rendered as an additional h1 (it still supplies
- Server run by CLI entry point