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
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,42 @@ jobs:
trap 'docker rm -f "$cid" >/dev/null' EXIT
docker cp . "$cid:/repo"
docker start -a "$cid"

ghost:
name: Ghost theme (GScan, demo, markup and browser checks)
runs-on: ubuntu-latest
timeout-minutes: 30
env:
GHOST_NETWORK: readerly-ghost-ci
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 20
- run: node tools/build-tokens.mjs --check
- run: node tools/ghost-locales.mjs --check
# GScan runs inside the ghost:6 image on the zip that would ship. Any error or
# warning fails.
- name: Build the theme zip and run GScan on it
run: |
set -euo pipefail
zip="$(tools/build-ghost-zip.sh)"
tools/ghost-dev/ghost-dev.sh gscan "$zip" -z
rm -rf "$RUNNER_TEMP/ghost-theme" && mkdir -p "$RUNNER_TEMP/ghost-theme"
unzip -q "$zip" -d "$RUNNER_TEMP/ghost-theme"
# A job container cannot reach ports published on the host, so Ghost and the
# checks share a Docker network and Ghost answers there as http://ghost:2368.
- name: Start Ghost with the zipped theme and load the demo
run: |
set -euo pipefail
docker network create "$GHOST_NETWORK"
THEME_DIR="$RUNNER_TEMP/ghost-theme/readerly" tools/ghost-dev/ghost-dev.sh up
- name: Markup parity, browser checks and side-by-side screenshots
run: tools/ghost-dev/ghost-dev.sh check
- name: Stop Ghost
if: always()
run: |
tools/ghost-dev/ghost-dev.sh clean
docker network rm "$GHOST_NETWORK" >/dev/null 2>&1 || true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
dist/
tools/ghost-dev/.state
tools/ghost-dev/out/
61 changes: 56 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Readerly

Readerly is a free theme for people who love books, for WordPress, Jekyll and Hugo. It is built for a book blog first, and it also gives you an author website and a reading log. Each use is optional: the theme creates no pages, posts or categories, and every section can be removed. It comes in two styles, Paper (light) and Lamplight (dark), and bundles its fonts, so it makes no third-party requests.
Readerly is a free theme for people who love books, for WordPress, Jekyll, Hugo and Ghost. It is built for a book blog first, and it also gives you an author website and a reading log. Each use is optional: the theme creates no pages, posts or categories, and every section can be removed. It comes in two styles, Paper (light) and Lamplight (dark), and bundles its fonts, so it makes no third-party requests.

The WordPress theme requires WordPress 6.9 and PHP 7.4, under GPLv2 or later. The Jekyll theme runs on GitHub Pages and Jekyll 4, and the Hugo theme on Hugo 0.146.0 or later, both under the MIT License.
The WordPress theme requires WordPress 6.9 and PHP 7.4, under GPLv2 or later. The Jekyll theme runs on GitHub Pages and Jekyll 4, the Hugo theme on Hugo 0.146.0 or later, and the Ghost theme on Ghost 6, all three under the MIT License.

## Layout

Expand All @@ -16,7 +16,8 @@ The WordPress theme requires WordPress 6.9 and PHP 7.4, under GPLv2 or later. Th
| `jekyll/fixtures/` | Sites that only the checks build: `bare` (a title and nothing else), `minima` (the output of `jekyll new`) and `sparse` (one post per missing field). |
| `hugo/theme/` | The Hugo theme, published as `listofbooks-net/hugo-theme-readerly`, with its demo site, Marginalia, in `hugo/theme/exampleSite/`. |
| `hugo/fixtures/` | Sites that only the checks build: `bare` (a title and nothing else), `quickstart` (what `hugo new site` and `hugo new content` make), `sparse` (one review per missing field), `paginated` (a custom pager path) and `no-credit` (the credit partial emptied). |
| `tools/` | The generator, the checks that CI runs, the zip builder, a local WordPress and the Jekyll and Hugo build images. None of it ships. |
| `ghost/` | The Ghost theme. Its contents are what ships; `ghost/README.md` is the theme's documentation. |
| `tools/` | The generator, the checks that CI runs, the zip builder, a local WordPress and the Jekyll and Hugo build images and a local Ghost. None of it ships. |

## Generated files

