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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ api-backend/Tests/
**/node_modules
**/dist
**/dist-ssr
**/dist-demo
**/playwright-report
**/test-results
*.local
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ jobs:
- name: Unit tests
run: pnpm test:front

# Browser-only demo (GitHub Pages, pages.yml): a package change that breaks it fails here, not after merge
- name: Demo tests + build
run: |
pnpm test:demo
pnpm build:demo

- name: Build & start stack
run: docker compose up -d --build frontend renderer

Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Push to main → build the browser-only demo (playground/demo/: the editor + view of one page against an in-browser
# mock of the API, kept in localStorage) and deploy it to GitHub Pages (https://trainpaths.github.io/cms/).
# Relative asset URLs (base './' in vite.demo.config.ts) and hash routes: works under /cms/ without a 404.html.
name: Pages

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
with:
package_json_file: package.json
- uses: actions/setup-node@v7
with:
node-version: 26
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- run: pnpm build:demo
- uses: actions/upload-pages-artifact@v5
with:
path: playground/dist-demo

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v5
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bld/
# Frontend build artifacts
dist
dist-ssr
dist-demo
*.local

# Editor directories and files
Expand Down
8 changes: 6 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ frontend/ @trainpaths/cms package (raw source): admin SPA, public
vite plugin, server/ (renderer, dev SSR), nginx.conf, generated API client
src/lib/web-editor/ block editor library (editor, blocks, view renderer, limits)
playground/ instance app on `workspace:*` (cms.config.json, index.html, public.html, entry stubs, style.css,
sample block/override/template) + e2e/
sample block/override/template) + e2e/ + demo/ (browser-only demo for GitHub Pages, see playground/CLAUDE.md)
api-backend/ .NET API (+ Tests/: xUnit unit + Testcontainers integration)
package.json, pnpm-workspace.yaml pnpm workspace root (frontend + playground; ESLint, all repo scripts)
Dockerfile 5-stage build: api-build → frontend-build (playground) → api → renderer → frontend
Expand All @@ -74,6 +74,8 @@ pnpm test:back # xUnit (needs Docker for Testcontainers)
pnpm test:front # Vitest unit tests (SSR render)
pnpm test:e2e # Playwright (needs the stack running; editor specs need staff creds, see frontend/CLAUDE.md)
pnpm test:all # test:back + test:front + test:e2e
pnpm dev:demo # browser-only demo (playground/demo/, no Docker) → http://localhost:5173
pnpm build:demo # demo → playground/dist-demo/ (what pages.yml deploys); test:demo = its Vitest
```

**No local .NET SDK?** Run `dotnet` in the SDK image with the repo mounted at the same path (the
Expand Down Expand Up @@ -132,7 +134,9 @@ Typed client generated from the committed contract (and committed itself: instan
## CI + releases (.github/workflows/)
`ci.yml` runs on PRs + pushes to `main`. **backend**: vulnerable-package check, `dotnet test`,
OpenAPI drift check. **frontend**: `pnpm audit`, generated-client drift check, lint, typecheck, Vitest, compose stack,
Playwright from `playground/` (with a bootstrap super admin for the editor specs). Dependabot opens weekly update PRs.
Playwright from `playground/` (with a bootstrap super admin for the editor specs), plus `test:demo` + `build:demo`.
Dependabot opens weekly update PRs. `pages.yml`: push to `main` → `build:demo` → GitHub Pages
(https://trainpaths.github.io/cms/; repo Settings → Pages → Source "GitHub Actions").
The backend job installs `postgresql-client-18` (backup round-trip tests).
`release.yml` runs after a green CI run on `main` (or manually, forcing the bump): Conventional Commits since the last
tag → bump (only docs/chore/ci/test/style/build → none). **Pre-1.0 (now)**: `!`/`BREAKING CHANGE` → minor, everything
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CMS

**Building a website with it?** Start from [`trainpaths/cms-starter`](https://github.com/trainpaths/cms-starter): the
template for a new site, with everything you need to develop your own site on this CMS.

A block-based content management system: site owners build pages from blocks in a Gutenberg-style editor; visitors
get server-rendered pages at `/{slug}`.

Expand All @@ -14,6 +17,9 @@ bumping one version.

Building a site on it: [`frontend/docs/INSTANCE_GUIDE.md`](frontend/docs/INSTANCE_GUIDE.md).

**[Try the editor in your browser](https://trainpaths.github.io/cms/)**: a demo page you can edit, publish and view,
with no server (changes stay in your browser).

## Features

- Block editor: nested blocks, drag & drop, undo/redo, autosave, outline, responsive (container queries)
Expand Down Expand Up @@ -69,6 +75,7 @@ pnpm dev # postgres + seaweedfs + api in docker, playgr
| `pnpm test:front` | Vitest (SSR render, head tags) |
| `pnpm test:e2e` | Playwright against the running stack (see `playground/CLAUDE.md`) |
| `pnpm test:all` | All three test suites |
| `pnpm dev:demo` / `build:demo` | Browser-only demo (GitHub Pages), no Docker; `test:demo` = its unit tests |

API change: `pnpm build:back`, then `pnpm gen-api`, commit `frontend/openapi/swagger.json` and `frontend/src/api/`;
CI fails when either drifts.
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfigWithVueTs(
ignores: [
'**/dist/**',
'**/dist-ssr/**',
'**/dist-demo/**',
'frontend/src/api/**',
'**/playwright-report/**',
'**/test-results/**',
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
"dev": "docker compose up -d postgres seaweedfs api && pnpm dev:web",
"dev:build": "docker compose up -d --build postgres seaweedfs api && pnpm dev:web",
"dev:web": "pnpm --filter cms-playground dev",
"dev:demo": "pnpm --filter cms-playground dev:demo",
"docker:up": "docker compose up -d --build",
"docker:down": "docker compose down",
"build:front": "pnpm --filter cms-playground build",
"build:demo": "pnpm --filter cms-playground build:demo",
"build:back": "dotnet build api-backend/api-backend.csproj",
"typecheck": "pnpm -r typecheck",
"lint": "eslint .",
"test:front": "pnpm --filter @trainpaths/cms test",
"test:demo": "pnpm --filter cms-playground test:demo",
"test:back": "dotnet test --project api-backend/Tests/Tests.csproj",
"test:all": "pnpm test:back && pnpm test:front && pnpm test:e2e",
"test:e2e": "pnpm --filter cms-playground test:e2e",
Expand Down
32 changes: 32 additions & 0 deletions playground/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ src/blocks/callout/ instance block example (Edit imports @trainpaths/cms/editor,
src/overrides/NotFound.vue override example: wraps the package's NotFound
src/templates/imprint.vue template page example: PageContent + `after` slot: firm name, contact, VAT ID, socials
e2e/ Playwright suite (below); e2e/tests/instance/ covers the examples above
demo/, demo.html, vite.demo.config.ts browser-only demo for GitHub Pages (below)
```
Extension points in general: `frontend/CLAUDE.md` → Package surface.

