diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc310d1 --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,141 @@ | |||
1 | # UNK | ||
2 | |||
3 | ## a very small static site generator | ||
4 | |||
5 | **UNK** is an experiment in minimalism. | ||
6 | It is a templating static site generator | ||
7 | with an included markup language | ||
8 | that all fits with 1000 bytes. | ||
9 | There are three main scripts: | ||
10 | |||
11 | - **UNK**, a bash script that applies the template | ||
12 | to each page and publishes them to the output dir, and | ||
13 | - **LHT**, an awk script that serves as a (very) basic | ||
14 | markup language. | ||
15 | - **TM**, the default template file for **UNK**. | ||
16 | |||
17 | Both scripts are 250 bytes each, for a total of 500 bytes. | ||
18 | The default template file takes up the remaining 500 bytes | ||
19 | of the target 1000 bytes. | ||
20 | You are, of course, free to make the template file as large | ||
21 | and involved as you like. | ||
22 | |||
23 | # DETAILS | ||
24 | |||
25 | ## UNK | ||
26 | |||
27 | **UNK** takes a set of files in a directory, applies a template to them, | ||
28 | and output them into another directory as HTML files ready for a server. | ||
29 | To keep a very small size, **UNK** delegates most file processing to **TM**, | ||
30 | the main template. It delegates by using an idea found in | ||
31 | [shab](https://github.com/zimbatm/shab): | ||
32 | each input file is read as a `heredoc`, which enables | ||
33 | shell interpolation. | ||
34 | So the template, as opposed to the engine, | ||
35 | can do all the heavy-lifting of index generation and navigation and such. | ||
36 | That means all the | ||
37 | |||
38 | Content goes into the following (hard-coded) directories: | ||
39 | |||
40 | - **I/**, for written (*__i__nput*) content (the pages of the site), | ||
41 | - **S/**, for ***s***tatic content (css, images, etc.), & | ||
42 | - **O/**, for the (*__o__utput*) website, ready for `rsync`ing | ||
43 | to a server. | ||
44 | |||
45 | If there is no **TM** in the directory where **UNK** is run, | ||
46 | one will be created that will simply echo the file being processed. | ||
47 | |||
48 | The following variables are made available to **TM**: | ||
49 | |||
50 | - **FN**: the *FileName* (with directories removed) | ||
51 | of the file being processed | ||
52 | - **TT**: the *TiTle* (the first line) of the file | ||
53 | - **BD**: the *BoDy* (the rest) of the file | ||
54 | |||
55 | as well as this function: | ||
56 | |||
57 | - **X**, for *eXpand*: the `shab` stand-in. | ||
58 | It is much simpler than `shab`, and will fail if the template | ||
59 | (or if it nests templates, one of the nested ones) | ||
60 | has a `ZZ` on a line by itself, due to its `heredoc` nature. | ||
61 | |||
62 | and these aliases (though they're more an artefact of saving space | ||
63 | in the script, but they can be used in templates): | ||
64 | |||
65 | - **c**: `cat` | ||
66 | - **q**: `test` | ||
67 | - **e**: `echo` | ||
68 | |||
69 | As mentioned above, templates can be nested. | ||
70 | Simply call another template from **TM** with the **X** function. | ||
71 | |||
72 | ## LHT | ||
73 | |||
74 | **LHT** stands for *Less HyperText*, | ||
75 | because that's what you're writing when you're writing it | ||
76 | (though not much less than HTML). | ||
77 | Basically, | ||
78 | blank lines are interpreted as `<p>` tag breaks, | ||
79 | unless the previous source paragraph started with `<` and ended with `>`. | ||
80 | It also has support for three inline spans: | ||
81 | |||
82 | - `*em*` or `_em_` as *em* | ||
83 | - `**strong**` or `__strong__` as **strong** | ||
84 | - `\`code\`` as `code`. | ||
85 | |||
86 | Everything else is just HTML. | ||
87 | |||
88 | **LHT** was inspired, in part, by | ||
89 | [Writing HTML in HTML](http://john.ankarstrom.se/html) by John Ankarstrom, | ||
90 | as well as some other articles I can't think of right now. | ||
91 | I liked the idea, but some tags in HTML are just annoying to write | ||
92 | over and over, and take me out of the flow of writing prose. | ||
93 | So I fixed those few tags. | ||
94 | **The inline tags are definitely subject to change.** | ||
95 | |||
96 | # Why? | ||
97 | |||
98 | I was bored and decided I'd try to write a static site generator | ||
99 | that could fit in a [toot] (500 characters). | ||
100 | I [wrote][1] [a few][2] [of them][3], | ||
101 | making them smaller and smaller each time. | ||
102 | By the end, I was left with a *tiny* script | ||
103 | that delegated almost *all* the work to the template file. | ||
104 | That script became **UNK** in this repo. | ||
105 | |||
106 | [toot]: https://writing.exchange/web/statuses/102333562361891512 | ||
107 | [1]: https://writing.exchange/web/statuses/102334522981990897 | ||
108 | [2]: https://writing.exchange/web/statuses/102334522981990897 | ||
109 | [3]: https://writing.exchange/web/statuses/102339851501562648 | ||
110 | |||
111 | I was feeling pretty high on my horse after writing the tiny SSG, | ||
112 | so I thought, | ||
113 | *[maybe I could try for a tootable Markdown converter next][4]* -- | ||
114 | boy, was I wrong about that. | ||
115 | Markdown is *way* too complicated to fit in 500 bytes. | ||
116 | So I just wrote the Really Important Parts: `<p>` and some inlines. | ||
117 | |||
118 | [4]: https://writing.exchange/@acdw/102339290120562386 | ||
119 | |||
120 | # LEGAL | ||
121 | |||
122 | Copyright © 2019 Case Duckworth <acdw@acdw.net> | ||
123 | This work is free. | ||
124 | You can redistribute it and/or modify it under the terms of | ||
125 | the Do What The Fuck You Want To Public License, Version 2, | ||
126 | as published by Sam Hocevar. | ||
127 | See the LICENSE file for more details. | ||
128 | |||
129 | ## Why this license? | ||
130 | |||
131 | I was going to go with a stricter license like the GPL, | ||
132 | but realized that | ||
133 | |||
134 | 1. this software isn't so important or time-consuming that I need | ||
135 | others to credit me or redistribute the project under the same terms, and | ||
136 | 2. the GPL is *way* too long for a project like this. | ||
137 | It's over 35 times *bigger* than the entirety of this project, | ||
138 | not counting the content or this README. | ||
139 | It would weigh down the entire undertaking. | ||
140 | The WTFPL, by contrast, is a trim 443 characters, | ||
141 | which is right in keeping with the smallness of this project. | ||