No description
  • Python 44.5%
  • JavaScript 21.5%
  • CSS 16.7%
  • HTML 14.6%
  • Shell 2.3%
  • Other 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
dsh 524f8bd037
All checks were successful
CI / test (push) Successful in 44s
Publish container image / publish (push) Successful in 1m30s
feat(wink): ship text-prefix JS model v2
2026-12-02 00:55:51 +00:00
.forgejo/workflows feat(site): add Caddy, Flask, Continuwuity and Resend to daily drivers 2026-11-27 19:35:53 +00:00
auth feat(auth): add set-password CLI 2026-11-28 16:30:41 +00:00
blog feat(blog): add admin draft preview and back link 2026-11-17 23:52:32 +00:00
deploy content(site): drop role label and link the onion service 2026-11-27 18:38:16 +00:00
migrations feat: add first-party stats and the deploy blueprint 2026-11-16 21:40:48 +00:00
pages feat(wink): ship text-prefix JS model v2 2026-12-02 00:55:51 +00:00
scripts feat: build bilingual portfolio site with Markdown blog and CMS 2026-10-22 17:57:31 +00:00
static feat(wink): ship text-prefix JS model v2 2026-12-02 00:55:51 +00:00
stats feat(blog): add admin image uploads and GitHub mirror links 2026-11-17 23:21:52 +00:00
templates/admin feat(blog): add admin image uploads and GitHub mirror links 2026-11-17 23:21:52 +00:00
tests feat(auth): add set-password CLI 2026-11-28 16:30:41 +00:00
.dockerignore chore: move private docs to agentic/web-frontend 2026-11-17 23:02:39 +00:00
.env.example content(site): drop role label and link the onion service 2026-11-27 18:38:16 +00:00
.gitignore chore: keep the input box in the private clone 2026-11-17 23:03:56 +00:00
.python-version chore: use uv-managed Python 3.14 on srvbtw 2026-11-07 22:24:44 +00:00
admin.py feat(blog): add admin draft preview and back link 2026-11-17 23:52:32 +00:00
AGENTS.md chore: keep the input box in the private clone 2026-11-17 23:03:56 +00:00
app.py feat(auth): add set-password CLI 2026-11-28 16:30:41 +00:00
config.py content(site): drop role label and link the onion service 2026-11-27 18:38:16 +00:00
docker-compose.yml fix(dev): run the container on the tailnet with pinned Python 2026-11-08 11:21:32 +00:00
docker-entrypoint.sh chore(ci): add Docker image, Compose and Forgejo workflows 2026-10-22 17:57:34 +00:00
Dockerfile fix(dev): run the container on the tailnet with pinned Python 2026-11-08 11:21:32 +00:00
extensions.py Initial commit 2026-10-22 16:49:19 +00:00
i18n.py feat(wink): ship text-prefix JS model v2 2026-12-02 00:55:51 +00:00
LICENSE chore: add Apache-2.0 license 2026-11-26 07:50:20 +00:00
markdown_render.py feat: build bilingual portfolio site with Markdown blog and CMS 2026-10-22 17:57:31 +00:00
pyproject.toml feat(wink): ship text-prefix JS model v2 2026-12-02 00:55:51 +00:00
README.md feat(auth): add set-password CLI 2026-11-28 16:30:41 +00:00
TASKS.md feat(projects): publish wink v0.1 2026-11-26 07:46:42 +00:00
uv.lock feat(wink): ship text-prefix JS model v2 2026-12-02 00:55:51 +00:00
wsgi.py chore(ci): add Docker image, Compose and Forgejo workflows 2026-10-22 17:57:34 +00:00

pvlb.dev — web-frontend

