build: setting up mfgames-writing

This commit is contained in:
D. Moonfire 2022-08-01 10:38:27 -05:00
parent c559e0dcd9
commit 324d8f140d
26 changed files with 583 additions and 173 deletions

26
.editorconfig Normal file
View File

@ -0,0 +1,26 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 80
tab_width = 4
trim_trailing_whitespace = true
[*.{js,ts}]
quote_type = double
[*.yaml]
indent_size = 4
tab_width = 4
indent_style = space
[package.json]
indent_size = 2
tab_width = 2

2
.envrc Normal file
View File

@ -0,0 +1,2 @@
export PATH=$PWD/scripts:$PWD/node_modules/.bin:$PATH
use flake || use nix

18
.gitignore vendored
View File

@ -1,7 +1,13 @@
node_modules/
*.epub
*.mobi
*.pdf
*.docx
*~
dmoonfire*
node_modules/
.direnv/
tmp/
build/
.*-swp
dmoonfire*.pdf
dmoonfire*.docx
dmoonfire*.html
dmoonfire*.mobi
dmoonfire*.epub
*.bz2

View File

@ -1,29 +1,19 @@
image: dmoonfire/mfgames-writing-js:2.0.0
stages:
- publish
- build
- test
- release
publish:
stage: publish
only: [master]
tags: [docker]
default:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
build:
stage: build
script:
# Install the basic requirements including the free fonts.
- npm ci
# Verify that the commits are good.
- npx commitlint --from=$CI_BUILD_BEFORE_SHA
# We need the cover from the general repository.
- mkdir -p build/repos
- git clone https://oauth2:$fedranAccessKey@gitlab.com/fedran/fedran-covers.git build/repos/fedran-covers
# Trigger the release if needed.
- npx semantic-release
# Build the files.
- npm run upload
- nix profile install 'nixpkgs#fontconfig'
- nix develop --command scripts/setup.sh
- nix develop --command scripts/build.sh
rules:
- if: $CI_COMMIT_BRANCH
artifacts:
expire_in: 1 week
paths:
@ -32,3 +22,28 @@ publish:
- "*.mobi"
- "*.docx"
- "*.html"
test:
stage: test
script:
- nix develop --command scripts/setup.sh
- nix develop --command scripts/test.sh
rules:
- if: $CI_COMMIT_BRANCH
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
release:
stage: release
script:
- nix profile install 'nixpkgs#fontconfig'
- nix develop --command scripts/setup.sh
- nix develop --command scripts/release.sh
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
artifacts:
paths:
- "*.pdf"
- "*.epub"
- "*.mobi"
- "*.docx"
- "*.html"

17
.prettierignore Normal file
View File

@ -0,0 +1,17 @@
CHANGELOG.md
package-lock.json
yarn.lock
*~
archives/
build/
extras/
others/
node_modules/
submissions/
sample-edits/
maps/
.direnv/
tmp/
edit/

6
commitlint.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"body-max-line-length": [0],
},
};

58
flake.lock Normal file
View File

@ -0,0 +1,58 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1643805626,
"narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "554d2d8aa25b6e583575459c297ec23750adb6cb",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixstable": {
"locked": {
"lastModified": 1622516815,
"narHash": "sha256-ZjBd81a6J3TwtlBr3rHsZspYUwT9OdhDk+a/SgSEf7I=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7e9b0dff974c89e070da1ad85713ff3c20b0ca97",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "21.05",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nixstable": "nixstable"
}
}
},
"root": "root",
"version": 7
}

30
flake.nix Normal file
View File

@ -0,0 +1,30 @@
{
description = ""Flight of the Scions" is a novel by D. Moonfire.";
inputs = {
nixstable.url = "nixpkgs/21.05";
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixstable, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
stable = nixstable.legacyPackages.${system};
in {
devShell = pkgs.mkShell {
buildInputs = [
pkgs.epubcheck
pkgs.nixfmt
pkgs.nodejs-16_x
pkgs.pandoc
pkgs.pdftk
pkgs.python39Full
pkgs.python39Packages.weasyprint
pkgs.jq
pkgs.s3cmd
];
};
});
}

11
matter/about.md Normal file
View File

