|
0
|
1 # Design notes
|
|
|
2
|
|
|
3 ## Requirements
|
|
|
4
|
|
|
5 The generator was written for a personal site. It is mostly a gallery of
|
|
|
6 projects, with posts and links to other sites. Pages have tags, and the tags
|
|
|
7 are the navigation. Links to the site get shared, so pages need link preview
|
|
|
8 metadata. There are no comments and no other dynamic parts. The site is
|
|
|
9 updated about once a week at most.
|
|
|
10
|
|
|
11 The toolchain avoids Node.js and npm. Python with python-markdown and Pillow
|
|
|
12 is the whole dependency list. The build runs on the author's machine, and only
|
|
|
13 the finished output goes to the server.
|
|
|
14
|
|
|
15 The images are mostly JPEG photos from a phone, plus screenshots. They
|
|
|
16 document things; fidelity is not a goal. They do need the right orientation,
|
|
|
17 no location data in the published copies, and screenshots have to stay
|
|
|
18 legible.
|
|
|
19
|
|
|
20 Because the site changes rarely, few moving parts matter more than build
|
|
|
21 speed. Whoever comes back to it after months has to be able to read the whole
|
|
|
22 generator.
|
|
|
23
|
|
|
24 ## Decisions
|
|
|
25
|
|
|
26 ### Clean builds
|
|
|
27
|
|
|
28 The normal workflow is a clean build, followed by replacing the whole
|
|
|
29 published site with an archive of the output. Incremental builds are a
|
|
|
30 convenience during writing. They only compare the dates of sources and
|
|
|
31 outputs, and they never remove files. See [build.md](build.md).
|
|
|
32
|
|
|
33 ### Header blocks
|
|
|
34
|
|
|
35 A page starts with `key: value` lines, folded like mail headers. This is not
|
|
|
36 YAML: there is no quoting, no nesting and no fence. Every value is a string.
|
|
|
37 The site configuration uses the same format.
|
|
|
38
|
|
|
39 Unknown header keys are passed to the templates and produce a warning. The
|
|
|
40 warning catches typos. It does not restrict what keys a site may use: a key
|
|
|
41 stops warning once it is listed in the configuration.
|
|
|
42
|
|
|
43 ### Mirrored paths
|
|
|
44
|
|
|
45 The output tree mirrors the source tree. The generator creates no directories
|
|
|
46 of its own and gives `index.md` no special role. Navigation and directory
|
|
|
47 indexes are written by hand, or kept up to date with `update_index.py`.
|
|
|
48
|
|
|
49 ### Errors and warnings
|
|
|
50
|
|
|
51 An error stops the build. It is used only where no correct output is possible,
|
|
|
52 such as a page without a title. Everything else produces output and a
|
|
|
53 warning: broken links, unknown sizes, unknown keys. A build with warnings
|
|
|
54 still exits successfully.
|
|
|
55
|
|
|
56 ### Markdown
|
|
|
57
|
|
|
58 python-markdown with the `extra` bundle and `sane_lists`. `smarty` is off,
|
|
|
59 so quotes and dashes stay as written.
|
|
|
60
|
|
|
61 ### Images
|
|
|
62
|
|
|
63 Image sizes are requested in the file name of the reference, such as
|
|
|
64 `photo.800.jpg`, so the Markdown stays standard. The original is the name
|
|
|
65 without that part.
|
|
|
66
|
|
|
67 The format of an image is decided by its content, not by its extension. A
|
|
|
68 generated image keeps the format of its original. There is no format
|
|
|
69 conversion.
|
|
|
70
|
|
|
71 Phone photos may be stored sideways, with the rotation recorded only in the
|
|
|
72 Exif (Exchangeable Image File Format) data. Generated images have the rotation
|
|
|
73 applied to their pixels and contain no Exif data, so location and camera
|
|
|
74 details are not published. They keep the colour profile of the original,
|
|
|
75 because phone cameras record in a wider colour space than sRGB. Images are
|
|
|
76 never scaled up.
|
|
|
77
|
|
|
78 Files referenced verbatim, including the originals behind linked thumbnails,
|
|
|
79 are copied unchanged with all their metadata.
|
|
|
80
|
|
|
81 ### Link previews
|
|
|
82
|
|
|
83 Services that show a preview card for a shared link read tags in the page
|
|
|
84 head. There is no standard all of them follow. Most read the Open Graph tags,
|
|
|
85 X wants its own `twitter:card` tag, and search engines read the description
|
|
|
86 meta tag. Each one crops, sizes and caches the image in its own way. The
|
|
|
87 generator aims at a common set of tags that most of them understand.
|
|
|
88
|
|
|
89 The generator supplies the values; the templates write the tags. Preview
|
|
|
90 images are cut to 1200x630, the size Facebook and LinkedIn ask for.
|
|
|
91
|
|
|
92 Consumers fetch a page on their own, so the canonical address and the image
|
|
|
93 address are absolute. They are built from the production address in the
|
|
|
94 configuration. `make_dist.sh` replaces it in a copy of the output when an
|
|
|
95 archive is meant for another address, such as a test server.
|
|
|
96
|
|
|
97 ### Templates
|
|
|
98
|
|
|
99 Templates are plain HTML with value markers and two kinds of block: a
|
|
|
100 condition and a loop. Blocks of the same kind cannot be nested. Values are
|
|
|
101 HTML-escaped unless a filter says otherwise.
|
|
|
102
|
|
|
103 ### Accepted limitations
|
|
|
104
|
|
|
105 - A file name with dots can be read as a size request. A reference to
|
|
|
106 `my.photo.png` with no such file present is taken as a request for size
|
|
|
107 `photo` of `my.png`.
|
|
|
108 - Building a subset of the site into a clean directory produces link
|
|
|
109 warnings for everything outside the subset, and incomplete tag index pages.
|
|
|
110 - Files from `static/`, `tpl/` and `src/` are copied into one tree. Nothing
|
|
|
111 detects one of them overwriting another.
|
|
|
112 - A changed template or configuration does not cause a rebuild. A clean
|
|
|
113 build does.
|