Manual
Almnck.
Price: 50ⓐ

Site Production

The Almanack site is managed by Django, but the production version is static content, generated by django-distill. Smooth navigation between pages is handled by the browser’s native cross-document View Transitions API — one CSS rule (@view-transition { navigation: auto }) opts in; the browser handles fetch, snapshot, and crossfade.

This pure-static model allows us to host the site using IPFS as well as over HTTPS. It also allows us to pursue a local-first model, as the site can be passively loaded and aggressively cached in the background.

Layout Lifecycle

The sidenotes/margin-box layout is managed by sidenotes.js, which exposes an explicit lifecycle through state transitions and custom events.

State Machine

IDLE → INITIALIZING → READY ⇄ REFLOW_PENDING
                            → DESTROYING → DESTROYED → IDLE
  • IDLE: No layout active (page load, or after destroy).
  • INITIALIZING: Collecting sidenotes, margin boxes, loading pinned fragments, doing initial positioning.
  • READY: Layout positioned and visible. Sidenotes.whenReady() resolves here.
  • REFLOW_PENDING: A reposition has been scheduled (via invalidate()). Coalesced into a single RAF.
  • DESTROYING: Cleanup in progress (removing listeners, returning static boxes to their parents). Currently unreached in production — navigation loads a fresh document, so the old layout simply dies with the page. State retained for legacy callers and potential future use.
  • DESTROYED: Clean slate.

Lifecycle Events

All dispatched on window:

  • almanack:layout-init-start — Init cycle begins. Detail: { cycleId }.
  • almanack:layout-cycle — Content collected and first positioning done.
  • almanack:layout-ready — Layout visible and stable.
  • almanack:layout-destroyed — Cleanup complete, DOM reset.

Using Sidenotes.whenReady()

For code that needs the layout to be positioned before acting:

Sidenotes.whenReady().then(() => {
  // Layout is READY — safe to query positioned elements
});

If the layout is already READY, the promise resolves immediately.

Margin Boxes

Margin boxes can be:

  • Inline: <div class="margin-box"> inside .maintext, placed near their document position.
  • Injected: Declared in <template id="injected-margin-boxes">, cloned and positioned during init.
  • Masthead: Boxes with placement: masthead are extracted from the <template> and placed in #masthead-identity before margin layout begins. Works on all viewports including mobile. The identity widget uses this placement.
  • Dynamic: Created at runtime via Sidenotes.injectMarginBox().

Placement is controlled by data-margin tokens (order-independent): - Vertical: top, bottom, near (default for inline) - Horizontal: left, right - Priority: high, low (default: normal)

Example: data-margin="left-top-high" places the box at the top of the left margin with high priority (positioned before normal boxes).

Navigation between pages uses cross-document View Transitions. Every navigation loads a fresh document, so every page runs the full INITIALIZING → READY cycle from scratch. No swap-boundary reconciliation, no teardown/re-init choreography.

Browsers without cross-document View Transition support (Firefox as of early 2026) get plain navigation — same behaviour, no transition animation. Article-specific boxes naturally update because the whole page is replaced; masthead chrome is identical across pages and so appears continuous across the crossfade.

Responsive Layout Modes

The site has three layout modes, determined by viewport width and input type. A single CSS breakpoint at 700px (mirrored in sidenotes.js as CONFIG.minViewportWidth) governs the transition between them.

Broadsheet (> 700px)

The primary layout: a three-column CSS grid with the article in the centre and margin notes on each side. Body font scales proportionally via clamp(1rem, 2.1vw, 1.3rem) — shrinking gracefully as the viewport narrows, then freezing at the 1.3rem ceiling above ~990px. Grid minimums are in em so they track the font size; margin font is 0.8em of the body (80% ratio).

┌──────────┬────────────────────┬──────────┐
│  margin  │   article centre   │  margin  │
│  (left)  │                    │  (right) │
└──────────┴────────────────────┴──────────┘

Pocket (≤ 700px, touch)

For narrow touch devices with JS enabled. All three columns render at 90vw with scroll-snap, so the reader swipes horizontally between them. A 5vw peek on each side hints at adjacent content. Footnotes appear inline in the centre column.

         ◄ swipe ►
┌─────┬──────────┬─────┐
│peek │  visible │peek │
│     │  column  │     │
└─────┴──────────┴─────┘

Fallback (≤ 700px, no JS or non-touch)

A single centred column with margins hidden and footnotes displayed at the bottom. This is a degraded mode — the goal is to get out of it as quickly as possible (i.e. the 700px threshold is set low). Body font resets to 1.2rem for comfortable reading. Figures from footnotes are constrained to 33% width since they were designed for margin-column proportions.

┌────────────────────┐
│   article centre   │
│                    │
│   ── footnotes ──  │
└────────────────────┘

Scaling mechanism

The proportional scaling system uses CSS clamp() with em-based grid minimums so the entire layout adapts to font size changes without breakpoint drift. For full details, invariant test results, and tuning parameters, see Proportional Scaling Results.

Justified Text

Body prose in the main reading column is justified with justif, Lyall Cooper’s small library that runs the Knuth–Plass line-breaking algorithm — the one TeX uses — over whole paragraphs, rather than the browser’s greedy line-at-a-time text-align: justify. It adds en-US hyphenation, optical margins, and hanging punctuation, giving even spacing without rivers of whitespace. Our thanks to Lyall both for the library and for fixing the word-spacing bug we hit during adoption.

justif is vendored and self-hosted (no CDN) under assets/js/vendor/justif-0.6.4/, and loads as a render-blocking ES module (assets/js/justif-init.js, <script type="module" blocking="render">) so the text paints already justified. It runs unconditionally on load — there is no reader-facing on/off control.

It manages only main-column body prose. Two things are deliberately left on the browser’s native justification:

  • The drop-cap opening paragraph. justif’s own drop-cap support only understands a floated CSS ::first-letter; Almanack’s drop cap is a floated illuminated image, which justif declines to manage.
  • Margin and sidenote prose. justif pins a managed paragraph’s intrinsic width, which would break the shrink-to-fit margin columns.

Footnote reference brackets ([N]) are CSS-generated content, invisible to justif’s width model, so justif-init.js realizes them as real text nodes before justifying — otherwise a footnote-bearing line can mis-break.

For the evaluation that led to adopting justif — including the upstream bug we found and its fix — and the remaining tradeoffs (a load-time flash on Safari and older Firefox, smaller mobile footnote tap targets, and a per-navigation line-breaking cost), see Justif: TeX-Style Justification.

User Authentication

For authentication purposes, we associate public keys with each user account and only support authentication systems that allow us to only store public keys. This is so we don’t have to faff around protecting passwords, and also to walk our walk.