Repo layout

Annotated map of the doc server crate (fds_doc_v2/). Each entry below is the canonical location for the behavior described in its line.

src/

  • src/main.rs — boots Tokio, calls routes::sitemap::spawn_writer() and backup::spawn_writer(), then APP.clone().run().await.
  • src/lib.rs — crate root; re-exports APP, content, routes, backup, zip, and the lang shim helpers (req_path, lang_for, current_prefix, prefix_breadcrumb, canonical_url_for).
  • src/content.rs — type dispatcher (render), HTML and JSON-LD escapers (html_escape, breadcrumb_html_escape, breadcrumb_jsonld), URL helpers (canonical_url, og_image_for), hreflang_alternates, pageprop_for, support_langs, and the lazy NAVBAR / FOOTER / SUPPORT_LANGS statics. Every render arm feeds pre-escaped strings to Akari.
  • src/content/ — per-type renderers and tree I/O:
    • board.rsrender_board_card, render_icon (falls back to crate::content::default_icon() from config.json).
    • list.rs — list-group-flush rendering, parse_slug_list.
    • board_group.rs, board_list.rs — grouped variants.
    • singlemd.rs, mdbook.rs — markdown-page types.
    • file.rs (FileContent) — uploaded-file pages.
    • link.rs — external-URL pages.
    • header.rsHeader struct (name, desc, icon) + write_into / from_value / fallback.
    • localization.rsLangDict (multi-lang string or per-lang dict).
    • fop.rs — filesystem helpers. fop::write_file_bytes prepends programfiles/content/ and is the canonical writer for uploads. combine_path, split_path, read_json_file, write_json_file, read_file, read_markdown_file, compile_markdown live here.
    • any.rs — fallback File impl for broken-ref nodes.
  • src/routes/view.rs — central ?view=... dispatch (edit / download / permissions); default branch renders the page.
  • src/routes/edit.rs — content editor. Multipart via req.files_or_default().await; sanitize_upload_filename blocks path traversal; FileContent::write_bytes must route through fop::write_file_bytes.
  • src/routes/download.rs?view=download. Honors Role::Read via guard::require.
  • src/routes/permissions.rs?view=permissions. Owner-gated; edits perms.json sibling to the resource.
  • src/routes/lang.rslang_for(req), req_path, url_for, current_prefix, prefix_breadcrumb, canonical_url_for. Single source of truth for prefix-aware URL building.
  • src/routes/lang_prefix.rs — runtime side of the generated per-language prefix endpoints.
  • src/routes/sitemap.rs — background sitemap writer; static CACHE: Lazy<RwLock<Arc<String>>> serves public requests from RAM.
  • src/routes/switch_lang.rs/op/switch_lang/<code> endpoint with open-redirect hardening.
  • src/backup.rs — periodic snapshot task; clean test-isolation pattern under #[cfg(test)] mod tests is worth copying when adding integration-style tests elsewhere.
  • src/zip.rs — zip helpers: archive_paths_to_file (used by backup) and archive_files_to_bytes (used by mdbook download).

build.rs

Code generator. Reads programfiles/op/support_lang.json and emits one prefix endpoint per non-default lang under /<lang>/<**path>. Each generated endpoint sets LangOverride and EffectivePath on req.params, strips the prefix, and dispatches into the shared handler chain.

templates/

  • templates/base/base.html — page skeleton. SEO block gated on -[ if canonical ]-; og:image further gated on -[ if og_image ]-.
  • templates/base/path.html — loops path, wraps the last item in <h1> via -[ if path_last ]-. SFX-served pages (login etc.) pass path only without path_last, so the loop stays backwards-compatible.

programfiles/

  • programfiles/content/ — content tree (boards, lists, ctx.json, markdown, files). Edited via ?view=edit or on disk.
  • programfiles/op/ — server config:
    • config.json — keys public_origin, default_icon, default_og_image, backup_interval_secs, backup_retain, backup_dir.
    • support_lang.json — language codes; drives build.rs.
    • navbar.json, footer.json — chrome translations per language.
    • robots.txt — static.
    • sitemap.xml — written by routes::sitemap.
  • programfiles/local_auth/ — user store; archived by the backup writer.
  • programfiles/backup/ — default backup destination (when backup_dir is unset).

Reference

  • LANG_AND_SEO_BEHAVIOR.md at repo root — exhaustive reference for URL routing, language resolution, pageprop_for, switch_lang, per-page SEO output, sitemap architecture, robots.txt, and known limitations. Linked here so deep dives have a single source of truth outside the source tree.