Personal portfolio and blog for pvlb.dev, built on a Flask + SQLAlchemy fork of Flango. The public site is a small, fast, server-rendered landing page; the blog is written in Markdown and edited through a private Flask-Admin CMS.

  • English is canonical at /, German lives under /de/.
  • Dark, terminal-flavoured design with self-hosted JetBrains Mono and an orange accent.
  • Markdown source is stored in SQLite; HTML is rendered server-side with markdown-it-py and highlighted with Pygments.
  • Admin-only post editor with EasyMDE, drafts, scheduling, image uploads and bilingual translation_key pairing.
  • Docker image, Compose file and Forgejo Actions for tests and image publishing.

Architecture and conventions live in the AGENTS.md map. The long-form topic files live in the private agentic/web-frontend repo, cloned as AGENTS.d/; a public checkout deliberately has no AGENTS.d/. Open work and deferred ideas live in TASKS.md. The house baseline for agents on this box is the DSH bootcamp.

Quick start

Requires uv and Python 3.14 on the host (the container currently uses the supported 3.13 base; pyproject.toml allows >=3.13). uv creates and owns .venv; do not install project packages globally.

uv sync
cp .env.example .env
uv run flask --app app db upgrade
uv run flask --app app create-admin --username admin   # prompts for a password
uv run flask --app app set-password --username admin   # rotate the password
uv run flask --app app run --debug

Open:

URL What it is
/ English landing page
/de/ German landing page
/projects/ English project index
/de/projekte/ German project index
/contact/ English contact page
/de/kontakt/ German contact page
/contact/phone/ English rotary phone game
/de/kontakt/telefon/ German rotary phone game
/blog/ English blog index
/de/blog/ German blog index
/blog/<slug> English post
/de/blog/<slug> German post
/admin Flask-Admin CMS (admin users only)
/admin/stats/ First-party visit statistics (admin users only)
/auth/login Session login for the CMS
/healthz JSON health check
/sitemap.xml Sitemap
/robots.txt Crawler rules

The phone game is a playful client-side gate, not privacy. Valid steps are stored as salted SHA-256 hashes and the full number is assembled only from the entered digits, so it is not plaintext in the JS. The QR is generated client-side from the vCard after a successful solve, but the 10^7 space is brute-forceable. It is noindexed, but a determined visitor can recover the number. Use a dedicated/alias number if that matters. The dial tones are local, shuffle-bagged OGG loops in static/audio/phone/ with a mute toggle on the page.

Visit statistics

The admin console has a read-only /admin/stats/ page: views, unique visitors per UTC day, a 14-day series, top pages, referrers and a separate crawler bucket. It is first-party and cookie-free:

  • ip_hash is HMAC(SECRET_KEY, "<utc-date>:<ip>"), so the raw IP is never stored and the same visitor has a different id tomorrow;
  • /static, /api, /auth, /admin, /healthz, robots.txt/sitemap.xml and non-200 responses are not counted; POSTs are not counted;
  • only browser / crawler / other is stored, never the full user agent;
  • STATS_ENABLED=0 stops recording; existing rows remain visible;
  • uv run flask --app app stats prune removes rows older than STATS_RETENTION_DAYS (default 90). Run it on a timer in production.

The visits table lives in the normal app database. This is site-owned analytics, not a third-party tracker, but it is still stored data — contact page copy must not claim otherwise.

Writing a post

  1. Log in at /auth/login and open /admin.
  2. Create a post under Posts:
    • lang selects English or German.
    • slug can be left empty; it is generated from the title (German umlauts are transliterated).
    • translation_key can be left empty; it defaults to the slug. Reuse the same key on the other language version to link the two.
    • Write the body in Markdown. Raw HTML is intentionally escaped.
    • published_at is a UTC date only; leave it empty when publishing to use “now”.
  3. Insert images with the editor's img toolbar button (upload) or url (remote image). Uploads are stored under instance/uploads/, served at /media/..., and only admins can upload.
  4. Set status to published. Drafts and future-dated posts return 404 in public views.
  5. To preview drafts from the public site, use show drafts in the header while logged in as an admin. A direct draft URL also works with ?preview=1.

