From 7b0baaab2b18e7232b48297de34887650f5b8ca6 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Tue, 19 Jan 2021 18:40:31 +0100 Subject: Init --- .gitignore | 5 + Makefile | 12 ++ README | 250 ++++++++++++++++++++++++++++++++++ config.cfg | 27 ++++ pages/001-example.cfg | 6 + pages/001-example.html | 1 + pages/002-example.cfg | 6 + pages/002-example.html | 1 + print.css | 31 +++++ style.css | 96 +++++++++++++ templates/atom.xml/footer.xml | 1 + templates/atom.xml/header.xml | 8 ++ templates/atom.xml/item.xml | 12 ++ templates/atom_content.xml/footer.xml | 1 + templates/atom_content.xml/header.xml | 8 ++ templates/atom_content.xml/item.xml | 15 ++ templates/index.html/footer.html | 7 + templates/index.html/header.html | 41 ++++++ templates/index.html/item.html | 1 + templates/page/footer.html | 5 + templates/page/header.html | 40 ++++++ templates/page/item.html | 6 + templates/rss.xml/footer.xml | 2 + templates/rss.xml/header.xml | 8 ++ templates/rss.xml/item.xml | 8 ++ templates/rss_content.xml/footer.xml | 2 + templates/rss_content.xml/header.xml | 8 ++ templates/rss_content.xml/item.xml | 10 ++ templates/sitemap.xml/footer.xml | 1 + templates/sitemap.xml/header.xml | 2 + templates/sitemap.xml/item.xml | 4 + templates/twtxt.txt/footer.txt | 0 templates/twtxt.txt/header.txt | 0 templates/twtxt.txt/item.txt | 1 + templates/urllist.txt/item.txt | 1 + 35 files changed, 627 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README create mode 100644 config.cfg create mode 100644 pages/001-example.cfg create mode 100644 pages/001-example.html create mode 100644 pages/002-example.cfg create mode 100644 pages/002-example.html create mode 100644 print.css create mode 100644 style.css create mode 100644 templates/atom.xml/footer.xml create mode 100644 templates/atom.xml/header.xml create mode 100644 templates/atom.xml/item.xml create mode 100644 templates/atom_content.xml/footer.xml create mode 100644 templates/atom_content.xml/header.xml create mode 100644 templates/atom_content.xml/item.xml create mode 100644 templates/index.html/footer.html create mode 100644 templates/index.html/header.html create mode 100644 templates/index.html/item.html create mode 100644 templates/page/footer.html create mode 100644 templates/page/header.html create mode 100644 templates/page/item.html create mode 100644 templates/rss.xml/footer.xml create mode 100644 templates/rss.xml/header.xml create mode 100644 templates/rss.xml/item.xml create mode 100644 templates/rss_content.xml/footer.xml create mode 100644 templates/rss_content.xml/header.xml create mode 100644 templates/rss_content.xml/item.xml create mode 100644 templates/sitemap.xml/footer.xml create mode 100644 templates/sitemap.xml/header.xml create mode 100644 templates/sitemap.xml/item.xml create mode 100644 templates/twtxt.txt/footer.txt create mode 100644 templates/twtxt.txt/header.txt create mode 100644 templates/twtxt.txt/item.txt create mode 100644 templates/urllist.txt/item.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..efc151f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin +output +saait +*.o +*.core diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..78f9724 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +generate: + mkdir -p output + find pages -type f -name '*.cfg' -print0 | sort -zr | xargs -0 saait + cp style.css print.css output/ + zip -r kronika.zip output + mv kronika.zip output/kronika.zip + +view: + $(BROWSER) output/index.html + +sync: + rsync -av output/ hiltjo@cow:/home/www/domains/www.codemadness.org/htdocs/ diff --git a/README b/README new file mode 100644 index 0000000..6a2a492 --- /dev/null +++ b/README @@ -0,0 +1,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//header.ext + templates//item.ext + templates//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/, 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 <. + + # Literal raw string value. + + % Insert contents of file of the value of the variable. + + For example in a HTML item template: + +
+
+