Expand All @@ -28,12 +29,15 @@ The WordPress theme requires WordPress 6.9 and PHP 7.4, under GPLv2 or later. Th
- `jekyll/theme/assets/css/readerly.css` (fonts, tokens and `design/assets/css/style.css`), `jekyll/theme/assets/js/theme.js`, and the theme's fonts and images
- the demo's covers and images in `jekyll/demo/assets/`
- `hugo/theme/assets/readerly/css/readerly.css` (the same CSS as the Jekyll theme's) and `hugo/theme/assets/readerly/js/theme.js`, the theme's fonts and images in `hugo/theme/static/readerly/`, and the demo's covers and images in `hugo/theme/exampleSite/static/assets/`
- `ghost/assets/css/readerly.css` (fonts, tokens and `design/assets/css/style.css`), `ghost/assets/js/theme.js`, and the Ghost theme's fonts and images

```sh
node tools/build-tokens.mjs # regenerate
node tools/build-tokens.mjs --check # exit 1 if a generated file is out of date
```

`node tools/ghost-locales.mjs [--check]` does the same for `ghost/locales/en.json`, from the strings in the Ghost templates.

Edit the source in `design/`, rerun the command and commit the generated files. Do not edit those files by hand. The design pages link `design/assets/css/demo.css`, which holds the demo-bar rules that no theme ships.

## Run WordPress locally
Expand All @@ -59,7 +63,7 @@ CI is `.github/workflows/ci.yml`. GitHub Actions is off for this repository, so
act pull_request -W .github/workflows/ci.yml
```

It checks that the generated files are up to date, that `theme.json` and the style files match the WordPress schema (`npm ci --prefix tools && node tools/check-theme-json.mjs`), that every PHP file passes `php -l` on PHP 7.4 and 8.4, and every Jekyll check in the next section.
It checks that the generated files are up to date, that `theme.json` and the style files match the WordPress schema (`npm ci --prefix tools && node tools/check-theme-json.mjs`), that every PHP file passes `php -l` on PHP 7.4 and 8.4, and every Jekyll, Hugo and Ghost check in the sections below.

## Build and check the Jekyll theme

Expand Down Expand Up @@ -123,6 +127,53 @@ To compare the design pages with the demo by eye, run `node tools/hugo-dev/side-

`tools/publish-hugo.sh <version>` pushes a release to the public repository: the tag first, then `main`. Hugo Modules resolve the semantic version tag, so there is no branch to move. Only an operator runs it; see the header of the script.

## Run Ghost locally

You need Docker and Node 20 or later. The script starts Ghost 6 (the `ghost:6` image, SQLite) with `ghost/` mounted read-only as the theme `readerly`, creates the admin, activates the theme and loads the Marginalia demo. Ghost listens on the first free port from 2380 (set `PORT` to fix it) and the script remembers the port in `tools/ghost-dev/.state`. The admin login is `admin@readerly.test` with the password in `tools/ghost-dev/seed.mjs`.

```sh
tools/ghost-dev/ghost-dev.sh up # start, set up, activate the theme, seed
tools/ghost-dev/ghost-dev.sh seed # reload the demo content
tools/ghost-dev/ghost-dev.sh gscan # GScan for Ghost 6 on ghost/; or: gscan dist/readerly-ghost-1.0.0.zip -z
tools/ghost-dev/ghost-dev.sh check # markup parity, browser checks, side-by-side screenshots
tools/ghost-dev/ghost-dev.sh export site/ https://readerly-ghost-demo.pages.dev # static copy, verified in a browser
tools/ghost-dev/ghost-dev.sh url # print the site URL
tools/ghost-dev/ghost-dev.sh down # stop, keep the data
tools/ghost-dev/ghost-dev.sh clean # remove the container and its data
```

`gscan` runs the GScan that ships in the `ghost:6` image and exits with 1 on any error or warning. Recommendations do not fail it.

Editing a template needs `down` and `up` again, because Ghost reads templates at start. To mount another theme folder, set `THEME_DIR`.

### Demo content

`seed.mjs` loads the demo through the Admin API. It first deletes every post, page and tag, so a rerun gives the same slugs and the same HTML. It reuses the images it uploaded before, because Ghost cannot delete an upload and would rename a repeat to `name-2.svg`. The content comes from `jekyll/demo` and `design/`:

- Ten reviews are posts. The newest, The Salt Orchard, is featured. A review's `excerpt` is the post's `custom_excerpt`; the Jekyll `lead` is not loaded, because Ghost has one summary field and the theme prints it under the title and on the cards.
- Facts about a book are internal tags in the order genre, other public tags, `#by:`, `#series:`, `#rating:`, `#pages:`, `#published:`, then the status (`#read`, `#reading`, `#want-to-read`, `#did-not-finish`). The tag table is in the theme README.
- Books on the reading log with no review are pages with the same fact tags, plus `#on-page:` for a book in progress. Isobel Thorne's four novels are pages tagged `#book` and `#buy:`.
- Design markup that Ghost's editor would flatten (the verdict, the pull quote, the praise and events lists, the where-to-buy block) goes in as HTML cards.
- The site settings, navigation, accent colour, Nora Vale's profile and the theme's custom settings are set too. The seed prints any theme setting the theme does not define.

### Checks against the running site

`check` runs three things:

1. Markup parity. Each of the seven design pages and its Ghost page reduce to a tree of tag names, classes, roles and ARIA attributes, and the trees must match. `tools/ghost-dev/parity-exceptions.json` lists the elements removed from either side first, each with a reason. The algorithm is `tools/jekyll-dev/check-parity.mjs`.
2. `tools/wp-dev/check-pages.cjs` on the pages in `tools/ghost-dev/pages.json`, at 1280 px and 390 px, in Paper and Lamplight. Requests to `cdn.jsdelivr.net/ghost/`, where Ghost loads Portal and its search from, are allowed; any other third-party request fails.
3. `tools/ghost-dev/side-by-side.mjs` screenshots each design page next to the Ghost page. Open `tools/ghost-dev/out/side-by-side/index.html`.

### Static copy for the demo site

`export` crawls the sitemaps, the home page, the feed, the 404 page and everything they reference into a folder you can host on Cloudflare Pages. It rewrites the Ghost address to the public one. It removes Portal, the comments and the member-attribution scripts, and the comments section. It turns each `form[data-members-form]` into `data-demo-form`, which the theme script confirms in place. Search keeps working: sodo-search reads three files, `/ghost/api/content/search-index/posts/`, `.../authors/` and `.../tags/`, and the export saves them. It writes `_headers`, which allows framing by `ghost.org` for the Marketplace preview, and `_redirects` when Ghost redirected something while crawling. The export then serves the copy, loads every page in a browser and fails on a request to the Ghost address, a failed request, or a search for "Salt" that finds nothing.

`tools/publish-ghost-demo.sh` runs all of that and deploys the copy with `wrangler pages deploy`. It changes a public site, so only an operator runs it, by hand.

### In CI

The `ghost` job builds the zip (`tools/build-ghost-zip.sh`, which writes `dist/readerly-ghost-<version>.zip`), runs GScan on it, starts Ghost with the unzipped theme, seeds it and runs `check`. A CI job cannot reach ports published on the host, so it sets `GHOST_NETWORK`: Ghost joins that Docker network as `ghost`, and the seed and the checks run in a Playwright container on the same network.

## Build the zip

```sh
Expand All @@ -137,4 +188,4 @@ tools/wp-dev/wp-dev.sh zip-test dist/readerly-1.0.0.zip

## The footer credit

The footer keeps one link, "Theme by List of Books", to https://www.listofbooks.net/. In WordPress, a site owner can edit or delete it in the Site Editor. In Jekyll, a site owner removes it by adding an empty `_includes/shell/credit.html`, and in Hugo an empty `layouts/_partials/credit.html`.
The footer keeps one link, "Theme by List of Books", to https://www.listofbooks.net/. In WordPress, a site owner can edit or delete it in the Site Editor. In Jekyll, a site owner removes it by adding an empty `_includes/shell/credit.html`, and in Hugo an empty `layouts/_partials/credit.html`. The Ghost theme prints it next to "Published with Ghost" from `ghost/partials/site/credit.hbs`, which a site owner edits in the theme files.
24 changes: 24 additions & 0 deletions ghost/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MIT License

Copyright (c) 2026 List of Books

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

The fonts in assets/fonts are licensed separately under the SIL Open Font
License 1.1; each font folder holds its OFL.txt.
Loading
Loading