Markdown supports CommonMark plus tables, strikethrough, footnotes, task lists, autolinked URLs and fenced code blocks with Pygments highlighting.

Bilingual content

  • English routes are unprefixed; German routes use the /de prefix. There is no Accept-Language redirect and no /en/ duplicate.
  • UI strings and landing copy live in i18n.py and pages/content.py.
  • Blog posts are one row per language. translation_key pairs a post with its counterpart; the detail page links to it, or shows a note if it is missing.
  • Auth/admin UI is English-only by design.

Configuration

Configuration is read from environment variables and .env via python-dotenv.

Variable Default Purpose
SECRET_KEY dev fallback Set a real secret in production.
DATABASE_URL sqlite:///main.db Relative SQLite paths resolve to instance/.
FLASK_DEBUG off Flask debug mode.
LOG_LEVEL INFO stdout and instance/app.log.
SITE_URL http://localhost:5000 Canonical base for SEO, sitemap, Open Graph.
SITE_NAME pvlb.dev Site name in branding and metadata.
SITE_OWNER Pavel Burda Name shown on the landing page and footer.
FORGEJO_URL explore repos URL Projects CTA.
SOURCE_URL repo URL Footer source link.
CONTACT_EMAIL empty Optional mailto link; .env.example suggests mail@pvlb.dev.
ONION_URL built-in pvlb.dev onion Optional Tor onion-service link used in the footer.
GITHUB_URL empty Optional GitHub link on the contact page.
MATRIX_DM_HANDLE @pvl:pvlb.dev Matrix DM handle.
MATRIX_DM_URL matrix.to link Matrix DM link.
MATRIX_CHAT_URL https://chat.pvlb.dev Cinny web client.
MATRIX_ROOM_URL #hi:pvlb.dev matrix.to Main chat room.
MATRIX_SPACE_URL #public:pvlb.dev matrix.to Public Matrix space.
MATRIX_ACCOUNT_URL https://matrix.org “get an account” link.
MATRIX_LEARN_URL https://joinmatrix.org “learn about Matrix” link.
TRUST_PROXY off Trust one X-Forwarded-* hop behind a reverse proxy.
SESSION_COOKIE_SECURE derived from SITE_URL Force secure session cookies.
STATS_ENABLED on First-party visit statistics; 0 stops recording.
STATS_RETENTION_DAYS 90 Age at which flask stats prune deletes visits.

Runtime files (SQLite database, logs) live in instance/ and are git-ignored.

Development

uv run pytest -q                  # full test suite
uv run ruff check .               # lint
uv run flask --app app routes     # URL map
uv run flask --app app shell      # app context

The suite uses in-memory SQLite and covers the landing pages, bilingual routes, Markdown rendering and safety, blog visibility, admin CMS flows and CSRF.

Design notes:

  • Public CSS is in static/css/style.css; tokens are at the top (--bg, --accent, --line, --radius).
  • JetBrains Mono is self-hosted under static/fonts/ (OFL license included).
  • Pygments CSS is generated by uv run python scripts/generate_pygments_css.py.
  • EasyMDE is vendored under static/vendor/easymde/ and loaded only on the admin post create/edit pages.

Database and migrations

uv run flask --app app db upgrade
uv run flask --app app db migrate -m "describe the change"

Migrations are committed. The current history creates the original Flango tables, then adds posts and drops tasks. For PostgreSQL later, set DATABASE_URL and install the driver; the models use SQLAlchemy 2.0 typed mappings.

Docker and Forgejo CI/CD

Local container test:

cp .env.example .env
docker compose up --build
# http://127.0.0.1:8000

The container runs flask db upgrade and then Gunicorn. SQLite data and logs are persisted in the instance named volume. The Compose file binds the app to 127.0.0.1:8000 by default; put Caddy/Traefik/nginx in front for TLS.

Temporary tailnet dev server

Rootless Docker runs as the deeps user; the default socket is $XDG_RUNTIME_DIR/docker.sock. Put this in the local (gitignored) .env:

