# Architecture Overview How the intotheeast site hangs together. --- ## Stack | Layer | Technology | Notes | |---|---|---| | CMS | Grav 2.0.7 stable | Flat-file PHP CMS; no database. Server upgrades in place via `bin/gpm self-upgrade` | | Admin | Admin2 v2.0.12 | Plugin slug: `admin2` (not `admin`) | | GPM channel | `stable` | Authoritative in `user/config/system.yaml` → `gpm.releases`; `GRAV_CHANNEL=production` in compose is cosmetic | | Container | Docker (`getgrav/grav` base + custom `Dockerfile`) | Grav 2.0 baked in at build time | | PHP session | `session.save_path = /tmp` | Set in `php/php-local.ini` | | Dev URL | http://localhost:8081 | Mapped from container port 80 | | Maps | MapLibre GL JS | Replaced Leaflet. One shared *display* path (`MapUtils.initEntryMap`) on trip + home, plus one sanctioned *editor* (`js/src/location-map.js`) for the `/post` pin picker | | Basemap | CartoDB dark-matter | Style URL single-sourced as `MAP_STYLE` in `js/src/map-style.js`, imported by both map paths so they cannot drift | | GPX rendering | toGeoJSON (bundled in `js/map.js`) | Parses GPX → GeoJSON route layers client-side; no CDN | --- ## Plugin roles The posting pipeline is a chain of three plugins: ``` Browser POST /post │ ├─ Grav Form plugin (built-in) │ └─ validates required fields; handles file uploads │ ├─ cache-on-save (custom) — onFormValidationProcessed, runs BEFORE the write │ ├─ setData('parent', …) ← derived from site.active_trip │ └─ sets pageconfig.overwrite_mode: edit when the hidden edit_path is filled, │ false when empty (create a fresh dated folder) │ ├─ add-page-by-form (third-party, patched — see deploy/patches/) │ └─ reads post-form.md config: │ ├─ pageconfig.slug_field → slug from date + title │ └─ pagefrontmatter → template: entry │ └─ writes entry.md to user/pages/01.trips//01.dailies/.entry/ │ └─ moves uploaded photos into the page folder │ └─ cache-on-save (again, post-write) └─ calls $grav['cache']->deleteAll() on every new-entry form submission └─ ensures entries appear in feed immediately in both dev and prod mode ``` Other notable plugins: | Plugin | Role | |---|---| | `login` | Auth for /post and /gpx-manager | | `api` (Grav API v1) | Used by /gpx-manager to list/upload/delete GPX files | | `admin2` | Admin panel at /admin | | `story-blocks` (custom) | Storytelling shortcode blocks for long-form stories (needs `shortcode-core`) | | `entry-actions` (custom) | Owner-only, active-trip-scoped actions via the Grav API. Three routes: `DELETE /entry/{slug}`, `POST /entry/{slug}/photos/order`, `POST /trip/{slug}/publish`. Exists because stock `DELETE /api/v1/pages` checks only write-permission (no trip scoping) and cannot renumber media to the `photo-NN` cover order | ### Plugin management model Three categories, by how each plugin is installed and maintained: 1. **GPM-managed** (`plugins.txt` → `make install-plugins`): the marketplace plugins, including `login`, `form`, `admin2`, `api`, `flex-objects`, shortcodes, etc. As of the 2.0.4 upgrade, `admin2`/`api`/`flex-objects` moved into this category — they were previously hand-extracted from the core bundle. Update with `bin/gpm update` (`make remote-update-plugins-` on servers). 2. **Custom, in-repo** (`user/plugins/` allowlisted in `user/.gitignore`): `cache-on-save`, `story-blocks`, `entry-actions`. Versioned in the user repo. 3. **Remote-only**: `git-sync` — installed and configured only on servers, **never** in `plugins.txt`, and disabled during upgrades. --- ## Asset pipeline `make build-assets` runs the theme's `npm run build` (esbuild) in a throwaway `node:20-alpine` container, as the host uid so outputs land in the tracked theme tree owned by you rather than root. | Source | → Output | |---|---| | `js/src/main.js` | `js/main.js` + `css-compiled/main.css` + `fonts/` (font files via the `woff2` loader) | | `js/src/map.js` | `js/map.js` + `css-compiled/map.css` — bundles `maplibre-gl`, `@mapbox/togeojson`, and `js/maplibre-utils.js` | | `js/src/feed-actions.js` | `js/feed-actions.js` | | `js/src/trip-publish.js` | `js/trip-publish.js` | | `js/src/post-form.js` | `js/post/` (ESM + code splitting) + `css-compiled/post-form.css` — also pulls in `location-map.js` and `map-style.js` | | `node_modules/maplibre-gl/dist/maplibre-gl.css` | `css-compiled/maplibre-gl.css` — built standalone so `location-map.js` can inject it on demand without a static import defeating its lazy load | | `scripts/gen-weather-icons.js` | `templates/partials/weather-icons.html.twig` (Lucide SVGs inlined into a Twig map) | The table lists esbuild **entry points**. Other files in `js/src/` (`api-utils.js`, `location-map.js`, `map-style.js`, `post-form.css`) are sources too — they are imported into a bundle rather than being built directly. **The trap:** `js/` holds both bundles *and* hand-authored sources. `js/maplibre-utils.js` (the `MapUtils` map engine, a plain IIFE imported by `js/src/map.js`) and `js/nav.js` are sources despite sitting beside the minified bundles. **The second trap:** `css/` is **not** the source of `css-compiled/`. `css/style.css` and `css/tokens.css` are hand-authored and served *directly* via `assets.addCss('theme://css/…')` in `partials/base.html.twig` — they are never compiled. `css-compiled/` is esbuild output from the CSS imports inside `js/src/*.js` (fontsource + PhotoSwipe → `main.css`; maplibre → `map.css`) plus the standalone maplibre build above. --- ## Template hierarchy All page templates extend `base.html.twig`: ``` templates/ ├─ default.html.twig ← extends base; generic page ├─ home.html.twig ← extends base; context-aware two-column layout ├─ trips.html.twig ← extends base; trip list (with the owner's publish toggle) ├─ trip.html.twig ← extends base; trip page with filter bar (All/Journal/Stories) ├─ entry.html.twig ← extends base; single journal entry (gallery, badges, map) ├─ story.html.twig ← extends base; single story (Ken Burns hero, shortcodes) ├─ post-form.html.twig ← extends base; the /post journal form ├─ gpx-manager.html.twig ← extends base; admin UI for GPX file management ├─ forms/ ← field overrides (e.g. forms/fields/datetime/datetime.html.twig) ├─ macros/ ← cover, cycling, date-range, stats └─ partials/ ← base.html.twig lives HERE, not at templates/ root ``` **`base.html.twig` is a partial** (`templates/partials/base.html.twig`), despite being the shell every page template extends. The standalone `dailies.html.twig`, `map.html.twig`, `stats.html.twig` and `stories.html.twig` view templates were **removed** in the 2026-07-04 standalone-page cleanup — the trip page (`trip.html.twig`) consolidated the feed, inline map, and inline stats. Site nav (in `partials/base.html.twig`) is deliberately minimal — **Home + Trips**, plus **New Post** when `grav.user.authenticated`. It does not link to trip sub-sections, because those standalone views no longer exist. Partials live in `templates/partials/` (plus macros in `templates/macros/`). Key partials: `base.html.twig` (site shell extended by all page templates), `entry-map.html.twig` (shared map column + `initEntryMap` call, used by trip + home), `trip-feed-col.html.twig` (feed column chrome, shared by trip + home), `home-predeparture.html.twig`, `entry-journal.html.twig` / `entry-story.html.twig` (feed cards), `trip-publish-toggle.html.twig`, and `weather-icons.html.twig`. ### Shared partial contracts Two partials are included by **both** `trip.html.twig` and the active branch of `home.html.twig`, via `{% include … with {…} only %}`. The `only` keyword means every value must be passed explicitly — the tables below are the contracts. The rules that govern them (single map path, required map globals, never hand-edit bundles) live in `CLAUDE.md`; these are the parameter details. #### `entry-map.html.twig` Renders the `.home-map-col` column (map div `#{{ map_id }}` + fullscreen button) and, when `entries` is non-empty, a thin `