# Admin (Decap CMS)

A lightweight, git-based editor at `/admin`. It commits markdown straight to the
Gitea repo — no database, no server. The public site stays static; rebuilding it
after an edit is a separate step (see *Deploy* below).

## 1. Put the repo on Gitea

The site must live in a Gitea repo (e.g. `git.kgva.ch/karim/kgva`). Set the same
`repo` and `branch` in `static/admin/config.yml`.

## 2. Create a Gitea OAuth app

In Gitea: **Settings → Applications → Create OAuth2 application**.

- Redirect URI: `https://<your-site>/admin/`
- Copy the **Client ID** into `static/admin/config.yml` → `backend.app_id`.

Decap uses PKCE, so no client secret and no auth proxy are needed.

## 3. Edit

Open `https://<your-site>/admin/`, log in with Gitea. New project:
*Portfolio → New Project*; images upload into `static/img` and are referenced as
`/img/...`. Saving commits to the repo on the configured branch.

## 4. Deploy (rebuild after an edit)

Because the site is baked into the Docker image, a commit must trigger a rebuild.
Pick one:

- **Manual:** on the host, `docker compose up -d --build`.
- **Gitea Actions** (`.gitea/workflows/deploy.yml`), sketch:

  ```yaml
  on: { push: { branches: [main] } }
  jobs:
    deploy:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v4
        - run: docker compose up -d --build      # on a runner with access to the host
  ```

  (Adjust to your Proxmox/LXC setup — same place OPENBUREAU deploys.)

- **Webhook:** point a Gitea webhook at a tiny script on the host that runs the
  `docker compose` line.

## Local editing (no auth)

```
npx decap-server          # in one terminal
# uncomment `local_backend: true` in config.yml
hugo server               # in another
# open http://localhost:1313/admin/
```

## Self-hosting the CMS bundle (optional)

To avoid the CDN (in the spirit of the colophon), download the bundle once and
point `static/admin/index.html` at it:

```
curl -L https://unpkg.com/decap-cms@^3.3.3/dist/decap-cms.js \
  -o static/admin/decap-cms.js
# then in index.html: <script src="/admin/decap-cms.js"></script>
```