Expand Down Expand Up @@ -74,3 +75,34 @@ Editor specs need staff credentials in the Playwright env — the same values as
BOOTSTRAP_SUPERADMIN_EMAIL=... BOOTSTRAP_SUPERADMIN_PASSWORD=... pnpm test:e2e
```
First run on a machine: `pnpm --filter cms-playground exec playwright install chromium`.

## Demo (`demo/`, GitHub Pages)
The real editor and public view of **one page**, with no server: the generated client's `fetch` is replaced by an
in-browser mock of the API (`client.setConfig({ fetch })`), and the page lives in localStorage. Nothing in the package
changes for it; it uses deep imports (`@trainpaths/cms/src/….ts`, with extension: the `./src/*` export adds none).
`pnpm dev:demo` (no Docker), `pnpm build:demo` → `dist-demo/` (deployed by `.github/workflows/pages.yml`),
`pnpm test:demo`.
```
demo.html shell → demo/main.ts
vite.demo.config.ts cms() without dev SSR + plugin `cms-demo`: build input demo.html only (emitted as index.html),
`/` → demo.html in dev, the package's MediaUploadButton.vue → demo/NoUpload.vue (no uploads);
base './' (Pages serves /cms/)
demo/main.ts app: Pinia, CMS i18n (+ demo/messages.ts after each loadAdminMessages), mock fetch, toApiError,
hash router: `#/` + `#/:slug` = ViewPage, `#/edit` = EditPage, `#/de/home` (editor view link) →
switch language + `#/`; one language for view + UI (`LANGUAGE_SWITCH`, demo/context.ts)
demo/mockApi.ts createMockFetch(store, {languages}): page GET/PUT (draft/live like the API: publish copies the
working copy to the live snapshot, hasUnpublishedChanges = differs from it, slug fixed: page is
`locked`), public state/page/menu/site-config (localized via core/localize.ts), media list +
tags (read-only), instance config from cms.config.json; anything else → 403 "Not available in the demo"
demo/store.ts localStorage `cms-demo:v1` (working copy + live snapshot; memory when storage fails), reset()
demo/seed.ts the page (every block incl. callout; de complete, fr/it partly: shows the untranslated badges),
main menu (labels per language), site config (contact only: no firm name or logo)
demo/media.ts, images/ seeded placeholder SVGs (the picker's library); media URLs are always served fresh
(stored ones would point at an older deploy's hashed assets)
demo/ViewPage.vue SiteHeader + PageView + SiteFooter of the published page; delegated clicks on link-block hrefs
(`/`, `/edit`, other paths → "only one page" toast)
demo/EditPage.vue the package's Editor.vue (view link + back → `#/`)
demo/DemoMenu.vue floating round button (cog + "Demo", bottom left, z-45) → Popover: edit/view, reset (confirm →
reload), GitHub links
demo/mockApi.test.ts Vitest (demo/vitest.config.ts): draft vs live, storage + reset, unpublish, languages, refusals
```
20 changes: 20 additions & 0 deletions playground/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Try the block editor of the CMS in your browser: edit a page, publish it and view the result." />
<title>CMS demo</title>
</head>
<body>
<!-- boot loader: replaced when the app mounts; styled by the CMS package CSS -->
<div id="app">
<div class="flex h-screen items-center justify-center gap-8 font-sans text-sm text-gray-400" role="status">
<span class="size-16 animate-spin rounded-full border-2 border-gray-200 border-t-primary"></span>
Loading…
</div>
</div>
<script type="module" src="/demo/main.ts"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions playground/demo/DemoApp.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { ConfirmDialog, ToastContainer } from '@trainpaths/nb-ui'
import DemoMenu from './DemoMenu.vue'
</script>

<template>
<RouterView />
<DemoMenu />
<ToastContainer position="right-16 bottom-[25vh]" />
<ConfirmDialog />
</template>
112 changes: 112 additions & 0 deletions playground/demo/DemoMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Button, Icon, Popover, useConfirm } from '@trainpaths/nb-ui'
import { translate } from '@trainpaths/cms/src/i18n/index.ts'
import { useDemo } from './context'

/** Floating round "Demo" button over every screen; opens the demo settings (edit/view, reset, links). */
const route = useRoute()
const router = useRouter()
const { confirm } = useConfirm()
const { reset } = useDemo()