BIND_ADDR=100.x.y.z                 # `tailscale ip -4`
WEB_PORT=8000
SITE_URL=http://srvbtw.tortoise-triggerfish.ts.net:8000
TRUST_PROXY=0
SESSION_COOKIE_SECURE=0

Then:

systemctl --user start docker.service
export DOCKER_HOST="unix://${XDG_RUNTIME_DIR}/docker.sock"

docker compose up -d --build
docker compose ps
docker compose logs -f web        # follow
docker compose exec web flask --app app create-admin --username admin
# or rotate an existing admin:
docker compose exec web flask --app app set-password --username pvl

The container then listens on <tailscale-ip>:8000, reachable at http://srvbtw.tortoise-triggerfish.ts.net:8000. Stop it with docker compose down (the named instance volume persists). This is a temporary dev binding; production keeps BIND_ADDR=127.0.0.1.

Before exposing the container, set at least:

FLASK_DEBUG=0
SECRET_KEY=<long random value>
SITE_URL=https://pvlb.dev
TRUST_PROXY=1
SESSION_COOKIE_SECURE=1

Forgejo workflows:

  • .forgejo/workflows/ci.yml — lint + tests on pushes to master and manual dispatch. There is deliberately no pull_request trigger.
  • .forgejo/workflows/publish.yml — builds the image on manual dispatch (dry run) and pushes git.pvlb.dev/web/web-frontend:{version,latest} only for v* tags. The tag must match the pyproject.toml version.
  • .forgejo/workflows/deploy.yml — manual, version-pinned production deploy. It never deploys latest; the image tag must already be published.

Required repository secrets for publishing/deploy:

Secret Purpose
AUDIENCE Repository variable holding the Authorized Integration audience (u:<id>:<uuid>), used by the OIDC image publish.
DEPLOY_SSH_KEY Private key for the forced-command deploy key.
DEPLOY_HOST Deploy host (srv).
DEPLOY_USER SSH user (dsh).
DEPLOY_KNOWN_HOSTS Pinned host key for deploy.yml.
DEPLOY_PORT Optional SSH port; defaults to 2222.

The production reference lives in deploy/ (compose.yaml, deploy.sh, receive.sh, .env.example, and the host runbook). deploy.sh pulls one X.Y.Z image, waits for /healthz, and rolls back to the previous tag on failure. Never deploy latest.

The runner label is docker; adjust it if your Forgejo runner uses a different label. Docker-in-Docker/socket access is required for the publish job. If your instance cannot resolve actions/checkout@v4, replace it with a git clone step using the job token.

Project structure

app.py                  application factory
wsgi.py                 Gunicorn entry point
config.py               environment-driven configuration
extensions.py           db, migrate, csrf, login_manager
admin.py                Flask-Admin instance, dashboard, admin access gate
i18n.py                 EN/DE URL helpers and UI translations
markdown_render.py      Markdown → HTML, excerpts, reading time
pages/                  landing pages, sitemap/robots/health, public base template
blog/                   Post model, services, public views, admin editor
auth/                   session login and create-admin CLI
stats/                  first-party visit statistics model/recorder/services/CLI
templates/admin/        Flask-Admin dashboard, stats and blog editor overrides
deploy/                 production compose, deploy/rollback scripts, host runbook
static/                 CSS, fonts, vendored EasyMDE, JS, favicon
AGENTS.d/               private knowledge clone (gitignored; absent after a clone)
input/ (optional)       local operator drop box -> AGENTS.d/input/
GIT.md                  local identity doc (gitignored)
migrations/             Alembic history
tests/                  pytest suite

Backporting

This repo is intentionally a real site, not a boilerplate. General-purpose pieces (i18n.py, markdown_render.py, the Docker/Forgejo setup, app-factory hardening) are written without pvlb.dev-specific assumptions so they can be proposed back to Flango. Site copy and the design live in clearly separated files.

License

Apache-2.0. See LICENSE.