@ -0,0 +1,11 @@
---
title: About D. Moonfire
---
D. Moonfire is the remarkable intersection of a computer nerd and a scientist. He inherited a desire for learning, endless curiosity, and a talent for being a polymath from both of his parents. Instead of focusing on a single genre, he writes stories and novels in many different settings ranging from fantasy to science fiction. He also throws in the occasional romance or forensics murder mystery to mix things up.
In addition to having a borderline unhealthy obsession with the written word, he is also a developer who loves to code as much as he loves writing.
He lives near Cedar Rapids, Iowa with his wife, numerous pet computers, and a pair of highly mobile things of the male variety.
You can see more work by D. Moonfire at his website at [https://d.moonfire.us/](https://d.moonfire.us/). His fantasy world, Fedran, can be found at [https://fedran.com/](https://fedran.com/).

11
matter/colophon.md Normal file
View File

@ -0,0 +1,11 @@
---
title: Colophon
---
Each chapter of this book was written as plain text files formatted with Markdown and include a YAML header at the top of each one. These files are managed in a Git repository located on [https://gitlab.com/fedran/flight-of-the-scions/](https://src.mfgames.com/fedran/flight-of-the-scions/). Emacs and Atom were used as the primary environment for writing.
These individual chapters were combined together using a TypeScript-based publication framework called MfGames Writing, a set of tools for converting those files into PDF (via WeasyPrint), EPUB, and MOBI.
The cover was created using Inkscape and TypeScript. The color scheme uses eight shades of a single color and an another eight of the color's complementary. These colors are shared among all of the Kanéko novels. Likewise, the "0047-00" along the spine indicates this is the first published book ("00") with Kanéko as the main character ("0047").
The font used on the cover and interior is Source Serif Pro in various weights and styles.

31
matter/credits.md Normal file
View File

@ -0,0 +1,31 @@
---
title: Credits
---
This is a book I've been working on for over twenty years. It has gone through so many iterations and readers that I've been unable to document them all to give them proper credit. For all those people, credits and not, thank you for helping me see this book to fruition.
## Alpha Readers
| ---------- | --------- | ---------- | ---------
| Aimee K. | bil J. | Bill H. | Brent M.
| Cassie M. | Ciuin | Dylan B. | Evelyn C.
| George D. | Greg H. | Greg T. | Kelsey L.
| Kris P. | Laura W. | Mark H. | Mary J.
| Nathan S. | Nick T. | Phyllis R. | Riley O.
| Shannon R. | Stacie S. | Stacy | Steve W.
| Tony M. | Tyree C. | Uriah |
## Editors
| ---------- | --------- | ---------- | ---------
| Shannon Ryan || Sarah Chorn ||
## Beta Readers
| ---------- | --------- | ---------- | ---------
| Marta B. | Mike K. | Randy R. ||
## Sensitivity Readers
| ---------- | --------- | ---------- | ---------
| Teri C. ||||

13
matter/fedran.md Normal file
View File

@ -0,0 +1,13 @@
---
title: Fedran
---
Fedran is a world caught on the cusp of two great ages.
For centuries, the Crystal Age shaped society through the exploration of magic. Every creature had the ability to affect the world using talents and spells. The only limitation was imagination, will, and the inescapable rules of resonance. But as society grew more civilized, magic became less reliable and weaker.
When an unexpected epiphany seemingly breaks the laws of resonance, everything changed. Artifacts no longer exploded when exposed to spells, but only if they were wrapped in cocoons of steel and brass. The humble fire rune becomes the fuel for new devices, ones powered by steam and pressure. These machines herald the birth of a new age, the Industrial Age.
Now, the powers of the old age struggle against the onslaught of new technologies and an alien way of approaching magic. Either the world will adapt or it will be washed away in the relentless march of innovation.
To explore the world of Fedran, check out [https://fedran.com/](https://fedran.com/). There you'll find stories, novels, character write-ups and more.

32
matter/license.md Normal file
View File

@ -0,0 +1,32 @@
---
title: License
---
This book is distributed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license. More info can be found at [https://creativecommons.org/licenses/by-nc-sa/4.0/](https://creativecommons.org/licenses/by-nc-sa/4.0/). This means:
### You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
### Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- NonCommercial — You may not use the material for commercial purposes.
- ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
### Preferred Attribution
The preferred attribution for this novel is:
> "Flight of the Scions" by D. Moonfire is licensed under CC BY-NC-SA 4.0
In the above attribution, use the following links:
- Flight of the Scions: [https://fedran.com/flight-of-the-scions/](https://fedran.com/flight-of-the-scions/)
- D. Moonfire: https://d.moonfire.us/
- CC BY-NC-SA 4.0: https://creativecommons.org/licenses/by-nc-sa/4.0/

29
matter/lorban.html Normal file
View File

@ -0,0 +1,29 @@
---
title: Lorban
---
<p>
This novel is set in the Kormar countryside where the native language is
Lorban. This is notionally translated into English, but there are certain
quirks of the language that stand being called out.
</p>
<ul>
<li>Lorban is roughly based on a casual form of Lojban.</li>
<li>
Names rarely start or end with vowels and native speakers have trouble
with Miwāfu vowel endings.
</li>
<li>
Lorban is accentless which causes trouble with Miwāfu array of tones.
</li>
<li>
The letter &ldquo;c&rdquo; is soft and always pronounced as
&ldquo;sh&rdquo; in &ldquo;shape.&rdquo;
</li>
</ul>
<p>
Lorban has no capital letters, they are added to satisfy English
conventions.
</p>

1
matter/pad.html Normal file
View File

@ -0,0 +1 @@
<br />

View File

@ -17,74 +17,51 @@
"scripts": {
"build:pdf": "mfgames-writing-format build pdf",
"build:epub": "mfgames-writing-format build epub",
"build": "npm run build:epub && npm run build:mobi && npm run build:pdf",
"build:extended": "npm run build && npm run build:html && npm run build:docx",
"build:docx": "sed 's@&#173;@@g' < dmoonfire-$npm_package_fedran_pov-$npm_package_fedran_vol-$npm_package_name-$npm_package_version.html | pandoc -f html -t docx -o dmoonfire-$npm_package_fedran_pov-$npm_package_fedran_vol-$npm_package_name-$npm_package_version.docx",
"build:mobi": "kindlegen dmoonfire-$npm_package_fedran_pov-$npm_package_fedran_vol-$npm_package_name-$npm_package_version.epub",
"build:html": "mfgames-writing-format build html",
"prebuild:mobi": "npm run build:epub",
"prebuild": "rm -f $npm_package_name-*.* $npm_package_name.tar.bz2",
"build:docx": "mfgames-writing-format build docx",
"build": "run-s build:*",
"prebuild": "npm run format",
"bundle": "tar -cjf $npm_package_name.tar.bz2 *.epub *.pdf",
"prebundle": "npm run build",
"upload": "aws --endpoint-url https://$AWS_ENDPOINT s3 cp --acl public-read $npm_package_name.tar.bz2 s3://$AWS_BUCKET/$npm_package_name.tar.bz2",
"preupload": "npm run bundle",
"lint": "fedran-lint --require-teaser"
"test:epubcheck": "epubcheck *.epub",
"prepare": "husky install",
"format": "run-s format:*",
"format:prettier": "prettier . --write --loglevel warn",
"format:nix": "nixfmt flake.nix",
"test": "run-s test:*",
"test:commits": "commitlint-gitlab-ci -x @commitlint/config-conventional"
},
"dependencies": {
"@fedran/lint": "^0.1.0",
"@fedran/writing-hyphen": "^1.0.0",
"@fedran/writing-theme": "^3.0.5",
"@mfgames-writing/epub2": "^1.1.8",
"@mfgames-writing/format": "^1.2.2",
"@mfgames-writing/guillemet-pipeline": "^1.0.6",
"@mfgames-writing/html": "^0.1.6",
"@mfgames-writing/hyphen": "^0.4.8",
"@mfgames-writing/weasyprint": "^4.0.6",
"commitlint": "^8.3.5"
"@fedran/writing-theme": "^4.0.2",
"@mfgames-writing/contracts": "^4.4.0",
"@mfgames-writing/docx-format": "^1.0.2",
"@mfgames-writing/epub2-format": "^2.1.1",
"@mfgames-writing/format": "^3.3.1",
"@mfgames-writing/guillemet": "^1.0.0",
"@mfgames-writing/hyphen-pipeline": "^1.0.2",
"@mfgames-writing/liquid-theme": "^2.1.1",
"@mfgames-writing/weasyprint-format": "^5.0.4",
"markdown-it-multimd-table": "^4.1.3"
},
"devDependencies": {
"@commitlint/cli": "^7.6.1",
"@commitlint/config-conventional": "^7.6.0",
"@semantic-release/changelog": "^3.0.6",
"@semantic-release/git": "^7.0.18",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^7.0.4",
"@semantic-release/npm": "^8.0.3",
"@semantic-release/release-notes-generator": "^10.0.3",
"commitizen": "^2.10.1",
"commitlint-gitlab-ci": "^0.0.4",
"cz-conventional-changelog": "^2.1.0",
"husky": "^4.2.1",
"semantic-release": "^15.14.0"
"husky": "^7.0.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"semantic-release": "^18.0.1"
},
"release": {
"branch": "master",
"message": "chore(release): v${nextRelease.version}\n\n${nextRelease.notes}",
"verifyConditions": [
"@semantic-release/changelog",
"@semantic-release/git"
],
"analyzeCommits": [
"@semantic-release/commit-analyzer"
],
"prepare": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
],
"publish": [],
"success": [],
"fail": []
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"pre-commit": "npm run lint",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
"private": true
}

152
publication.json Normal file
View File

@ -0,0 +1,152 @@
{
"metadata": {
"title": "Allegro",
"author": "D. Moonfire",
"language": "en",
"theme": "@fedran/writing-theme",
"outputDirectory": ".",
"outputFilename": "dmoonfire-{{ edition.fedran.identifier }}-{{ edition.name }}-{{ edition.version }}.{{ edition.ext }}",
"markdown": {
"extensions": [
{
"package": "markdown-it-multimd-table",
"options": {
"headerless": true
}
}
]
},
"style": {
"css": "td { width: 6em; } td[colspan=\"2\"] { width: 12em; }"
}
},
"includes": [
{
"json": "./fedran.json",
"merge": "metadata.fedran"
}
],
"editions": {
"epub": {
"format": "@mfgames-writing/epub2-format",
"ext": "epub"
},
"pdf": {
"format": "@mfgames-writing/weasyprint-format",
"images": {
"grayscale": true,
"opaque": true
},
"ext": "pdf"
},
"docx": {
"format": "@mfgames-writing/docx-format",
"ext": "docx"
}
},
"contents": [
{
"element": "cover",
"source": "build/fedran-covers/pov/covers/0047-00-flight-of-the-scions.jpg",
"linear": false,
"exclude": {
"editions": ["pdf"],
"toc": true
}
},
{
"element": "bastard",
"source": "matter/title.html",
"linear": false,
"exclude": {
"editions": ["epub", "html"],
"toc": true
}
},
{
"element": "title",
"source": "matter/title.html",
"linear": false,
"exclude": {
"toc": true
}
},
{
"element": "legal",
"source": "matter/legal.md",
"liquid": true,
"linear": false
},
{
"element": "dedication",
"source": "matter/dedication.md",
"linear": false
},
{
"element": "toc",
"linear": false,
"title": "Contents",
"exclude": {
"editions": ["pdf"]
}
},
{
"element": "preface",
"source": "matter/lorban.html",
"linear": false
},
{
"element": "chapter",
"number": 1,
"directory": "chapters",
"source": "/^chapter-\\d+.(markdown|md)$/",
"start": true,
"page": 1,
"pipeline": [
{
"module": "@mfgames-writing/guillemet"
},
{
"module": "@fedran/writing-hyphen"
},
{
"module": "@mfgames-writing/hyphen-pipeline",
"exclude": ["`.*?`", "<code>.*?</code>"]
}
]
},
{
"element": "appendix",
"source": "matter/about.md"
},
{
"element": "appendix",
"source": "matter/fedran.md"
},
{
"element": "appendix",
"id": "license",
"source": "matter/license.md"
},
{
"element": "appendix",
"source": "matter/credits.md",
"pipeline": [
{
"module": "@mfgames-writing/guillemet"
},
{
"module": "@fedran/writing-hyphen"
},
{
"module": "@mfgames-writing/hyphen-pipeline",
"exclude": ["`.*?`", "<code>.*?</code>"]
}
]
},
{
"element": "colophon",
"source": "matter/colophon.md"
}
]
}

View File

@ -1,87 +0,0 @@
metadata:
series:
name: Linsan
volume: 1
title: Allegro
author: D. Moonfire
publisher: Broken Typewriter Press
rights: CC-BY-NC-SA-4.0
description:
source: ./description.md
subjects:
- Anime
- Fantasy
- Steampunk
- Fiction
- Action
- Drama
language: en
date: 2019-12-20
theme: "@fedran/writing-theme"
outputDirectory: .
outputFilename: "dmoonfire-{{ edition.fedran.pov }}-{{ edition.fedran.vol}}-{{ edition.name }}-{{ edition.version }}.{{ edition.editionName }}"
editions:
epub:
format: "@mfgames-writing/epub2"
pdf:
format: "@mfgames-writing/weasyprint"
images:
grayscale: true
opaque: true
contents:
- element: cover
source: build/repos/fedran-covers/dist/full/{{ edition.fedran.pov }}-{{ edition.fedran.vol}}-{{ edition.name }}-front.jpg
linear: false
exclude:
editions: [pdf]
toc: true
- element: bastard
source: frontmatter/title.html
linear: false
exclude:
editions: [epub]
toc: true
- element: title
source: frontmatter/title.html
linear: false
exclude:
toc: true
- element: legal
source: frontmatter/legal.md
liquid: true
linear: false
- element: dedication
source: frontmatter/dedication.md
linear: false
- element: toc
linear: false
title: Contents
exclude:
editions: [pdf]
- element: chapter
number: 1
directory: chapters
source: /^chapter-\d+.md$/
start: true
page: 1
pipeline: &pipelines
- module: "@fedran/writing-hyphen"
- module: "@mfgames-writing/hyphen"
- element: appendix
source: backmatter/about.md
- element: appendix
source: backmatter/fedran.md
- element: appendix
id: license
source: backmatter/license.md
liquid: true
- element: appendix
source: backmatter/patrons.md
- element: appendix
source: backmatter/credits.md
pipeline: *pipelines
- element: colophon
source: backmatter/colophon.md

38
release.config.js Normal file
View File

@ -0,0 +1,38 @@
module.exports = {
branches: ["main"],
extends: ["@commitlint/config-conventional"],
message:
"chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "conventionalcommits",
},
],
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
[
"@semantic-release/exec",
{
prepareCmd: "npm run build",
},
],
"@semantic-release/changelog",
"@semantic-release/git",
[
"@semantic-release/gitlab",
{
assets: [
{ path: "*.epub", label: "EPUB2", type: "other" },
{ path: "*.pdf", label: "PDF", type: "other" },
{ path: "*.docx", label: "DOCX", type: "other" },
],
},
],
],
};

14
scripts/build.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Move into the root folder.
cd $(dirname $(dirname $0))
# Download the covers.
mkdir -p build/fedran-covers
pushd build/fedran-covers
s3cmd --access_key=$AWS_ACCESS_KEY_ID --access_token=$AWS_SECRET_ACCESS_KEY --host=$AWS_ENDPOINT --host-bucket=$AWS_ENDPOINT -P get s3://$AWS_BUCKET/fedran-covers.tar.bz2
tar -xjf fedran-covers.tar.bz2
popd
# Build the project.
npm run build

11
scripts/release.sh Executable file
View File

@ -0,0 +1,11 @@
mkdir -p build/repos
git clone https://oauth2:$fedranAccessKey@gitlab.com/fedran/fedran-covers.git build/repos/fedran-covers
rm -f dmoonfire*
npm install --ci
npx semantic-release
export npm_package_name=$(cat package.json | jq -r .name)
tar -cjf $npm_package_name.tar.bz2 dmoonfire*
s3cmd --access_key=$AWS_ACCESS_KEY_ID --access_token=$AWS_SECRET_ACCESS_KEY --host=$AWS_ENDPOINT --host-bucket=$AWS_ENDPOINT -P put flight-of-the-scions.tar.bz2 s3://$AWS_BUCKET

15
scripts/setup.sh Executable file
View File

@ -0,0 +1,15 @@
# Install the fonts we need for the covers.
if [ "x$CI" == "x" ]
then
echo "not in CI environment, not installing fonts"
else
echo "installing fonts"
mkdir -p ~/.local/share/fonts
cp $(nix-build --no-out-link '<nixpkgs>' -A source-serif-pro)/share/fonts/opentype/*.otf ~/.local/share/fonts
cp $(nix-build --no-out-link '<nixpkgs>' -A source-sans-pro)/share/fonts/opentype/*.otf ~/.local/share/fonts
fc-cache
fc-list | grep -i source
fi
echo "installing node packages"
npm install --ci

2
scripts/test.sh Executable file
View File

@ -0,0 +1,2 @@
npm install --ci
npx commitlint-gitlab-ci -x @commitlint/config-conventional