${title}

+

+ Last modification on + +

+
+ %{contentfile} +
+ +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 diff --git a/config.cfg b/config.cfg new file mode 100644 index 0000000..a18787a --- /dev/null +++ b/config.cfg @@ -0,0 +1,27 @@ +# defaults: can be overwritten by any page. + +# last updated the site. +siteupdated = 2017-11-23 + +# site title (part of page ${title} probably). +sitetitle = 19 PDH Puszcza +# prefix site url. +siteurl = https://19.niedzwiedzinski.cyou +# site mail used for contact "mail link". +sitemail = patryk.niedzwiedzinski@zhr.pl +# site generator. +sitegenerator = saait (https://git.codemadness.org/saait/file/README.html) + +# page + +# page language. +lang = pl +# author (global default). +author = 19 PDH Puszcza +# site keywords (global default), don't use too many. +keywords = blog, kronika, harcerstwo, poznań +# site description (global default). +description = Strona i kronika harcerzy z 19 PDH Puszcza + +# default title. +title = 19 PDH Puszcza diff --git a/pages/001-example.cfg b/pages/001-example.cfg new file mode 100644 index 0000000..e5b0043 --- /dev/null +++ b/pages/001-example.cfg @@ -0,0 +1,6 @@ +filename = example.html +title = Example page +description = This is an example page +keywords = example +created = 2009-04-12 +updated = 2009-04-12 diff --git a/pages/001-example.html b/pages/001-example.html new file mode 100644 index 0000000..1b9e072 --- /dev/null +++ b/pages/001-example.html @@ -0,0 +1 @@ +

example

diff --git a/pages/002-example.cfg b/pages/002-example.cfg new file mode 100644 index 0000000..5d2d392 --- /dev/null +++ b/pages/002-example.cfg @@ -0,0 +1,6 @@ +filename = example2.html +title = Example page 2 +description = This is an example page 2 +keywords = example +created = 2009-04-13 +updated = 2009-04-13 diff --git a/pages/002-example.html b/pages/002-example.html new file mode 100644 index 0000000..cd9f9e7 --- /dev/null +++ b/pages/002-example.html @@ -0,0 +1 @@ +

example 2

