Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches: [main]
pull_request:
# The site's content partly lives in CodeForFire/lagebuch. An automatic
# The site's content partly lives in CodeForFire/lagebuch and
# CodeForFire/helfer. An automatic
# cross-repo trigger would need a token with write access to this repo, so
# instead the site rebuilds nightly and on demand.
schedule:
Expand Down Expand Up @@ -36,6 +37,15 @@ jobs:
sparse-checkout: docs
persist-credentials: false

# docs/ from the FwAssist repo: the launcher icon and the screenshots.
- name: Check out CodeForFire/helfer (docs only)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: CodeForFire/helfer
path: .helfer
sparse-checkout: docs
persist-credentials: false

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
Expand Down
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ dist/
# Dependencies
node_modules/

# Content synced from CodeForFire/lagebuch by scripts/sync-docs.mjs.
# docs/ over there is the single source of truth; nothing here is hand-edited.
src/content/docs/datenschutz.md
# Content synced from CodeForFire/lagebuch and CodeForFire/helfer by
# scripts/sync-docs.mjs. docs/ over there is the single source of truth;
# nothing here is hand-edited.
src/content/docs/lagebuch/datenschutz.md
src/assets/lagebuch-logo.png
src/assets/screenshots/
src/assets/fwassist-icon.png
src/assets/fwassist/
public/bilder/

# CI checkout of the lagebuch repo
# CI checkouts of the app repos
.lagebuch/
.helfer/

# Environment
.env
Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# codeforfire.github.io

