Eating our own cooking
A language for web applications should run a web application, so the site you are reading is one. It is a single Tessera program, handle(request) -> response, compiled to a shared library and loaded straight into nginx by the Tessera nginx module.
The text of every page, the page structure and the navigation are rows in a SQLite database. When the database is empty, the program fills it with the initial content of the site, so a fresh container serves a complete site on its first request.
What happens on a request
nginx accepts the request
The Tessera module hands the method, path, headers and body to the program.
The program opens the database
It talks to SQLite through the
dbeffect. On first use it creates the tables and seeds the pages.The page is built
The program reads the page and its blocks and renders HTML. All text is escaped, so content cannot inject markup.
The visit is counted
A page view is stored with an anonymous visitor id that changes every day.
The response is sent
With a strict content security policy, and with framing forbidden.
A trimmed excerpt of the router
fn handle(request: http.Request) -> http.Response uses db, env, log, random, time {
if request.path == "/healthz" {
return http.text(200, "ok\n")
}
if starts_with(request.path, "/admin") {
return admin.respond(request)
}
let connection = store.open() else return unavailable()
let site = store.load_settings(connection)
let current = match store.find_page(connection, slug_of(request.path)) {
.Some(found) => found
.None => return missing(connection, site, request)
}
remember(connection, site, request, 200)
let items = store.page_blocks(connection, current.slug)
http.html(200, view.document(site, store.navigation(connection), current, items))
}Statistics, without tracking
The site counts page views, so we can see which pages are read and where visitors come from. It sets no cookies and never stores an IP address. A visitor is a hash of a salt that is private to the installation, the day, the address and the browser. It cannot be reversed, and it changes every day, so visitors cannot be followed over time. Of a referrer only the host name is kept.
The statistics are shown on a password-protected admin page. Its user name and password come from environment variables of the container.
Run it yourself
The site is open source and runs in Docker with one compose file. The database lives in a folder you mount, so it survives restarts and upgrades. See the website repository.