diff --git a/print.css b/print.css new file mode 100644 index 0000000..c032e9f --- /dev/null +++ b/print.css @@ -0,0 +1,31 @@ +a, +a:visited { + color: inherit; + text-decoration: none; +} +/* HTML5 semantic tags: some (older) browsers display this inline by default */ +article, figcaption, figure, header, main { + display: block; +} +/* hide navigation menus when printing */ +nav, +#menuwrap, +.hidden { + display: none; +} +table, img { + border: 0; +} +table tr td { + padding: 2px 10px 2px 0px; +} +pre { + margin: 0; +} +code { + border: 3px solid #aaa; + display: block; + overflow-x: auto; + padding: 5px; + word-wrap: normal; +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..4a307e5 --- /dev/null +++ b/style.css @@ -0,0 +1,96 @@ +html { + overflow-y: scroll; +} +* { + box-sizing: border-box; +} +body { + background-color: #fff; + color: #000; + font-family: sans-serif; + padding: 1ex; + /* center page */ + margin: 0 auto; + max-width: 80ex; +} +/* HTML5 semantic tags: some (older) browsers display this inline by default */ +article, figcaption, figure, header, main, nav { + display: block; +} +table, img { + border: 0; +} +hr { + border: 0; + border-bottom: 3px solid #aaa; + height: 3px; +} +h1 { + font-size: 140%; +} +h2 { + font-size: 120%; +} +h3 { + font-size: 120%; +} +h1, +h1 a, +h1 a:visited, +h2, +h2 a, +h2 a:visited, +h3, +h3 a, +h3 a:visited, +h1 a:hover, +h2 a:hover, +h3 a:hover { + color: inherit; + text-decoration: none; +} +table tr td { + padding: 2px 10px 2px 0px; +} +pre { + margin: 0; +} +code { + background-color: #eee; + border: 3px solid #aaa; + display: block; + font-family: monospace; + overflow-x: auto; + padding: 5px; + word-wrap: normal; +} +#menu td { + padding: 1ex 0; +} +#main { + border-top: 3px solid #aaa; + padding: 2ex 0; +} +#menu a { + font-weight: bold; + vertical-align: middle; +} +.hidden { + display: none; +} +footer { + padding: 10px; + text-align: center; + background-color:#507b34; + color: #fff; +} + +.icon img { + width: 30px; + height: 30px; + margin: 0 5px; +} +a.icon { + text-decoration: none; + color: none; +} diff --git a/templates/atom.xml/footer.xml b/templates/atom.xml/footer.xml new file mode 100644 index 0000000..f2d5538 --- /dev/null +++ b/templates/atom.xml/footer.xml @@ -0,0 +1 @@ + diff --git a/templates/atom.xml/header.xml b/templates/atom.xml/header.xml new file mode 100644 index 0000000..d42faca --- /dev/null +++ b/templates/atom.xml/header.xml @@ -0,0 +1,8 @@ + + + ${sitetitle} + ${description} + ${siteupdated}T00:00:00Z + + ${siteurl}/atom.xml + diff --git a/templates/atom.xml/item.xml b/templates/atom.xml/item.xml new file mode 100644 index 0000000..e0e7a9d --- /dev/null +++ b/templates/atom.xml/item.xml @@ -0,0 +1,12 @@ + + ${title} + + ${siteurl}/${filename} + ${updated}T00:00:00Z + ${created}T00:00:00Z + + ${author} + ${siteurl} + + ${description} + diff --git a/templates/atom_content.xml/footer.xml b/templates/atom_content.xml/footer.xml new file mode 100644 index 0000000..f2d5538 --- /dev/null +++ b/templates/atom_content.xml/footer.xml @@ -0,0 +1 @@ + diff --git a/templates/atom_content.xml/header.xml b/templates/atom_content.xml/header.xml new file mode 100644 index 0000000..d42faca --- /dev/null +++ b/templates/atom_content.xml/header.xml @@ -0,0 +1,8 @@ + + + ${sitetitle} + ${description} + ${siteupdated}T00:00:00Z + + ${siteurl}/atom.xml + diff --git a/templates/atom_content.xml/item.xml b/templates/atom_content.xml/item.xml new file mode 100644 index 0000000..6b23a04 --- /dev/null +++ b/templates/atom_content.xml/item.xml @@ -0,0 +1,15 @@ + + ${title} + + ${siteurl}/${filename} + ${updated}T00:00:00Z + ${created}T00:00:00Z + + ${author} + ${siteurl} + + ${description} + ${title} +

Last modification on

+ %{contentfile}]]>
+
diff --git a/templates/index.html/footer.html b/templates/index.html/footer.html new file mode 100644 index 0000000..ead1ef0 --- /dev/null +++ b/templates/index.html/footer.html @@ -0,0 +1,7 @@ + + +
+ 📁 Pobierz archiwum + + + diff --git a/templates/index.html/header.html b/templates/index.html/header.html new file mode 100644 index 0000000..5e642f3 --- /dev/null +++ b/templates/index.html/header.html @@ -0,0 +1,41 @@ + + + + + + + + + + + Posts - ${sitetitle} + + + + + + + + + +
+
+

Wpisy z kroniki

+ diff --git a/templates/index.html/item.html b/templates/index.html/item.html new file mode 100644 index 0000000..9f011d4 --- /dev/null +++ b/templates/index.html/item.html @@ -0,0 +1 @@ + diff --git a/templates/page/footer.html b/templates/page/footer.html new file mode 100644 index 0000000..6600659 --- /dev/null +++ b/templates/page/footer.html @@ -0,0 +1,5 @@ + + + + + diff --git a/templates/page/header.html b/templates/page/header.html new file mode 100644 index 0000000..8679cc2 --- /dev/null +++ b/templates/page/header.html @@ -0,0 +1,40 @@ + + + + + + + + + + + ${title} - ${sitetitle} + + + + + + + +
${title}
+ + + + + + + +
+
+
diff --git a/templates/page/item.html b/templates/page/item.html new file mode 100644 index 0000000..729cfad --- /dev/null +++ b/templates/page/item.html @@ -0,0 +1,6 @@ +
+