const editing = computed(() => route.name === 'edit')

function go(path: string, close: () => void) {
close()
void router.push(path)
}

async function onReset(close: () => void) {
close()
const ok = await confirm({
title: translate('demo.resetTitle'),
message: translate('demo.resetMessage'),
confirmText: translate('demo.reset'),
cancelText: translate('common.cancel'),
danger: true,
})
if (ok) reset()
}

const linkClass = 'text-sm text-primary underline-offset-2 hover:underline'
</script>

<template>
<!-- z-45: over the editor header (z-40) and sidebars (z-30), under dialogs (z-50: the reset confirm covers it) -->
<div class="fixed bottom-16 left-16 z-[45] font-sans">
<Popover
placement="top"
align="start"
:label="$t('demo.title')"
>
<template #trigger="{ props: triggerProps, open }">
<button
v-bind="triggerProps"
type="button"
class="flex size-64 cursor-pointer flex-col items-center justify-center gap-2 rounded-full border-none text-white shadow-lg ring-white/70 transition hover:scale-105 hover:bg-primary focus-visible:ring-4 focus-visible:outline-hidden motion-reduce:transition-none motion-reduce:hover:scale-100"
:class="open ? 'bg-primary' : 'bg-black'"
data-testid="demo-menu"
>
<Icon
name="settings"
:size="22"
/>
<span class="text-[10px] leading-none font-semibold tracking-wide uppercase">{{ $t('demo.button') }}</span>
</button>
</template>
<template #default="{ close }">
<div
class="flex w-[min(288px,calc(100vw-32px))] flex-col gap-12"
data-testid="demo-panel"
>
<div>
<p class="m-0 text-base font-semibold text-gray-900">{{ $t('demo.title') }}</p>
<p class="m-0 mt-4 text-sm text-gray-600">{{ $t('demo.note') }}</p>
</div>
<div class="flex flex-col gap-8">
<Button
bg="primary"
block
data-testid="demo-switch"
@click="go(editing ? '/' : '/edit', close)"
>
<Icon
:name="editing ? 'eye' : 'edit'"
:size="16"
/>
{{ editing ? $t('demo.view') : $t('demo.edit') }}
</Button>
<Button
variant="outline"
text="danger"
border="danger"
block
data-testid="demo-reset"
@click="onReset(close)"
>
{{ $t('demo.reset') }}
</Button>
</div>
<div class="flex flex-wrap gap-x-16 gap-y-4 border-t border-gray-200 pt-12">
<a
href="https://github.com/trainpaths/cms"
target="_blank"
rel="noopener"
:class="linkClass"
>{{ $t('demo.repo') }}</a
>
<a
href="https://github.com/trainpaths/cms-starter"
target="_blank"
rel="noopener"
:class="linkClass"
>{{ $t('demo.starter') }}</a
>
</div>
</div>
</template>
</Popover>
</div>
</template>
17 changes: 17 additions & 0 deletions playground/demo/EditPage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import Editor from '@trainpaths/cms/src/lib/web-editor/editor/Editor.vue'
import { DEMO_PAGE_ID } from './seed'

// the real editor; its view link and back button lead to the view (`#/`)
const router = useRouter()
</script>

<template>
<Editor
:page-id="DEMO_PAGE_ID"
public-base=""
preview-path="/"
@back="router.push('/')"
/>
</template>
5 changes: 5 additions & 0 deletions playground/demo/NoUpload.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script setup lang="ts">
// Stands in for the package's MediaUploadButton in the demo build (vite.demo.config.ts): no uploads, images are
// chosen from the seeded library. Renders nothing.
defineOptions({ render: () => null })
</script>
Loading
Loading