summary refs log tree commit diff
path: root/README
blob: 6a2a4924ec45943e8c5c666f2af226cb99f27ae6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
saait
-----

The most boring static page generator.

Meaning of saai (dutch): boring
Pronounciation:          site

Some parts are intentionally hardcoded in C for simplicity.


Build and install
-----------------

$ make
# make install


Dependencies
------------

- C compiler (C99), tested on gcc and clang.
- libc
- POSIX make (optional).
- mandoc for documentation: https://mdocml.bsd.lv/ (optional).


Tested and works on
-------------------

- OpenBSD
- Linux (glibc).
- Windows (mingw and cygwin).


Example of a workflow
---------------------

This script monitors pages for changes and for new files in the directory then
regenerates static files if this happens. If successful then refreshes the
current window/tab in Firefox.

Dependencies: make, xdotool, entr (https://eradman.com/entrproject/).

	#!/bin/sh
	if test x"$1" = x"rebuild"; then
		make && xdotool search --class firefox key F5
	else
		while :; do find pages | entr -d -p "$(readlink -f "$0")" rebuild; done
	fi


Using Markdown
--------------

A possible method could be to just convert the Markdown to HTML and to run
saait after that as usual.

In this example it uses smu for the Markdown processor, available at:
https://github.com/Gottox/smu:

	cd pages
	for f in *.md; do
		smu -n < "$f" > "$(basename "$f" .md).html"
	done


Documentation
-------------

See the man page of saait(1).


Man page
--------

SAAIT(1)		    General Commands Manual		      SAAIT(1)

NAME
     saait  the most boring static page generator

SYNOPSIS
     saait [-c configfile] [-o outputdir] [-t templatesdir] pages...

DESCRIPTION
     saait writes HTML pages to the output directory.

     The arguments pages are page config files, which are processed in the
     given order.

     The options are as follows:

     -c configfile
	     The global configuration file, the default is "config.cfg".  Each
	     page configuration file inherits variables from this file.	 These
	     variables can be overwritten per page.

     -o outputdir
	     The output directory, the default is "output".

     -t templatesdir
	     The templates directory, the default is "templates".

DIRECTORY AND FILE STRUCTURE
     A recommended directory structure for pages, although the names can be
     anything:
     pages/001-page.cfg
     pages/001-page.html
     pages/002-page.cfg
     pages/002-page.html

     The directory and file structure for templates must be:
     templates/<templatename>/header.ext
     templates/<templatename>/item.ext
     templates/<templatename>/footer.ext

     The following filename prefixes are detected for template blocks and
     processed in this order:

     "header."
	     Header block.

     "item."
	     Item block.

     "footer."
	     Footer block.

     The files are saved as output/<templatename>, for example
     templates/atom.xml/* will become: output/atom.xml.	 If a template block
     file does not exist then it is treated as if it was empty.

     Template directories starting with a dot (".") are ignored.

     The "page" templatename is special and will be used per page.

CONFIG FILE
     A config file has a simple key=value configuration syntax, for example:

     # this is a comment line.
     filename = example.html
     title = Example page
     description = This is an example page
     created = 2009-04-12
     updated = 2009-04-14

     The following variable names are special with their respective defaults:

     contentfile
	     Path to the input content filename, by default this is the path
	     of the config file with the last extension replaced to ".html".

     filename
	     The filename or relative file path for the output file for this
	     page.  By default the value is the basename of the contentfile.
	     The path of the written output file is the value of filename
	     appended to the outputdir path.

     A line starting with # is a comment and is ignored.

     TABs and spaces before and after a variable name are ignored.  TABs and
     spaces before a value are ignored.

TEMPLATES
     A template (block) is text.  Variables are replaced with the values set
     in the config files.

     The possible operators for variables are:

     $	     Escapes a XML string, for example: < to the entity &lt;.

     #	     Literal raw string value.

     %	     Insert contents of file of the value of the variable.

     For example in a HTML item template:

     <article>
	     <header>
		     <h1><a href="">${title}</a></h1>
		     <p>
			     <strong>Last modification on </strong>
			     <time datetime="${updated}">${updated}</time>
		     </p>
	     </header>
	     %{contentfile}
     </article>

EXIT STATUS
     The saait utility exits 0 on success, and >0 if an error occurs.

EXAMPLES
     A basic usage example:

     1.   Create a directory for a new site:

	  mkdir newsite

     2.   Copy the example pages, templates, global config file and example
	  stylesheets to a directory:

	  cp -r pages templates config.cfg style.css print.css newsite/

     3.   Change the current directory to the created directory.

	  cd newsite/

     4.   Change the values in the global config.cfg file.

     5.   If you want to modify parts of the header, like the navigation menu
	  items, you can change the following two template files:
	  templates/page/header.html
	  templates/index.html/header.html

     6.   Create any new pages in the pages directory.	For each config file
	  there has to be a corresponding HTML file.  By default this HTML
	  file has the path of the config file, but with the last extension
	  (".cfg" in this case) replaced to ".html".

     7.   Create an output directory:

	  mkdir -p output

     8.   After any modifications the following commands can be used to
	  generate the output and process the pages in descending order:

	  find pages -type f -name '*.cfg' -print0 | sort -zr | xargs -0 saait

     9.   Copy the modified stylesheets to the output directory also:

	  cp style.css print.css output/

     10.  Open output/index.html locally in your webbrowser to review the
	  changes.

     11.  To synchronize files, you can securely transfer them via SSH using
	  rsync:

	  rsync -av output/ user@somehost:/var/www/htdocs/

TRIVIA
     The most boring static page generator.

     Meaning of saai (dutch): boring, pronunciation of saait: site

SEE ALSO
     find(1), sort(1), xargs(1)

AUTHORS
     Hiltjo Posthuma <hiltjo@codemadness.org>