From 7c900e8f70574a70050639a61e4e9097c68e57c9 Mon Sep 17 00:00:00 2001 From: Lai Hung <19669099+phoduke@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:34:44 +0700 Subject: [PATCH 01/14] feat(ghost-dev): add the local Ghost harness and the Marginalia demo loader --- .gitignore | 2 + tools/ghost-dev/ghost-dev.sh | 187 +++++++++++++++++ tools/ghost-dev/seed.mjs | 380 ++++++++++++++++++++++++++++++++++ tools/ghost-dev/yaml-lite.mjs | 89 ++++++++ 4 files changed, 658 insertions(+) create mode 100755 tools/ghost-dev/ghost-dev.sh create mode 100644 tools/ghost-dev/seed.mjs create mode 100644 tools/ghost-dev/yaml-lite.mjs diff --git a/.gitignore b/.gitignore index b947077..d356ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules/ dist/ +tools/ghost-dev/.state +tools/ghost-dev/out/ diff --git a/tools/ghost-dev/ghost-dev.sh b/tools/ghost-dev/ghost-dev.sh new file mode 100755 index 0000000..d4da03f --- /dev/null +++ b/tools/ghost-dev/ghost-dev.sh @@ -0,0 +1,187 @@ +#!/usr/bin/env bash +# Local Ghost for developing and checking the Readerly Ghost theme. Needs Docker and Node 20+. +# +# tools/ghost-dev/ghost-dev.sh up start Ghost 6 with ghost/ mounted as theme readerly, create the admin, activate the theme, load the demo +# tools/ghost-dev/ghost-dev.sh seed reload the Marginalia demo content (deletes every post, page and tag first) +# tools/ghost-dev/ghost-dev.sh gscan [path] [-z] run GScan for Ghost 6 on a theme folder (default ghost/) or, with -z, a zip; exit 1 on any error or warning +# tools/ghost-dev/ghost-dev.sh check markup parity with design/, browser checks and side-by-side screenshots, against the running site +# tools/ghost-dev/ghost-dev.sh export [public url] crawl the running site into a static copy for Cloudflare Pages, then verify it +# tools/ghost-dev/ghost-dev.sh url print the site URL +# tools/ghost-dev/ghost-dev.sh down stop Ghost (keeps the database and uploaded images) +# tools/ghost-dev/ghost-dev.sh clean remove the container, its volume and the remembered port +# +# Every command is safe to rerun. Ghost listens on 127.0.0.1 at PORT, or at the first +# free port from 2380, remembered in tools/ghost-dev/.state. The admin is +# admin@readerly.test with the password in seed.mjs (printed by up). +# +# Environment: +# PORT fixed port +# THEME_DIR theme folder to mount (default ghost/); without package.json the default theme stays active +# GHOST_NETWORK a Docker network. Ghost joins it as host "ghost" and publishes no port; seed, +# check and export then run in a Playwright container on that network. CI uses +# this, because a job container cannot reach the host's published ports. +set -euo pipefail + +here="$(cd "$(dirname "$0")" && pwd)" +repo="$(cd "$here/../.." && pwd)" +state="$here/.state" +name=readerly-ghost-dev +volume="$name-content" +ghost_image=ghost:6 +runner_image=mcr.microsoft.com/playwright:v1.61.0-noble +theme_dir="$(realpath -m "${THEME_DIR:-$repo/ghost}")" +network="${GHOST_NETWORK:-}" + +port_in_use() { ss -Hltn "sport = :$1" | grep -q .; } +running() { [[ "$(docker inspect -f '{{.State.Running}}' "$name" 2>/dev/null || true)" == true ]]; } + +pick_port() { + if [[ -n "${PORT:-}" ]]; then echo "$PORT"; return; fi + if running; then docker port "$name" 2368/tcp | head -n1 | sed 's/.*://'; return; fi + if [[ -f "$state" ]]; then + local saved + saved="$(sed -n 's/^PORT=//p' "$state")" + if [[ -n "$saved" ]] && ! port_in_use "$saved"; then echo "$saved"; return; fi + fi + for p in $(seq 2380 2499); do + if ! port_in_use "$p"; then echo "$p"; return; fi + done + echo "no free port in 2380-2499" >&2 + exit 1 +} + +if [[ -n "$network" ]]; then + url="http://ghost:2368" +else + port="$(pick_port)" + url="http://localhost:$port" +fi + +ghost_ready() { + if [[ -n "$network" ]]; then + docker exec "$name" node -e 'fetch("http://localhost:2368/ghost/api/admin/site/").then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1))' + else + curl -fsS -o /dev/null "$url/ghost/api/admin/site/" + fi +} + +start() { + if running; then + ghost_ready 2>/dev/null && return + fi + docker rm -f "$name" >/dev/null 2>&1 || true + local args=( + -e "url=$url" -e NODE_ENV=development -e security__staffDeviceVerification=false + -e privacy__useUpdateCheck=false -e privacy__useGravatar=false -e privacy__useRpcPing=false + -v "$volume:/var/lib/ghost/content" + ) + if [[ -n "$network" ]]; then + args+=(--network "$network" --network-alias ghost) + else + args+=(-p "127.0.0.1:$port:2368") + [[ -f "$theme_dir/package.json" ]] && args+=(-v "$theme_dir:/var/lib/ghost/content/themes/readerly:ro") + printf 'PORT=%s\n' "$port" >"$state" + fi + local cid + cid="$(docker create --name "$name" "${args[@]}" "$ghost_image")" + # A job container cannot bind-mount its own files, so the theme is copied in instead. + if [[ -n "$network" && -f "$theme_dir/package.json" ]]; then + docker cp "$theme_dir/." "$cid:/var/lib/ghost/content/themes/readerly" + fi + docker start "$cid" >/dev/null + local tries=0 + until ghost_ready 2>/dev/null; do + if (( ++tries > 180 )); then + echo "Ghost did not answer within 180 seconds. Check: docker logs $name" >&2 + exit 1 + fi + sleep 1 + done +} + +# node_tool + + {{ghost_head}} + + + + {{> "site/header"}} +
+{{{body}}} +
+ {{> "site/footer"}} + {{ghost_foot}} + + diff --git a/ghost/error-404.hbs b/ghost/error-404.hbs new file mode 100644 index 0000000..6be189d --- /dev/null +++ b/ghost/error-404.hbs @@ -0,0 +1,28 @@ +{{!< default}} +
+
+ +

{{t "This page has wandered off the shelf"}}

+

{{t "The link may be old, or the page may have been moved or renamed. Try a search, or start again from the front page."}}

