Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YDRjtmAiNpo5mK5N3d7QwZ
80 lines
4.6 KiB
Markdown
80 lines
4.6 KiB
Markdown
# Forum and comments (Flarum)
|
|
|
|
The forum is a separate PHP application ([Flarum](https://flarum.org/) 2, PHP 8.3+, MariaDB or
|
|
MySQL). It is not part of the static build: the site only links to it and shows its threads in a
|
|
frame.
|
|
|
|
| Path | Role |
|
|
|---|---|
|
|
| `extension/` | Flarum extension `oc/flarum-museum`: the `oc:import` command and the look of embedded threads |
|
|
| `docker/`, `docker-compose.yml` | local test forum; `docker/bundle.sh` packages the server bundle |
|
|
| `import/` | not versioned: `machines.json` (export from the extraction repo), `forum.json` (thread map), `forum.tar.gz` (server bundle) |
|
|
|
|
## How comments work
|
|
|
|
- `../oc/scripts/06_forum.py` writes `import/machines.json`: one entry per machine with its
|
|
archived comments, oldest first.
|
|
- `php flarum oc:import` creates one discussion per machine: an opening post linking to the
|
|
museum page, then one post per archived comment, all by the user `Archive`, with the original
|
|
author and date at the top of each post and the original date as the post date. Discussions go
|
|
under three tags (Computers, Consoles, Pongs) that are hidden from "All discussions".
|
|
- The command records what it imported (table `oc_threads`) and skips it on later runs, so it
|
|
can be run again when new machines arrive. It writes the map machine → discussion to
|
|
`forum.json`.
|
|
- Copied to `../data/forum.json`, that map makes `make content` give every machine a Comments
|
|
tab pointing at its thread (`forum_thread` in the page front matter); the old comments are
|
|
then no longer written into the pages.
|
|
- With `params.forum.url` set, the Comments tab shows `<forum>/embed/<id>` (Flarum's Embed
|
|
extension) in a frame that follows the height of the thread.
|
|
|
|
## Local test
|
|
|
|
make forum-up # http://localhost:8081, admin / adminadmin (first start takes a minute)
|
|
make forum-import # export + import; safe to repeat
|
|
|
|
To see it in the site, copy `forum/import/forum.json` to `data/forum.json`, run `make content`,
|
|
and build with `HUGO_PARAMS_FORUM_URL=http://localhost:8081 hugo server`. Do not commit a
|
|
`data/forum.json` made from the test forum: its thread numbers are not those of the real one.
|
|
|
|
## Server install
|
|
|
|
The forum must live **outside** the folder `make deploy` writes to (that folder is synchronised
|
|
with deletion). On the test server: `web/oldcomputers-forum/`, next to `web/oldcomputers/`,
|
|
served at `https://barbel.synology.me/oldcomputers-forum`.
|
|
|
|
Checked on the test server (2026-10-11): PHP 8.4 (FPM) with every extension Flarum needs, Apache
|
|
2.4 behind nginx, `.htaccess` rewriting active. Files copied over the network share are **not
|
|
writable by the web server user `http`**, and the share does not let permissions be changed.
|
|
|
|
No Composer is needed on the server: `make forum-bundle` builds `forum/import/forum.tar.gz`, a
|
|
complete Flarum 2 tree (PHP 8.4) with the Embed and museum extensions and a top-level
|
|
`.htaccess` that routes every request into `public/`, so `config.php`, `storage/` and `vendor/`
|
|
are never served. This layout is tested in the local image.
|
|
|
|
1. Create an empty MariaDB database and a user for it.
|
|
2. Unpack the bundle into `web/oldcomputers-forum/`.
|
|
3. Give the user `http` write access to that folder and everything in it (File Station →
|
|
Properties → Permissions, or `chown -R http:http` over SSH). Flarum writes `config.php`,
|
|
`storage/` and `public/assets/`.
|
|
4. Install. Either open the forum address and fill the installer (database, administrator), or
|
|
over SSH, as `http`, in the forum folder: `php flarum install --file=install.yml` (format in
|
|
`docker/entrypoint.sh`). Do not leave the folder online uninstalled: whoever opens the
|
|
installer first becomes its administrator.
|
|
5. Enable the extensions Embed and "Old-Computers museum" (admin panel, or
|
|
`php flarum extension:enable flarum-embed` and `oc-museum`). Tags is enabled by default.
|
|
6. In the admin panel: e-mail settings (registration confirms addresses by e-mail), and a spam
|
|
filter extension. Schedule a database dump.
|
|
7. Import, over SSH in the forum folder (copy `import/machines.json` there first):
|
|
|
|
php flarum oc:import machines.json --site-url=https://barbel.synology.me/oldcomputers --map=forum.json
|
|
|
|
then bring `forum.json` back as `data/forum.json`, set `params.forum.url`, `make content`,
|
|
`make deploy`.
|
|
|
|
To update the forum or the extension later: rebuild the bundle, unpack it over the existing
|
|
folder (it contains no `config.php` and no user data), then `php flarum migrate` and
|
|
`php flarum cache:clear`.
|
|
|
|
The forum and the site should share one domain: logging in from the embedded thread relies on
|
|
the forum's cookie, which browsers restrict across domains.
|