PureWiki handles user requests for content (the public wiki) using an efficient routing and rendering engine. This guide explains how the system translates a URL into a fully realized HTML page.
The Router (index.php)
Every request passes through index.php. It normalizes the requested URL and determines if the path points to /setup, a dashboard route, or a regular wiki page.
purewiki/frontend/renderer.php).Before a public page is rendered, the router handles these cases in order:
- Setup: Without a configuration, the Setup Wizard is shown.
- Dashboard: Routes below
/dashboardrequire a login and a sufficient role, then load a controller frompurewiki/admin/. - Language prefix: With i18n enabled, a language prefix selects the language version. The prefix of the default language is redirected (301) to the clean URL.
- Preview:
?preview=1renders the draft for logged-in users and skips the cache. - Private pages and redirects: Visitors of a private page are sent to the start page. Pages with an enabled redirect send visitors to the target URL.
- Cache: If caching is enabled, visitors receive the stored HTML file.
The Rendering Engine
The renderPage() function is the core of PureWiki generation. It handles:
- Data Extraction: Parses the
page.jsonto retrieve metadata and blocks. - Content Parsing: Blocks are converted into semantic HTML via
purewiki/frontend/parser.php. - Theme Injection: The aggregated data and HTML content are passed to the active theme template. The color overrides of the Theme Colors setting are added to the head.
- Placeholder Replacement: Replaces specialized placeholders (e.g.,
{{ content }},{{ assets_head }}) within the theme's output.
The Caching Mechanism (/cache)
To deliver lightning-fast response times, PureWiki uses a robust static HTML caching system.
Sitemap (sitemap.xml)
PureWiki dynamically generates a sitemap.xml to aid search engine indexing. It is served from the wiki root and follows the sitemaps.org standard.
getCachedPagesTree()) and automatically excludes private pages. Priority is dynamically calculated based on page depth.On-Demand Assets
Libraries are only loaded on pages that need them. While parsing, the blocks request Prism.js (code blocks), KaTeX (math) and Iconify (icons) through the AssetManager. Extensions can add their own files, see Extension Development.