+ {{> "site/search-form" id="search-404" placeholder=(t "Search by title, author or genre")}} +
+ {{t "Back to the front page"}} + {{#get "pages" include="tags" filter="slug:reading-log" limit="1" as |log_pages|}}{{#foreach log_pages}}{{t "See my reading log"}}{{/foreach}}{{/get}} +
+
+ {{#get "posts" include="tags,authors" filter="tag:[hash-rating-5,hash-rating-4-5]" limit="8" as |favourites|}}{{#if favourites}} +
+
+

{{t "Or pick something to read"}}

+

{{t "Recent favourites"}}

+
+
    + {{#foreach favourites}} +
  • + {{> "book/card" variant="compact" link=true}} +
  • + {{/foreach}} +
+
+ {{/if}}{{/get}} +
diff --git a/ghost/error.hbs b/ghost/error.hbs new file mode 100644 index 0000000..32a1746 --- /dev/null +++ b/ghost/error.hbs @@ -0,0 +1,17 @@ +{{!< default}} +
+
+ +

{{message}}

+ +
+ {{#if errorDetails}} + + {{/if}} +
diff --git a/ghost/index.hbs b/ghost/index.hbs new file mode 100644 index 0000000..4a027b6 --- /dev/null +++ b/ghost/index.hbs @@ -0,0 +1,13 @@ +{{!< default}} +{{#is "paged"}} +{{> "sections/recent"}} +{{else}} +{{> "sections/intro"}} +{{#foreach posts limit="1"}} +{{> "sections/feature"}} +{{/foreach}} +{{#match posts.length ">" 1}}{{> "sections/recent"}}{{/match}} +{{#if @custom.show_currently_reading}}{{#get "posts" include="tags,authors" filter="tag:hash-reading" limit="12" as |reading_posts|}}{{#get "pages" include="tags" filter="tag:hash-reading" limit="12" as |reading_pages|}}{{> "sections/reading-now" shelf_posts=reading_posts shelf_pages=reading_pages show_log_link=true}}{{/get}}{{/get}}{{/if}} +{{#if @custom.show_genres}}{{> "sections/genres"}}{{/if}} +{{> "sections/newsletter"}} +{{/is}} diff --git a/ghost/locales/en.json b/ghost/locales/en.json new file mode 100644 index 0000000..d492918 --- /dev/null +++ b/ghost/locales/en.json @@ -0,0 +1,96 @@ +{ + "{pages} pages": "{pages} pages", + "{shelf}, scrollable shelf": "{shelf}, scrollable shelf", + "% book": "% book", + "% books": "% books", + "% review": "% review", + "% review so far": "% review so far", + "% reviews": "% reviews", + "% reviews and counting": "% reviews and counting", + "About {name}": "About {name}", + "about {title}": "about {title}", + "Average rating": "Average rating", + "Back to the front page": "Back to the front page", + "Books read": "Books read", + "Browse": "Browse", + "Browse by genre": "Browse by genre", + "Buy": "Buy", + "Buy the book": "Buy the book", + "By": "By", + "by {author}": "by {author}", + "Comments": "Comments", + "Cover of {title}": "Cover of {title}", + "Currently reading": "Currently reading", + "Dark theme": "Dark theme", + "Did not finish": "Did not finish", + "Discover {title}": "Discover {title}", + "DNF": "DNF", + "Elsewhere": "Elsewhere", + "Email address": "Email address", + "Featured": "Featured", + "Featured review": "Featured review", + "Genre": "Genre", + "Genres and tags": "Genres and tags", + "Join my newsletter": "Join my newsletter", + "Latest review": "Latest review", + "Learn more": "Learn more", + "More": "More", + "More from {name}": "More from {name}", + "More in {genre}": "More in {genre}", + "My books": "My books", + "My rating": "My rating", + "My reading log": "My reading log", + "New release": "New release", + "Newer": "Newer", + "Newest first": "Newest first", + "No cover image yet: {title}": "No cover image yet: {title}", + "No reviews": "No reviews", + "No reviews yet": "No reviews yet", + "of {pages}": "of {pages}", + "Older": "Older", + "Older reviews": "Older reviews", + "Or pick something to read": "Or pick something to read", + "Other genres": "Other genres", + "Page": "Page", + "Page {page} of {pages}": "Page {page} of {pages}", + "Pages": "Pages", + "Pages read": "Pages read", + "Pagination": "Pagination", + "Portrait of {name}": "Portrait of {name}", + "Primary": "Primary", + "Progress through {title}": "Progress through {title}", + "Published": "Published", + "Published {date}": "Published {date}", + "Published with Ghost": "Published with Ghost", + "Rated {rating} out of 5": "Rated {rating} out of 5", + "Read": "Read", + "Read more about {title}": "Read more about {title}", + "Read the review": "Read the review", + "Reading": "Reading", + "Reading statistics": "Reading statistics", + "Recent favourites": "Recent favourites", + "Recent reviews": "Recent reviews", + "Reviewed by": "Reviewed by", + "Reviewer": "Reviewer", + "reviews": "reviews", + "Reviews": "Reviews", + "Search": "Search", + "Search by title, author or genre": "Search by title, author or genre", + "Search reviews": "Search reviews", + "See my reading log": "See my reading log", + "Series": "Series", + "Set aside for now": "Set aside for now", + "Skip to content": "Skip to content", + "Status": "Status", + "Stopped at page {page}": "Stopped at page {page}", + "Subscribe": "Subscribe", + "Thank you. Please check your inbox to confirm your subscription.": "Thank you. Please check your inbox to confirm your subscription.", + "The link may be old, or the page may have been moved or renamed. Try a search, or start again from the front page.": "The link may be old, or the page may have been moved or renamed. Try a search, or start again from the front page.", + "Theme by List of Books": "Theme by List of Books", + "This page has wandered off the shelf": "This page has wandered off the shelf", + "Up next": "Up next", + "Want to read": "Want to read", + "Website": "Website", + "You might also like": "You might also like", + "you@example.com": "you@example.com" +} diff --git a/ghost/package.json b/ghost/package.json new file mode 100644 index 0000000..dadf541 --- /dev/null +++ b/ghost/package.json @@ -0,0 +1,121 @@ +{ + "name": "readerly", + "description": "A theme for book blogs, author websites and reading logs, in a light style (Paper) and a dark style (Lamplight).", + "version": "1.0.0", + "license": "MIT", + "author": { + "name": "List of Books", + "email": "contact@listofbooks.net", + "url": "https://www.listofbooks.net/" + }, + "homepage": "https://www.listofbooks.net/themes/readerly", + "repository": { + "type": "git", + "url": "https://github.com/listofbooks-net/readerly-theme.git" + }, + "bugs": "https://github.com/listofbooks-net/readerly-theme/issues", + "keywords": ["ghost", "theme", "ghost-theme", "books", "book-reviews", "reading-log", "author", "dark-mode"], + "engines": { + "ghost": ">=6.0.0" + }, + "config": { + "posts_per_page": 9, + "image_sizes": { + "xs": { "width": 160 }, + "s": { "width": 320 }, + "m": { "width": 600 }, + "l": { "width": 960 }, + "xl": { "width": 1200 }, + "xxl": { "width": 2000 } + }, + "card_assets": true, + "custom": { + "color_scheme": { + "type": "select", + "options": ["Auto", "Paper", "Lamplight"], + "default": "Auto", + "description": "Paper is light and Lamplight is dark. Auto follows each reader's system setting." + }, + "style_toggle": { + "type": "boolean", + "default": true, + "description": "Show a button in the header that switches between Paper and Lamplight." + }, + "footer_about": { + "type": "text", + "description": "One or two sentences under the site title in the footer." + }, + "secondary_navigation_title": { + "type": "text", + "default": "Genres", + "description": "Heading of the secondary navigation in the footer." + }, + "copyright_note": { + "type": "text", + "description": "Text after the copyright line, for example: All reviews are my own." + }, + "intro_eyebrow": { + "type": "text", + "group": "homepage" + }, + "intro_heading": { + "type": "text", + "group": "homepage", + "description": "Wrap words in *asterisks* to set them in italics. Leave empty to hide the introduction." + }, + "intro_lead": { + "type": "text", + "group": "homepage" + }, + "intro_button_text": { + "type": "text", + "default": "Read the latest review", + "group": "homepage", + "description": "Links to your newest post. Leave empty to hide the button." + }, + "secondary_button_text": { + "type": "text", + "group": "homepage" + }, + "secondary_button_url": { + "type": "text", + "group": "homepage" + }, + "show_currently_reading": { + "type": "boolean", + "default": true, + "group": "homepage", + "description": "Books tagged #reading, when there are any." + }, + "show_genres": { + "type": "boolean", + "default": true, + "group": "homepage" + }, + "newsletter_eyebrow": { + "type": "text", + "group": "homepage" + }, + "newsletter_heading": { + "type": "text", + "default": "Get new reviews by email.", + "group": "homepage", + "description": "Shown when your site has signups turned on." + }, + "newsletter_note": { + "type": "text", + "group": "homepage" + }, + "show_related_reviews": { + "type": "boolean", + "default": true, + "group": "post" + }, + "show_reviewer_bio": { + "type": "boolean", + "default": true, + "group": "post" + } + } + } +} diff --git a/ghost/page.hbs b/ghost/page.hbs new file mode 100644 index 0000000..af00c0b --- /dev/null +++ b/ghost/page.hbs @@ -0,0 +1,26 @@ +{{!< default}} +{{#post}} +
+ {{#match @page.show_title_and_feature_image}} +
+ {{> "book/eyebrow"}} +

{{title}}

+ {{#if custom_excerpt}} +

{{custom_excerpt}}

+ {{/if}} +
+ {{/match}} + + {{> "book/panel"}} + {{#match @page.show_title_and_feature_image}}{{#if feature_image}} +
+ {{feature_image_alt}} + {{#if feature_image_caption}}
{{feature_image_caption}}
{{/if}} +
+ {{/if}}{{/match}} + +
+ {{content}} +
+
+{{/post}} diff --git a/ghost/partials/archive-list.hbs b/ghost/partials/archive-list.hbs new file mode 100644 index 0000000..504cc54 --- /dev/null +++ b/ghost/partials/archive-list.hbs @@ -0,0 +1,8 @@ + + {{pagination}} \ No newline at end of file diff --git a/ghost/partials/book/author.hbs b/ghost/partials/book/author.hbs new file mode 100644 index 0000000..4933521 --- /dev/null +++ b/ghost/partials/book/author.hbs @@ -0,0 +1 @@ +{{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}{{#if ../plain}}{{split name separator="#by:"}}{{else}}{{t "by {author}" author=(split name separator="#by:")}}{{/if}}{{/match}}{{/foreach}} \ No newline at end of file diff --git a/ghost/partials/book/badge.hbs b/ghost/partials/book/badge.hbs new file mode 100644 index 0000000..4cf40c0 --- /dev/null +++ b/ghost/partials/book/badge.hbs @@ -0,0 +1 @@ +{{#foreach tags visibility="internal"}}{{#match slug "hash-reading"}}{{t "Reading"}}{{else match slug "hash-read"}}{{t "Read"}}{{else match slug "hash-want-to-read"}}{{t "Want to read"}}{{else match slug "hash-did-not-finish"}}{{t "DNF"}}{{/match}}{{/foreach}} \ No newline at end of file diff --git a/ghost/partials/book/card-cover.hbs b/ghost/partials/book/card-cover.hbs new file mode 100644 index 0000000..89bdb3b --- /dev/null +++ b/ghost/partials/book/card-cover.hbs @@ -0,0 +1 @@ +{{#if link}}{{else}}
{{> "book/cover" described=true}}
{{/if}} \ No newline at end of file diff --git a/ghost/partials/book/card.hbs b/ghost/partials/book/card.hbs new file mode 100644 index 0000000..f65fc77 --- /dev/null +++ b/ghost/partials/book/card.hbs @@ -0,0 +1,40 @@ +{{#match variant "compact"}} +
"book/data"}}> + {{#if feature_image}}{{> "book/card-cover" link=link}}{{else}}{{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}{{> "book/card-cover" ../this link=../link}}{{/match}}{{/foreach}}{{/if}} +
+ <{{#if heading}}{{heading}}{{else}}h3{{/if}} class="book-card__title">{{#if link}}{{title}}{{else}}{{title}}{{/if}} + {{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}

{{split name separator="#by:"}}

{{/match}}{{/foreach}} + {{#has tag="#reading,#read,#want-to-read,#did-not-finish"}}
{{> "book/rating"}}{{> "book/badge"}}
{{else}}{{#foreach tags visibility="internal"}}{{#match name "~^" "#rating:"}}
{{> "book/stars" value=(split name separator="#rating:")}}
{{/match}}{{/foreach}}{{/has}} + {{> "book/progress"}} +
+
+{{else match variant "own"}} +
+ {{> "book/card-cover" link=true}} +
+ {{date published_at format="YYYY"}}{{#primary_tag}} · {{name}}{{/primary_tag}} +

{{title}}

+ {{#if custom_excerpt}} +

{{custom_excerpt}}

+ {{/if}} +
+ {{#foreach tags visibility="internal"}}{{#match name "~^" "#buy:"}}{{t "Buy"}} {{../title}}{{/match}}{{/foreach}} + {{t "Learn more"}} {{t "about {title}" title=title}} +
+
+
+{{else}} +
"book/data"}}> + {{#if feature_image}}{{> "book/card-cover" link=true}}{{else}}{{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}{{> "book/card-cover" ../this link=true}}{{/match}}{{/foreach}}{{/if}} +
+ {{#if featured}}{{t "Featured"}}{{#primary_tag}} · {{name}}{{/primary_tag}}{{else}}{{#primary_tag}}{{name}}{{/primary_tag}}{{/if}} + <{{#if heading}}{{heading}}{{else}}h3{{/if}} class="book-card__title">{{title}} + {{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}

{{t "by {author}" author=(split name separator="#by:")}}

{{/match}}{{/foreach}} + {{#foreach tags visibility="internal"}}{{#match name "~^" "#rating:"}}
{{> "book/stars" value=(split name separator="#rating:")}}
{{/match}}{{/foreach}} + {{#if blurb}} +

{{#if custom_excerpt}}{{custom_excerpt}}{{else}}{{excerpt words="40"}}{{/if}}

+ {{/if}} +

+
+
+{{/match}} \ No newline at end of file diff --git a/ghost/partials/book/cover.hbs b/ghost/partials/book/cover.hbs new file mode 100644 index 0000000..56a04b0 --- /dev/null +++ b/ghost/partials/book/cover.hbs @@ -0,0 +1 @@ +{{#if feature_image}}{{#if described}}{{#if feature_image_alt}}{{feature_image_alt}}{{else}}{{t {{else}}{{/if}} \ No newline at end of file diff --git a/ghost/partials/book/data.hbs b/ghost/partials/book/data.hbs new file mode 100644 index 0000000..d22c3ee --- /dev/null +++ b/ghost/partials/book/data.hbs @@ -0,0 +1 @@ +{{#foreach tags visibility="internal"}}{{#match name "~^" "#rating:"}} data-rating="{{split name separator="#rating:"}}"{{/match}}{{#match name "~^" "#pages:"}} data-pages="{{split name separator="#pages:"}}"{{/match}}{{/foreach}} \ No newline at end of file diff --git a/ghost/partials/book/eyebrow.hbs b/ghost/partials/book/eyebrow.hbs new file mode 100644 index 0000000..b649c07 --- /dev/null +++ b/ghost/partials/book/eyebrow.hbs @@ -0,0 +1 @@ +{{#foreach tags visibility="internal"}}{{#match name "~^" "#eyebrow:"}}{{split name separator="#eyebrow:"}}{{/match}}{{/foreach}} \ No newline at end of file diff --git a/ghost/partials/book/json-ld.hbs b/ghost/partials/book/json-ld.hbs new file mode 100644 index 0000000..85cc00f --- /dev/null +++ b/ghost/partials/book/json-ld.hbs @@ -0,0 +1,3 @@ +{{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}{{#foreach ../tags visibility="internal"}}{{#match name "~^" "#rating:"}} + +{{/match}}{{/foreach}}{{/match}}{{/foreach}} \ No newline at end of file diff --git a/ghost/partials/book/panel.hbs b/ghost/partials/book/panel.hbs new file mode 100644 index 0000000..0ef8da1 --- /dev/null +++ b/ghost/partials/book/panel.hbs @@ -0,0 +1,31 @@ +{{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}} + +{{/match}}{{/foreach}} \ No newline at end of file diff --git a/ghost/partials/book/progress.hbs b/ghost/partials/book/progress.hbs new file mode 100644 index 0000000..798f966 --- /dev/null +++ b/ghost/partials/book/progress.hbs @@ -0,0 +1 @@ +{{#has tag="#reading"}}{{#foreach tags visibility="internal"}}{{#match name "~^" "#on-page:"}}{{#foreach ../tags visibility="internal"}}{{#match name "~^" "#pages:"}}

{{t "Page {page} of {pages}" page=(split ../name separator="#on-page:") pages=(split name separator="#pages:")}}

{{/match}}{{/foreach}}{{/match}}{{/foreach}}{{/has}}{{#has tag="#did-not-finish"}}{{#foreach tags visibility="internal"}}{{#match name "~^" "#on-page:"}}

{{t "Stopped at page {page}" page=(split name separator="#on-page:")}}

{{/match}}{{/foreach}}{{/has}} \ No newline at end of file diff --git a/ghost/partials/book/rating.hbs b/ghost/partials/book/rating.hbs new file mode 100644 index 0000000..8c24af9 --- /dev/null +++ b/ghost/partials/book/rating.hbs @@ -0,0 +1 @@ +{{#foreach tags visibility="internal"}}{{#match name "~^" "#rating:"}}{{> "book/stars" value=(split name separator="#rating:") large=../large}}{{/match}}{{/foreach}} \ No newline at end of file diff --git a/ghost/partials/book/stars.hbs b/ghost/partials/book/stars.hbs new file mode 100644 index 0000000..6a9f197 --- /dev/null +++ b/ghost/partials/book/stars.hbs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ghost/partials/navigation.hbs b/ghost/partials/navigation.hbs new file mode 100644 index 0000000..98ec4b5 --- /dev/null +++ b/ghost/partials/navigation.hbs @@ -0,0 +1,7 @@ + + {{#foreach navigation}} + {{#if label}} +
  • {{label}}
  • + {{/if}} + {{/foreach}} + \ No newline at end of file diff --git a/ghost/partials/pagination.hbs b/ghost/partials/pagination.hbs new file mode 100644 index 0000000..4ddd78e --- /dev/null +++ b/ghost/partials/pagination.hbs @@ -0,0 +1,18 @@ +{{#match pages ">" 1}} + +{{/match}} \ No newline at end of file diff --git a/ghost/partials/sections/feature.hbs b/ghost/partials/sections/feature.hbs new file mode 100644 index 0000000..81134b1 --- /dev/null +++ b/ghost/partials/sections/feature.hbs @@ -0,0 +1,18 @@ +
    +
    +
    + {{#if feature_image}}{{else}}{{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}{{/match}}{{/foreach}}{{/if}} +
    + {{#if featured}}{{t "Featured review"}}{{else}}{{t "Latest review"}}{{/if}}{{#primary_tag}} · {{name}}{{/primary_tag}} +

    {{title}}

    + {{#foreach tags visibility="internal"}}{{#match name "~^" "#by:"}}

    {{t "by {author}" author=(split name separator="#by:")}}{{#foreach ../tags visibility="internal"}}{{#match name "~^" "#series:"}} · {{split name separator="#series:"}}{{/match}}{{/foreach}}

    {{/match}}{{/foreach}} + {{#foreach tags visibility="internal"}}{{#match name "~^" "#rating:"}}
    {{> "book/stars" value=(split name separator="#rating:") large=true}}
    {{/match}}{{/foreach}} + {{#if excerpt}} +

    {{#if custom_excerpt}}{{custom_excerpt}}{{else}}{{excerpt words="50"}}{{/if}}

    + {{/if}} +

    · {{reading_time}}

    + {{t "Read the review"}} {{> "site/icon" name="arrow-right"}} +
    +
    +
    +
    \ No newline at end of file diff --git a/ghost/partials/sections/genres.hbs b/ghost/partials/sections/genres.hbs new file mode 100644 index 0000000..9a57fad --- /dev/null +++ b/ghost/partials/sections/genres.hbs @@ -0,0 +1,15 @@ +{{#get "tags" limit="8" include="count.posts" order="count.posts desc" filter="visibility:public" as |genres|}}{{#if genres}} +
    +
    +
    +

    {{t "Browse by genre"}}

    +

    {{plural @root.pagination.total empty=(t "No reviews yet") singular=(t "% review so far") plural=(t "% reviews and counting")}}

    +
    + +
    +
    +{{/if}}{{/get}} \ No newline at end of file diff --git a/ghost/partials/sections/intro.hbs b/ghost/partials/sections/intro.hbs new file mode 100644 index 0000000..011c969 --- /dev/null +++ b/ghost/partials/sections/intro.hbs @@ -0,0 +1,25 @@ +{{#if @custom.intro_heading}} +
    +
    +
    + {{#if @custom.intro_eyebrow}} + {{@custom.intro_eyebrow}} + {{/if}} +

    {{#split @custom.intro_heading separator="*"}}{{#foreach this}}{{#if @even}}{{this}}{{else}}{{this}}{{/if}}{{/foreach}}{{/split}}

    + {{#if @custom.intro_lead}} +

    {{@custom.intro_lead}}

    + {{/if}} + {{#if @custom.intro_button_text}}{{#foreach posts limit="1"}} +
    + {{@custom.intro_button_text}} + {{#if @custom.secondary_button_text}}{{#if @custom.secondary_button_url}} + {{@custom.secondary_button_text}} + {{/if}}{{/if}} +
    + {{/foreach}}{{/if}} +
    +
    +
    +{{else}} +

    {{@site.title}}

    +{{/if}} \ No newline at end of file diff --git a/ghost/partials/sections/newsletter.hbs b/ghost/partials/sections/newsletter.hbs new file mode 100644 index 0000000..08ead25 --- /dev/null +++ b/ghost/partials/sections/newsletter.hbs @@ -0,0 +1,25 @@ +{{#if @site.members_enabled}}{{#unless @site.members_invite_only}}{{#unless @member}}{{#if @custom.newsletter_heading}} +
    +
    + +
    +
    +{{/if}}{{/unless}}{{/unless}}{{/if}} \ No newline at end of file diff --git a/ghost/partials/sections/reading-now-body.hbs b/ghost/partials/sections/reading-now-body.hbs new file mode 100644 index 0000000..5870999 --- /dev/null +++ b/ghost/partials/sections/reading-now-body.hbs @@ -0,0 +1,20 @@ +
    +
    +
    +

    {{t "Currently reading"}}{{#if show_count}} {{/if}}

    + {{#if show_log_link}}{{#get "pages" include="tags" filter="slug:reading-log" limit="1" as |log_pages|}}{{#foreach log_pages}}{{t "My reading log"}} {{> "site/icon" name="arrow-right"}}{{/foreach}}{{/get}}{{/if}} +
    +
      + {{#foreach shelf_posts}} +
    • + {{> "book/card" variant="compact" link=true}} +
    • + {{/foreach}} + {{#foreach shelf_pages}} +
    • + {{> "book/card" variant="compact" link=html}} +
    • + {{/foreach}} +
    +
    +
    \ No newline at end of file diff --git a/ghost/partials/sections/reading-now.hbs b/ghost/partials/sections/reading-now.hbs new file mode 100644 index 0000000..7467980 --- /dev/null +++ b/ghost/partials/sections/reading-now.hbs @@ -0,0 +1 @@ +{{#if shelf_posts}}{{> "sections/reading-now-body"}}{{else if shelf_pages}}{{> "sections/reading-now-body"}}{{/if}} \ No newline at end of file diff --git a/ghost/partials/sections/recent.hbs b/ghost/partials/sections/recent.hbs new file mode 100644 index 0000000..f9eeb6f --- /dev/null +++ b/ghost/partials/sections/recent.hbs @@ -0,0 +1,28 @@ +
    +
    +
    + {{#is "paged"}} +

    {{t "Reviews"}} {{t "Page {page} of {pages}" page=pagination.page pages=pagination.pages}}

    + {{else}} +

    {{t "Recent reviews"}}

    + {{#if pagination.next}}{{t "Older reviews"}} {{> "site/icon" name="arrow-right"}}{{/if}} + {{/is}} +
    +
      + {{#is "paged"}} + {{#foreach posts}} +
    • + {{> "book/card" blurb="clamp"}} +
    • + {{/foreach}} + {{else}} + {{#foreach posts from="2"}} +
    • + {{> "book/card" blurb="clamp"}} +
    • + {{/foreach}} + {{/is}} +
    + {{pagination}} +
    +
    \ No newline at end of file diff --git a/ghost/partials/sections/shelf-body.hbs b/ghost/partials/sections/shelf-body.hbs new file mode 100644 index 0000000..1681214 --- /dev/null +++ b/ghost/partials/sections/shelf-body.hbs @@ -0,0 +1,20 @@ +
    +
    +

    {{heading}}

    + {{#if note}} +

    {{note}}

    + {{/if}} +
    +
      + {{#foreach shelf_posts}} +
    • + {{> "book/card" variant="compact" link=true}} +
    • + {{/foreach}} + {{#foreach shelf_pages}} +
    • + {{> "book/card" variant="compact" link=html}} +
    • + {{/foreach}} +
    +
    \ No newline at end of file diff --git a/ghost/partials/sections/shelf.hbs b/ghost/partials/sections/shelf.hbs new file mode 100644 index 0000000..8e08420 --- /dev/null +++ b/ghost/partials/sections/shelf.hbs @@ -0,0 +1 @@ +{{#if shelf_posts}}{{> "sections/shelf-body"}}{{else if shelf_pages}}{{> "sections/shelf-body"}}{{/if}} \ No newline at end of file diff --git a/ghost/partials/site/credit.hbs b/ghost/partials/site/credit.hbs new file mode 100644 index 0000000..844e601 --- /dev/null +++ b/ghost/partials/site/credit.hbs @@ -0,0 +1 @@ +

    {{t "Published with Ghost"}} · {{t "Theme by List of Books"}}

    \ No newline at end of file diff --git a/ghost/partials/site/footer.hbs b/ghost/partials/site/footer.hbs new file mode 100644 index 0000000..e7ef051 --- /dev/null +++ b/ghost/partials/site/footer.hbs @@ -0,0 +1,28 @@ +
    +
    + + +
    +
    \ No newline at end of file diff --git a/ghost/partials/site/header.hbs b/ghost/partials/site/header.hbs new file mode 100644 index 0000000..223665d --- /dev/null +++ b/ghost/partials/site/header.hbs @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/ghost/partials/site/icon.hbs b/ghost/partials/site/icon.hbs new file mode 100644 index 0000000..153a00d --- /dev/null +++ b/ghost/partials/site/icon.hbs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ghost/partials/site/search-form.hbs b/ghost/partials/site/search-form.hbs new file mode 100644 index 0000000..0978b6e --- /dev/null +++ b/ghost/partials/site/search-form.hbs @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/ghost/post.hbs b/ghost/post.hbs new file mode 100644 index 0000000..b96394b --- /dev/null +++ b/ghost/post.hbs @@ -0,0 +1,77 @@ +{{!< default}} +{{#post}} +
    +
    +
    + {{#if primary_tag}} +
      + {{#foreach tags}} +
    • {{name}}
    • + {{/foreach}} +
    + {{/if}} +

    {{title}}

    + {{#if custom_excerpt}} +

    {{custom_excerpt}}

    + {{/if}} + +
    + + {{> "book/panel"}} + {{#if feature_image}} +
    + {{feature_image_alt}} + {{#if feature_image_caption}}
    {{feature_image_caption}}
    {{/if}} +
    + {{/if}} + +
    + {{content}} +
    + + {{#if @custom.show_reviewer_bio}}{{#primary_author}}{{#if bio}} + + {{/if}}{{/primary_author}}{{/if}} + + {{#if @custom.show_related_reviews}}{{#if primary_tag}} + {{#get "posts" include="tags,authors" filter="tags:{{primary_tag.slug}}+id:-{{id}}" limit="3" as |related|}}{{#if related}} +
    +
    + + {{#primary_tag}}{{t "More in {genre}" genre=name}} {{> "site/icon" name="arrow-right"}}{{/primary_tag}} +
    + +
    + {{/if}}{{/get}} + {{/if}}{{/if}} + + {{#if comments}} +
    +
    +

    {{t "Comments"}}

    +
    + {{comments title="" count=false}} +
    + {{/if}} +
    +
    +{{> "book/json-ld"}} +{{/post}} diff --git a/ghost/tag.hbs b/ghost/tag.hbs new file mode 100644 index 0000000..be24d8c --- /dev/null +++ b/ghost/tag.hbs @@ -0,0 +1,21 @@ +{{!< default}} +
    + {{#tag}} +
    + {{t "Genre"}} +

    {{name}}

    + {{#if description}} +

    {{description}}

    + {{/if}} +

    {{plural ../pagination.total empty=(t "No reviews") singular=(t "% review") plural=(t "% reviews")}}{{#match ../pagination.pages ">" 1}} · {{t "Page {page} of {pages}" page=../pagination.page pages=../pagination.pages}}{{/match}}

    + {{#get "tags" filter="visibility:public+slug:-{{slug}}" include="count.posts" order="count.posts desc" limit="6" as |other_tags|}}{{#if other_tags}} +
      + {{#foreach other_tags}}{{#match count.posts ">" 0}} +
    • {{name}}
    • + {{/match}}{{/foreach}} +
    + {{/if}}{{/get}} +
    + {{/tag}} + {{> "archive-list"}} +
    diff --git a/tools/build-tokens.mjs b/tools/build-tokens.mjs index 80292a6..53c2391 100644 --- a/tools/build-tokens.mjs +++ b/tools/build-tokens.mjs @@ -289,6 +289,19 @@ const outputs = [ ...mirrors.flatMap((m) => m.copies), ]; +// The Ghost theme (ghost/) ships the same stylesheet and script as Jekyll, plus +// its own ghost.css for Koenig cards and members forms, which is not generated. +const ghostMirrors = [ + mirror('design/assets/fonts', 'ghost/assets/fonts'), + mirror('design/assets/img', 'ghost/assets/img', ['paper-grain.svg', 'cover-grain.svg']), +]; +mirrors.push(...ghostMirrors); +outputs.push( + ['ghost/assets/css/readerly.css', () => buildJekyllCss().replace('Readerly for Jekyll.', 'Readerly for Ghost.')], + ['ghost/assets/js/theme.js', () => readFileSync(join(root, 'design/assets/js/theme.js'))], + ...ghostMirrors.flatMap((m) => m.copies), +); + const check = process.argv.includes('--check'); const stale = []; for (const [path, build] of outputs) { diff --git a/tools/ghost-locales.mjs b/tools/ghost-locales.mjs new file mode 100644 index 0000000..1fd5726 --- /dev/null +++ b/tools/ghost-locales.mjs @@ -0,0 +1,25 @@ +#!/usr/bin/env node +// Writes ghost/locales/en.json from every {{t "..."}} string in the Ghost theme's templates, +// so the English file always holds exactly the strings the theme prints. +// Usage: node tools/ghost-locales.mjs [--check] (--check writes nothing and exits 1 when stale) +import { readFileSync, readdirSync, writeFileSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const theme = join(dirname(fileURLToPath(import.meta.url)), '../ghost'); +const templates = (dir) => + readdirSync(dir, { withFileTypes: true }).flatMap((entry) => + entry.isDirectory() ? (entry.name === 'assets' ? [] : templates(join(dir, entry.name))) : entry.name.endsWith('.hbs') ? [join(dir, entry.name)] : [], + ); +const strings = new Set(templates(theme).flatMap((file) => [...readFileSync(file, 'utf8').matchAll(/[({]t "([^"]+)"/g)].map((m) => m[1]))); +const next = `${JSON.stringify(Object.fromEntries([...strings].sort((a, b) => a.localeCompare(b)).map((s) => [s, s])), null, '\t')}\n`; +const file = join(theme, 'locales/en.json'); +if (readFileSync(file, 'utf8') === next) { + console.log('ghost/locales/en.json is up to date.'); +} else if (process.argv.includes('--check')) { + console.error('ghost/locales/en.json is out of date (run node tools/ghost-locales.mjs)'); + process.exit(1); +} else { + writeFileSync(file, next); + console.log(`Wrote ghost/locales/en.json (${strings.size} strings)`); +} From bb99a94bed4b9a4935eff78583f2365bf5bb8ed5 Mon Sep 17 00:00:00 2001 From: Lai Hung <19669099+phoduke@users.noreply.github.com> Date: Thu, 12 Nov 2026 14:35:14 +0700 Subject: [PATCH 05/14] docs(ghost): add the theme README and license --- ghost/LICENSE | 24 +++++++ ghost/README.md | 170 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 ghost/LICENSE create mode 100644 ghost/README.md diff --git a/ghost/LICENSE b/ghost/LICENSE new file mode 100644 index 0000000..79e7e12 --- /dev/null +++ b/ghost/LICENSE @@ -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. diff --git a/ghost/README.md b/ghost/README.md new file mode 100644 index 0000000..25b499a --- /dev/null +++ b/ghost/README.md @@ -0,0 +1,170 @@ +# Readerly for Ghost + +Readerly is a free Ghost theme for people who love books. It is built for a book blog first, and it also gives you a reading log and an author website. It comes in two styles, Paper (light) and Lamplight (dark), and bundles its fonts, Fraunces and Literata, so it loads no fonts from other servers. + +- Demo: Marginalia, a book blog by the fictional reviewer Nora Vale. +- Requires Ghost 6.0 or later. +- License: MIT. The fonts are under the SIL Open Font License (`assets/fonts/*/OFL.txt`). + +## Install + +1. Download `readerly-ghost-.zip`. +2. In Ghost Admin, go to **Settings > Design & branding > Change theme > Upload theme** and select the zip file. +3. Click **Activate**. + +The theme works with any existing Ghost content. Every section that needs book data shows nothing until you add that data. + +## Theme settings + +Go to **Settings > Design & branding > Customize**. + +| Setting | Group | What it does | +| --- | --- | --- | +| Color scheme | Site-wide | Paper, Lamplight, or Auto (follows the reader's system setting). | +| Style toggle | Site-wide | Shows a button in the header that switches between Paper and Lamplight. | +| Footer about | Site-wide | One or two sentences under the site title in the footer. | +| Secondary navigation title | Site-wide | The heading of the secondary navigation in the footer. The default is "Genres". | +| Copyright note | Site-wide | Text after the copyright line. | +| Intro eyebrow, heading, lead | Homepage | The introduction at the top of the home page. Put words in `*asterisks*` to set them in italics. An empty heading hides the introduction. | +| Intro button text | Homepage | A button that links to your newest post. | +| Secondary button text and URL | Homepage | A second button, for example to your reading log. | +| Show currently reading | Homepage | Shows books tagged `#reading`. | +| Show genres | Homepage | Shows your tags with the number of posts in each. | +| Newsletter eyebrow, heading, note | Homepage | The signup section. It shows only when your site lets visitors sign up. | +| Show related reviews | Post | Shows up to three posts with the same primary tag. | +| Show reviewer bio | Post | Shows the author's bio card when the author has a bio. | + +Ghost's own settings also apply: the site title, description (shown as the tagline), logo, icon, accent color, navigation, secondary navigation, and the heading and body fonts under **Typography**. + +## Write a book review + +A review is an ordinary Ghost post. + +- **Cover**: the post's feature image. Add alt text, for example "Cover of The Salt Orchard by Mira Hollis". +- **Summary**: the post's excerpt. It shows under the title and on cards. +- **Genre**: the first public tag. It is the post's primary tag. Add more public tags for series, themes and so on. +- **Book facts**: internal tags, which start with `#`. Readers never see the tags themselves; the theme reads them. + +| Internal tag | Example | Shows | +| --- | --- | --- | +| `#by:` | `#by:Mira Hollis` | "by Mira Hollis" on cards and in the book panel. A post with this tag is a book review. | +| `#rating:<0.5 to 5>` | `#rating:4.5` | Stars on cards, in the book panel, and in the Review structured data. Half stars are allowed. | +| `#series:` | `#series:The Tidewater Books · Book 2 of 3` | A Series row in the book panel. | +| `#pages:` | `#pages:384` | A Pages row, the reading progress bar, and the pages count on the reading log. | +| `#published:` | `#published:2026 · Harrow & Lane` | A Published row in the book panel. | +| `#on-page:` | `#on-page:142` | With `#reading` and `#pages`, the reading progress bar. | +| `#reading`, `#read`, `#want-to-read`, `#did-not-finish` | `#read` | A status badge, and the shelf on your reading log. | + +Ghost's tag field treats a comma as the end of a tag, so do not use commas inside a tag. Use ` · ` instead. + +A post with `#by:` shows a book panel with the cover and the facts. A post without it shows its feature image as a normal header image. A book without a cover image gets a typeset placeholder cover. + +Mark a post as featured to label it "Featured" on cards and on the home page. + +### Verdict, pull quote and other review blocks + +Readerly styles Ghost's cards: images (normal, wide and full width), galleries, bookmarks, embeds, callouts, toggles, buttons, products, headers, files, audio, video and the alternative blockquote style. For the design's verdict box and pull quote, add an **HTML** card with this markup. Save it as a snippet to reuse it. + +```html +
    +
    +

    My verdict

    +
    +
    +

    Patient, precise and quietly devastating.

    +
    +

    What worked

    • The orchard as a living clock
    +

    Less so

    • A too-tidy ending
    +
    +
    +``` + +```html +
    +

    “Grief is a ledger you keep in pencil.”

    +
    The Salt Orchard, chapter nine
    +
    +``` + +## Add a reading log + +1. Create a page with the slug `reading-log`. +2. In the page settings, set **Template** to **Reading log**. +3. Optional: add the internal tag `#eyebrow:Reading journal` for the small label above the title, and an excerpt for the text under it. + +The page lists every post and page tagged `#reading`, `#read`, `#want-to-read` and `#did-not-finish`, and shows your number of books read, pages read, average rating and books not finished. The home page links to this page from its "Currently reading" section, and the 404 page links to it too. + +For a book you have not reviewed, create a **page** instead of a post: title, feature image (the cover), and the same internal tags. Pages stay out of your home page, your RSS feed and your email newsletter. Write something in the page body to make the book's card a link to the page. + +## Add an author website + +For authors who want to present their own books: + +1. Create a page, for example with your name as the title. Set **Template** to **Author site**. Its feature image is your portrait, its excerpt is the text under your name, and `#eyebrow:Novelist` sets the label above it. +2. Create a page for each of your books. Tag it `#book`, give it a public tag for the kind of book (for example "Novel"), set its publish date to the book's publication date, and add `#pages:` and `#buy:` if you like. Mark your newest book as featured to show it as the new release. +3. Anything you write in the author page's body shows below your books. For quotes from reviews and for events, add HTML cards with this markup: + +```html +
    +
    +

    Kind words

    +
      +
    • +

      “A novel that rings long after you close it.”

      +
      The Northern Review on The Bell Foundry
      +
    • +
    +
    +
    +``` + +```html +
    +
    +

    Events

    +
      +
    • + +
      +

      In conversation: The Bell Foundry

      +

      Wren & Ash Books, York · 7 pm

      +
      + Book a place +
    • +
    +
    +
    +``` + +The newsletter signup section follows when your site lets visitors sign up. + +## Search, members, newsletters and comments + +- **Search**: the search box in the header and on the 404 page opens Ghost's built-in search. +- **Signups**: the newsletter section is a Ghost signup form. It shows when **Settings > Membership** lets visitors sign up and the reader is not signed in. +- **Comments**: when you turn on comments in **Settings > Membership**, they show under each post. +- **Paid content**: Ghost shows its own call to action in place of content a reader cannot access. + +## Templates + +| Template | Used for | +| --- | --- | +| `index.hbs` | The home page and its later pages | +| `post.hbs` | Posts | +| `page.hbs` | Pages, including book pages; it respects "Show title and feature image" | +| `custom-reading-log.hbs` | Template "Reading log" | +| `custom-author-site.hbs` | Template "Author site" | +| `tag.hbs`, `author.hbs` | Tag and author archives | +| `error-404.hbs`, `error.hbs` | Not found and other errors | + +## Translate the theme + +Every interface string is in `locales/en.json`. Copy it to `locales/.json`, translate the values, and set the publication language under **Settings > General**. + +## The footer credit + +The footer says "Published with Ghost" and "Theme by List of Books", with a link to https://www.listofbooks.net/. Both are in `partials/site/credit.hbs`. We ask that you keep the credit; it is how a free theme pays for itself. + +## Develop + +The theme's source lives in the repository https://github.com/listofbooks-net/readerly-theme. `assets/css/readerly.css`, `assets/js/theme.js`, the fonts and the grain images are generated from its `design/` folder, so change them there. `assets/css/ghost.css`, `assets/js/books.js` and the templates are edited here. From 5be2ff1b14347e945c5894a05a53a73fad966303 Mon Sep 17 00:00:00 2001 From: Lai Hung <19669099+phoduke@users.noreply.github.com> Date: Thu, 12 Nov 2026 14:35:34 +0700 Subject: [PATCH 06/14] docs: list the Ghost port in the README --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 44cff31..711d8bd 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 From 59d03b94df7d5bace45ea7e20185f92a080729a8 Mon Sep 17 00:00:00 2001 From: Lai Hung <19669099+phoduke@users.noreply.github.com> Date: Thu, 12 Nov 2026 14:37:58 +0700 Subject: [PATCH 07/14] feat(ghost-dev): build the Ghost theme zip, publish the demo, and add the ghost CI job --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++++++ tools/build-ghost-zip.sh | 31 ++++++++++++++++++++++++++++ tools/ghost-dev/check.mjs | 3 ++- tools/ghost-dev/pages.json | 1 + tools/publish-ghost-demo.sh | 35 +++++++++++++++++++++++++++++++ tools/wp-dev/check-pages.cjs | 6 +++++- 6 files changed, 114 insertions(+), 2 deletions(-) create mode 100755 tools/build-ghost-zip.sh create mode 100755 tools/publish-ghost-demo.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fd3fd4..614cdb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,3 +112,43 @@ 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: | + docker rm -f readerly-ghost-dev >/dev/null 2>&1 || true + docker volume rm readerly-ghost-dev-content >/dev/null 2>&1 || true + docker network rm "$GHOST_NETWORK" >/dev/null 2>&1 || true diff --git a/tools/build-ghost-zip.sh b/tools/build-ghost-zip.sh new file mode 100755 index 0000000..c3cbc54 --- /dev/null +++ b/tools/build-ghost-zip.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Builds the distributable Ghost theme zip: the contents of ghost/ inside a +# top-level readerly/ folder, ready for Ghost Admin > Settings > Design > Change theme > Upload theme. +# +# tools/build-ghost-zip.sh writes dist/readerly-ghost-.zip and prints its path +# +# Only files below ghost/ go in; the design reference, tools and harness never +# ship. Dotfiles, node_modules and editor and OS leftovers are excluded. +set -euo pipefail + +repo="$(cd "$(dirname "$0")/.." && pwd)" +theme="$repo/ghost" +version="$(sed -n 's/^[[:space:]]*"version":[[:space:]]*"\([^"]*\)".*/\1/p' "$theme/package.json" | head -n1)" +[[ -n "$version" ]] || { echo "no version in ghost/package.json" >&2; exit 1; } + +for required in package.json default.hbs index.hbs post.hbs; do + [[ -f "$theme/$required" ]] || { echo "missing ghost/$required" >&2; exit 1; } +done + +out="$repo/dist/readerly-ghost-$version.zip" +stage="$(mktemp -d)" +trap 'rm -rf "$stage"' EXIT + +mkdir -p "$repo/dist" "$stage/readerly" +cp -R "$theme/." "$stage/readerly/" +find "$stage/readerly" -depth \( -name '.*' -o -name node_modules -o -name 'Thumbs.db' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -o -name '*.log' -o -name '*.map' \) -exec rm -rf {} + + +rm -f "$out" +# -X drops extra file attributes and -D skips directory entries, so the zip holds only files. +(cd "$stage" && find readerly -type f | LC_ALL=C sort | zip -qXD "$out" -@) +echo "$out" diff --git a/tools/ghost-dev/check.mjs b/tools/ghost-dev/check.mjs index c933144..79f61ef 100644 --- a/tools/ghost-dev/check.mjs +++ b/tools/ghost-dev/check.mjs @@ -53,7 +53,8 @@ async function parity() { const response = await fetch(site + path); const expected = file === '404.html' ? 404 : 200; if (response.status !== expected) failures.push(`${file}: ${path} answered ${response.status}, expected ${expected}`); - const siteHtml = await response.text(); + // Ghost adds a class per page, tag and author to body; the design's body has none. + const siteHtml = (await response.text()).replace(/]*>/, ''); const designHtml = readFileSync(join(repo, 'design', file), 'utf8'); const problems = []; compare(body(designHtml, file, 'design', exceptions), body(siteHtml, file, 'demo', exceptions), '', problems); diff --git a/tools/ghost-dev/pages.json b/tools/ghost-dev/pages.json index fd8ad03..56c6873 100644 --- a/tools/ghost-dev/pages.json +++ b/tools/ghost-dev/pages.json @@ -16,5 +16,6 @@ }, "notFound": ["404"], "colorScheme": { "paper": "light", "lamplight": "dark" }, + "allowFailed": ["/members/api/member/"], "allowThirdParty": ["https://cdn.jsdelivr.net/ghost/"] } diff --git a/tools/publish-ghost-demo.sh b/tools/publish-ghost-demo.sh new file mode 100755 index 0000000..a68923e --- /dev/null +++ b/tools/publish-ghost-demo.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Publishes the static Ghost demo (the Marginalia site) that the Ghost Marketplace listing links to. +# +# tools/publish-ghost-demo.sh [public url] default: https://readerly-ghost-demo.pages.dev +# +# 1. Checks that the tree is clean and on main, equal to origin/main after a fetch. +# 2. Starts Ghost with the theme and the demo content, runs every check +# (tools/ghost-dev/ghost-dev.sh check), and exports the static copy for the public URL, +# which export-static.mjs verifies in a browser. +# 3. Uploads the copy to the Cloudflare Pages project readerly-ghost-demo with wrangler. +# +# Uploading changes a public site and the Marketplace listing points at it, so only an operator +# runs this, by hand, and wrangler must already be logged in (wrangler login). +set -euo pipefail + +public="${1:-https://readerly-ghost-demo.pages.dev}" +repo="$(cd "$(dirname "$0")/.." && pwd)" +cd "$repo" + +[[ -z "$(git status --porcelain)" ]] || { echo "the working tree is not clean" >&2; exit 1; } +[[ "$(git branch --show-current)" == main ]] || { echo "publish from main" >&2; exit 1; } +git fetch --quiet origin main +[[ "$(git rev-parse HEAD)" == "$(git rev-parse origin/main)" ]] || { echo "HEAD is not origin/main; pull or push first" >&2; exit 1; } + +node tools/build-tokens.mjs --check +tools/ghost-dev/ghost-dev.sh gscan +tools/ghost-dev/ghost-dev.sh up +tools/ghost-dev/ghost-dev.sh check + +stage="$(mktemp -d)" +trap 'rm -rf "$stage"; tools/ghost-dev/ghost-dev.sh down' EXIT +tools/ghost-dev/ghost-dev.sh export "$stage/site" "$public" + +npx --yes wrangler pages deploy "$stage/site" --project-name readerly-ghost-demo +echo "Published the demo to $public." diff --git a/tools/wp-dev/check-pages.cjs b/tools/wp-dev/check-pages.cjs index 7902171..c150eb9 100644 --- a/tools/wp-dev/check-pages.cjs +++ b/tools/wp-dev/check-pages.cjs @@ -10,6 +10,7 @@ // mobileMenu { open, panel, close } selectors of a menu toggle to exercise at 390 px // colorScheme {