The website for [Lagebuch](https://github.com/CodeForFire/lagebuch) — offline
incident documentation for fire brigades. Built with
The CodeForFire website, home of both apps:
[Lagebuch](https://github.com/CodeForFire/lagebuch) (offline incident
documentation for the command vehicle, at `/lagebuch/`) and
[FwAssist](https://github.com/CodeForFire/helfer) (small offline helpers for
the phone, at `/fwassist/`). The landing page at `/` presents both equally.
Built with
[Astro Starlight](https://starlight.astro.build/), deployed to GitHub Pages at
**<https://codeforfire.github.io/>**.

Expand All @@ -12,14 +16,19 @@ repository.
## Where the content comes from

Most pages are written here, in `src/content/docs/`. Some content is owned by
the app repository and copied in at build time by `scripts/sync-docs.mjs`:
the app repositories and copied in at build time by `scripts/sync-docs.mjs`:

| On this site | Source in `CodeForFire/lagebuch` |
| On this site | Source |
|---|---|
| `datenschutz` | `docs/datenschutz-und-sicherheit.md` |
| logo, favicon, og:image | `docs/logo/` |
| demo animation | `docs/demo/einsatz-flow.gif` |
| screenshots on `rundgang` | `docs/screenshots/` |
| `lagebuch/datenschutz` | `CodeForFire/lagebuch` `docs/datenschutz-und-sicherheit.md` |
| Lagebuch logo, favicon, og:image | `CodeForFire/lagebuch` `docs/logo/` |
| demo animation | `CodeForFire/lagebuch` `docs/demo/einsatz-flow.gif` |
| screenshots on `lagebuch/rundgang` | `CodeForFire/lagebuch` `docs/screenshots/` |
| FwAssist icon | `CodeForFire/helfer` `docs/play/icon-512.png` |
| screenshots on `fwassist` | `CodeForFire/helfer` `docs/screenshots/` |

Lagebuch used to live at the root; `astro.config.mjs` redirects the old
addresses (`/download/`, `/rundgang/`, …) to `/lagebuch/…`.

The hotspot positions on `rundgang` (`src/data/rundgang.ts`) are percentages
of the 1920×1032 frame `make screenshots` renders. The build fails if a
Expand All @@ -28,19 +37,20 @@ not part of the tour yet. After a visual change in the app, re-check the
positions with `npm run dev`.

Everything the script writes is gitignored — never edit those files here, edit
them in the app repository. The script fails the build if a source file has
them in the app repositories. The script fails the build if a source file has
moved, rather than quietly dropping a page.

Because an automatic cross-repo trigger would need a token with write access to
this repository, the site rebuilds **nightly** (and on demand via *Actions →
Pages → Run workflow*). A change to the Datenschutz page or a fresh
`make screenshots` therefore appears here within a day.
`make screenshots` in either app therefore appears here within a day.

## Developing

Needs Node 22.19 or newer (see `.nvmrc`) and a checkout of
`CodeForFire/lagebuch`. The sync script looks for it in `$LAGEBUCH_PATH`, then
`.lagebuch/`, `../lagebuch` and `../../lagebuch`.
Needs Node 22.19 or newer (see `.nvmrc`) and checkouts of
`CodeForFire/lagebuch` and `CodeForFire/helfer`. The sync script looks for
each in `$LAGEBUCH_PATH` / `$HELFER_PATH`, then `.lagebuch/` / `.helfer/`,
`../<name>` and `../../<name>`.

```bash
npm install
Expand Down
68 changes: 45 additions & 23 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,77 @@ import starlight from '@astrojs/starlight'
// custom domain arrives, change `site` and add a CNAME file — nothing else.
const site = 'https://codeforfire.github.io'

const REPO = 'https://github.com/CodeForFire/lagebuch'
const ORG = 'https://github.com/CodeForFire'
const LAGEBUCH = `${ORG}/lagebuch`
const HELFER = `${ORG}/helfer`

/** Developer-facing and English: linked, never copied. */
const github = (items) => ({
label: 'Auf GitHub',
collapsed: true,
items: items.map(([label, link]) => ({ label, link, attrs: { target: '_blank' } })),
})

export default defineConfig({
site,
// Lagebuch used to live at the root. Releases, the app's README and people's
// bookmarks still point at the old addresses, so keep them working.
redirects: {
'/download/': '/lagebuch/download/',
'/probefahrt/': '/lagebuch/probefahrt/',
'/rundgang/': '/lagebuch/rundgang/',
'/vergleich/': '/lagebuch/vergleich/',
'/datenschutz/': '/lagebuch/datenschutz/',
},
integrations: [
starlight({
title: 'Lagebuch',
title: 'CodeForFire',
description:
'Das digitale Einsatztagebuch für den Einsatzleitwagen — offline, ohne Cloud, ohne Abo.',
'Offline-Werkzeuge für die Feuerwehr — Lagebuch für den ELW, FwAssist für die Hosentasche. Open Source, ohne Cloud, ohne Abo.',
// Monolingual German: Starlight ships German UI strings, so search,
// navigation and "Auf dieser Seite" need no further configuration.
locales: {
root: { label: 'Deutsch', lang: 'de' },
},
logo: {
src: './src/assets/lagebuch-logo.png',
alt: 'Lagebuch',
replacesTitle: false,
},
favicon: '/bilder/favicon.png',
head: [
{ tag: 'meta', attrs: { property: 'og:image', content: `${site}/bilder/social-preview.png` } },
{ tag: 'meta', attrs: { property: 'og:image:alt', content: 'Lagebuch — Einsatzdokumentation für den ELW' } },
{ tag: 'meta', attrs: { name: 'twitter:card', content: 'summary_large_image' } },
],
customCss: ['./src/styles/custom.css'],
social: [{ icon: 'github', label: 'GitHub', href: REPO }],
social: [{ icon: 'github', label: 'GitHub', href: ORG }],
sidebar: [
{
label: 'Lagebuch',
items: [
{ label: 'Start', slug: '' },
{ label: 'Probefahrt in 5 Minuten', slug: 'probefahrt' },
{ label: 'Rundgang durch einen Einsatz', slug: 'rundgang' },
{ label: 'Herunterladen und installieren', slug: 'download' },
{ label: 'Lagebuch im Vergleich', slug: 'vergleich' },
{ label: 'Datenschutz und Sicherheit', slug: 'datenschutz' },
{ label: 'Start', slug: 'lagebuch' },
{ label: 'Probefahrt in 5 Minuten', slug: 'lagebuch/probefahrt' },
{ label: 'Rundgang durch einen Einsatz', slug: 'lagebuch/rundgang' },
{ label: 'Herunterladen und installieren', slug: 'lagebuch/download' },
{ label: 'Lagebuch im Vergleich', slug: 'lagebuch/vergleich' },
{ label: 'Datenschutz und Sicherheit', slug: 'lagebuch/datenschutz' },
github([
['Quellcode', LAGEBUCH],
['Releases', `${LAGEBUCH}/releases`],
['Roadmap', `${LAGEBUCH}/blob/main/ROADMAP.md`],
['Changelog', `${LAGEBUCH}/blob/main/CHANGELOG.md`],
['Fragen & Antworten', `${LAGEBUCH}/discussions`],
['Mitmachen', `${LAGEBUCH}/blob/main/CONTRIBUTING.md`],
]),
],
},
{
// Developer-facing and English: linked, never copied.
label: 'Auf GitHub',
label: 'FwAssist',
items: [
{ label: 'Quellcode', link: REPO, attrs: { target: '_blank' } },
{ label: 'Releases', link: `${REPO}/releases`, attrs: { target: '_blank' } },
{ label: 'Roadmap', link: `${REPO}/blob/main/ROADMAP.md`, attrs: { target: '_blank' } },
{ label: 'Changelog', link: `${REPO}/blob/main/CHANGELOG.md`, attrs: { target: '_blank' } },
{ label: 'Fragen & Antworten', link: `${REPO}/discussions`, attrs: { target: '_blank' } },
{ label: 'Mitmachen', link: `${REPO}/blob/main/CONTRIBUTING.md`, attrs: { target: '_blank' } },
{ label: 'Start', slug: 'fwassist' },
github([
['Quellcode', HELFER],
['Releases', `${HELFER}/releases`],
['Changelog', `${HELFER}/blob/main/CHANGELOG.md`],
['Ideen', `${HELFER}/discussions/categories/ideen`],
['Fragen & Antworten', `${HELFER}/discussions`],
]),
],
},
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"check": "astro check"
},
"license": "MIT",
"description": "Website für Lagebuch — die Einsatzdokumentation von CodeForFire",
"description": "Website von CodeForFire — Lagebuch und FwAssist",
"dependencies": {
"@astrojs/starlight": "^0.42.8",
"astro": "^7.4.5",
Expand Down
106 changes: 68 additions & 38 deletions scripts/sync-docs.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copies the user-facing content that lives in CodeForFire/lagebuch into this
// site. docs/ over there is the single source of truth: nothing this script
// writes is hand-edited here, and every target is gitignored.
// Copies the user-facing content that lives in the app repositories
// (CodeForFire/lagebuch and CodeForFire/helfer) into this site. docs/ over
// there is the single source of truth: nothing this script writes is
// hand-edited here, and every target is gitignored.
//
// Run it before `astro build` / `astro dev` (npm run sync).

Expand All @@ -14,22 +15,25 @@ const siteRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')

const BLOB = 'https://github.com/CodeForFire/lagebuch/blob/main'

/** Where a checkout of CodeForFire/lagebuch might be, most specific first. */
const CANDIDATES = [
process.env.LAGEBUCH_PATH,
join(siteRoot, '.lagebuch'), // the CI checkout
join(siteRoot, '..', 'lagebuch'),
join(siteRoot, '..', '..', 'lagebuch'), // the local dev layout
].filter(Boolean)
/** Where a checkout of CodeForFire/<name> might be, most specific first. */
function candidates(name, envVar) {
return [
process.env[envVar],
join(siteRoot, `.${name}`), // the CI checkout
join(siteRoot, '..', name),
join(siteRoot, '..', '..', name), // the local dev layout
].filter(Boolean)
}

function findLagebuch() {
for (const candidate of CANDIDATES) {
function findRepo(name, envVar) {
const looked = candidates(name, envVar)
for (const candidate of looked) {
if (existsSync(join(candidate, 'docs'))) return resolve(candidate)
}
throw new Error(
'No checkout of CodeForFire/lagebuch found. Looked for a docs/ directory in:\n' +
CANDIDATES.map((c) => ` - ${c}`).join('\n') +
'\n\nClone it next to this repo, or set LAGEBUCH_PATH.',
`No checkout of CodeForFire/${name} found. Looked for a docs/ directory in:\n` +
looked.map((c) => ` - ${c}`).join('\n') +
`\n\nClone it next to this repo, or set ${envVar}.`,
)
}

Expand All @@ -38,17 +42,32 @@ async function required(path, why) {
try {
return await readFile(path, 'utf8')
} catch {
throw new Error(`Missing in the lagebuch checkout: ${path}\n (needed for ${why})`)
throw new Error(`Missing in the app checkout: ${path}\n (needed for ${why})`)
}
}

/** Copy every PNG in `from` into a freshly emptied `to`; fail if there are none. */
async function copyScreenshots(from, to) {
let shots
try {
shots = (await readdir(from)).filter((f) => f.endsWith('.png'))
} catch {
throw new Error(`Missing in the app checkout: ${from}\n (needed for the screenshots)`)
}
if (shots.length === 0) throw new Error(`No screenshots found in ${from}`)
await rm(to, { recursive: true, force: true })
await mkdir(to, { recursive: true })
for (const shot of shots) await cp(join(from, shot), join(to, shot))
return shots.map((shot) => join(to, shot))
}

/**
* docs/datenschutz-und-sicherheit.md is written for github.com, so its links
* are repo-relative. Point them at github.com — except the download anchor,
* which has a better home on this site.
*/
const LINK_REWRITES = [
['](../README.md#downloads-prüfen)', '](/download/#downloads-prüfen)'],
['](../README.md#downloads-prüfen)', '](/lagebuch/download/#downloads-prüfen)'],
['](master-data.md)', `](${BLOB}/docs/master-data.md)`],
['](../ROADMAP.md)', `](${BLOB}/ROADMAP.md)`],
['](../SECURITY.md)', `](${BLOB}/SECURITY.md)`],
Expand Down Expand Up @@ -76,7 +95,7 @@ async function syncDatenschutz(lagebuch) {
body = body.replaceAll(from, to)
}

const target = join(siteRoot, 'src', 'content', 'docs', 'datenschutz.md')
const target = join(siteRoot, 'src', 'content', 'docs', 'lagebuch', 'datenschutz.md')
await writeFile(
target,
frontmatter({
Expand All @@ -90,7 +109,7 @@ async function syncDatenschutz(lagebuch) {
return target
}

async function syncImages(lagebuch) {
async function syncLagebuchImages(lagebuch) {
const written = []

const logoSource = join(lagebuch, 'docs', 'logo', 'lagebuch-logo.png')
Expand All @@ -105,27 +124,18 @@ async function syncImages(lagebuch) {
await mkdir(bilder, { recursive: true })

const gifSource = join(lagebuch, 'docs', 'demo', 'einsatz-flow.gif')
await required(gifSource, 'the demo animation on the landing page')
await required(gifSource, 'the demo animation on the Lagebuch start page')
await cp(gifSource, join(bilder, 'einsatz-flow.gif'))
written.push(join(bilder, 'einsatz-flow.gif'))

const shotsDir = join(lagebuch, 'docs', 'screenshots')
let shots
try {
shots = (await readdir(shotsDir)).filter((f) => f.endsWith('.png'))
} catch {
throw new Error(`Missing in the lagebuch checkout: ${shotsDir}\n (needed for the screenshots)`)
}
if (shots.length === 0) throw new Error(`No screenshots found in ${shotsDir}`)
// Into src/assets, not public/: the Rundgang page renders them through
// astro:assets, which needs them as imports to emit WebP and srcsets.
const screenshots = join(siteRoot, 'src', 'assets', 'screenshots')
await rm(screenshots, { recursive: true, force: true })
await mkdir(screenshots, { recursive: true })
for (const shot of shots) {
await cp(join(shotsDir, shot), join(screenshots, shot))
written.push(join(screenshots, shot))
}
written.push(
...(await copyScreenshots(
join(lagebuch, 'docs', 'screenshots'),
join(siteRoot, 'src', 'assets', 'screenshots'),
)),
)

await cp(logoSource, join(bilder, 'favicon.png'))
written.push(join(bilder, 'favicon.png'))
Expand All @@ -149,7 +159,27 @@ function describe(repo) {
}
}

const lagebuch = findLagebuch()
console.log(`sync-docs: reading from ${lagebuch} @ ${describe(lagebuch)}`)
const written = [await syncDatenschutz(lagebuch), ...(await syncImages(lagebuch))]
/** The FwAssist start page: the launcher icon and the phone screenshots. */
async function syncHelfer(helfer) {
const iconSource = join(helfer, 'docs', 'play', 'icon-512.png')
await required(iconSource, 'the FwAssist hero icon')
const iconTarget = join(siteRoot, 'src', 'assets', 'fwassist-icon.png')
await cp(iconSource, iconTarget)

const shots = await copyScreenshots(
join(helfer, 'docs', 'screenshots'),
join(siteRoot, 'src', 'assets', 'fwassist', 'screenshots'),
)
return [iconTarget, ...shots]
}

const lagebuch = findRepo('lagebuch', 'LAGEBUCH_PATH')
console.log(`sync-docs: reading Lagebuch from ${lagebuch} @ ${describe(lagebuch)}`)
const helfer = findRepo('helfer', 'HELFER_PATH')
console.log(`sync-docs: reading FwAssist from ${helfer} @ ${describe(helfer)}`)
const written = [
await syncDatenschutz(lagebuch),
...(await syncLagebuchImages(lagebuch)),
...(await syncHelfer(helfer)),
]
console.log(`sync-docs: wrote ${written.length} files`)
Loading
Loading