${title}

+

Last modification on

+
+ +%{contentfile} diff --git a/templates/rss.xml/footer.xml b/templates/rss.xml/footer.xml new file mode 100644 index 0000000..3a9dbde --- /dev/null +++ b/templates/rss.xml/footer.xml @@ -0,0 +1,2 @@ + + diff --git a/templates/rss.xml/header.xml b/templates/rss.xml/header.xml new file mode 100644 index 0000000..396ef6b --- /dev/null +++ b/templates/rss.xml/header.xml @@ -0,0 +1,8 @@ + + + + ${sitetitle} + ${description} + ${siteurl} diff --git a/templates/rss.xml/item.xml b/templates/rss.xml/item.xml new file mode 100644 index 0000000..c003f1b --- /dev/null +++ b/templates/rss.xml/item.xml @@ -0,0 +1,8 @@ + + ${title} + ${siteurl}/${filename} + ${siteurl}/${filename} + ${created}T00:00:00Z + ${author} + ${description} + diff --git a/templates/rss_content.xml/footer.xml b/templates/rss_content.xml/footer.xml new file mode 100644 index 0000000..3a9dbde --- /dev/null +++ b/templates/rss_content.xml/footer.xml @@ -0,0 +1,2 @@ + + diff --git a/templates/rss_content.xml/header.xml b/templates/rss_content.xml/header.xml new file mode 100644 index 0000000..396ef6b --- /dev/null +++ b/templates/rss_content.xml/header.xml @@ -0,0 +1,8 @@ + + + + ${sitetitle} + ${description} + ${siteurl} diff --git a/templates/rss_content.xml/item.xml b/templates/rss_content.xml/item.xml new file mode 100644 index 0000000..780185a --- /dev/null +++ b/templates/rss_content.xml/item.xml @@ -0,0 +1,10 @@ + + ${title} + ${siteurl}/${filename} + ${siteurl}/${filename} + ${created}T00:00:00Z + ${author} + ${title} +

Last modification on

+ %{contentfile}]]>
+
diff --git a/templates/sitemap.xml/footer.xml b/templates/sitemap.xml/footer.xml new file mode 100644 index 0000000..d8521b5 --- /dev/null +++ b/templates/sitemap.xml/footer.xml @@ -0,0 +1 @@ + diff --git a/templates/sitemap.xml/header.xml b/templates/sitemap.xml/header.xml new file mode 100644 index 0000000..669269c --- /dev/null +++ b/templates/sitemap.xml/header.xml @@ -0,0 +1,2 @@ + + diff --git a/templates/sitemap.xml/item.xml b/templates/sitemap.xml/item.xml new file mode 100644 index 0000000..ceeaace --- /dev/null +++ b/templates/sitemap.xml/item.xml @@ -0,0 +1,4 @@ + + ${siteurl}/${filename} + ${updated} + diff --git a/templates/twtxt.txt/footer.txt b/templates/twtxt.txt/footer.txt new file mode 100644 index 0000000..e69de29 diff --git a/templates/twtxt.txt/header.txt b/templates/twtxt.txt/header.txt new file mode 100644 index 0000000..e69de29 diff --git a/templates/twtxt.txt/item.txt b/templates/twtxt.txt/item.txt new file mode 100644 index 0000000..864b3a3 --- /dev/null +++ b/templates/twtxt.txt/item.txt @@ -0,0 +1 @@ +${created}T00:00:00Z ${title}: ${siteurl}/${filename} diff --git a/templates/urllist.txt/item.txt b/templates/urllist.txt/item.txt new file mode 100644 index 0000000..13923ba --- /dev/null +++ b/templates/urllist.txt/item.txt @@ -0,0 +1 @@ +${siteurl}/${filename} -- cgit 1.4.1