diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2021-01-19 18:40:31 +0100 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2021-01-19 18:40:31 +0100 |
commit | 7b0baaab2b18e7232b48297de34887650f5b8ca6 (patch) | |
tree | cc7531f4ef3b5ed012616dca290e13065e95cab4 | |
download | low-puszcza-7b0baaab2b18e7232b48297de34887650f5b8ca6.tar.gz low-puszcza-7b0baaab2b18e7232b48297de34887650f5b8ca6.zip |
Init
35 files changed, 627 insertions, 0 deletions
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/<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 <. + + # 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> 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 @@ +<p>example</p> 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 @@ +<p>example 2</p> 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 @@ +</feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="${lang}"> + <title type="text">${sitetitle}</title> + <subtitle type="text">${description}</subtitle> + <updated>${siteupdated}T00:00:00Z</updated> + <link rel="alternate" type="text/html" href="${siteurl}" /> + <id>${siteurl}/atom.xml</id> + <link rel="self" type="application/atom+xml" href="${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 @@ +<entry> + <title type="text">${title}</title> + <link rel="alternate" type="text/html" href="${siteurl}/${filename}" /> + <id>${siteurl}/${filename}</id> + <updated>${updated}T00:00:00Z</updated> + <published>${created}T00:00:00Z</published> + <author> + <name>${author}</name> + <uri>${siteurl}</uri> + </author> + <summary type="text">${description}</summary> +</entry> 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 @@ +</feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="${lang}"> + <title type="text">${sitetitle}</title> + <subtitle type="text">${description}</subtitle> + <updated>${siteupdated}T00:00:00Z</updated> + <link rel="alternate" type="text/html" href="${siteurl}" /> + <id>${siteurl}/atom.xml</id> + <link rel="self" type="application/atom+xml" href="${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 @@ +<entry> + <title type="text">${title}</title> + <link rel="alternate" type="text/html" href="${siteurl}/${filename}" /> + <id>${siteurl}/${filename}</id> + <updated>${updated}T00:00:00Z</updated> + <published>${created}T00:00:00Z</published> + <author> + <name>${author}</name> + <uri>${siteurl}</uri> + </author> + <summary type="text">${description}</summary> + <content type="html"><![CDATA[<h1>${title}</h1> + <p><strong>Last modification on </strong> <time>${updated}</time></p> + %{contentfile}]]></content> +</entry> 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 @@ + </table> + </div> + <hr> + <a href="kronika.zip">📁 Pobierz archiwum</a> + </main> + </body> +</html> 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 @@ +<!DOCTYPE html> +<html dir="ltr" lang="${lang}"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta http-equiv="Content-Language" content="${lang}" /> + <meta name="viewport" content="width=device-width" /> + <meta name="keywords" content="${keywords}" /> + <meta name="description" content="${description}" /> + <meta name="author" content="${author}" /> + <meta name="generator" content="${sitegenerator}" /> + <title>Posts - ${sitetitle}</title> + <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> + <link rel="stylesheet" href="print.css" type="text/css" media="print" /> + <link rel="alternate" href="atom.xml" type="application/atom+xml" title="${sitetitle} Atom Feed" /> + <link rel="alternate" href="atom_content.xml" type="application/atom+xml" title="${sitetitle} Atom Feed with content" /> + <link rel="icon" href="/favicon.png" type="image/png" /> + </head> + <body> + <nav id="menuwrap"> + <table id="menu" width="100%" border="0"> + <tr> + <td id="links" align="left"> + <a href="https://puszcza.netlify.app">⬅ 19 PDH Puszcza</a> | + <a href="index.html">Kronika</a> | + <a href="https://pics.niedzwiedzinski.cyou" title="Galeria zdjęć z obozów">Zdjęcia</a> | + </td> + <td id="links-contact" align="right"> + <span class="hidden"> | </span> + <a href="https://facebook.com/19pdhpuszcza">FB</a> | + <a href="https://github.com/19pdh">Git</a> | + <a href="atom_content.xml">RSS</a> | + <a href="mailto:${sitemail}" title="Wyślij maila">Mail</a> + </td> + </tr> + </table> + </nav> + <hr class="hidden" /> + <main id="mainwrap"> + <div id="main"> + <h1>Wpisy z kroniki</h1> + <table> 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 @@ +<tr><td><time>${created}</time></td><td><a href="${filename}">${title}</a></td></tr> 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 @@ + </article> + </div> + </main> + </body> +</html> 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 @@ +<!DOCTYPE html> +<html dir="ltr" lang="${lang}"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta http-equiv="Content-Language" content="${lang}" /> + <meta name="viewport" content="width=device-width" /> + <meta name="keywords" content="${keywords}" /> + <meta name="description" content="${description}" /> + <meta name="author" content="${author}" /> + <meta name="generator" content="${sitegenerator}" /> + <title>${title} - ${sitetitle}</title> + <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> + <link rel="stylesheet" href="print.css" type="text/css" media="print" /> + <link rel="alternate" href="atom.xml" type="application/atom+xml" title="${sitetitle} Atom Feed" /> + <link rel="alternate" href="atom_content.xml" type="application/atom+xml" title="${sitetitle} Atom Feed with content" /> + <link rel="icon" href="/favicon.png" type="image/png" /> + </head> + <body> + <nav id="menuwrap"> + <table id="menu" width="100%" border="0"> + <tr> + <td id="links" align="left"> + <a href="https://puszcza.netlify.app">⬅ 19 PDH Puszcza</a> | + <a href="index.html">Kronika</a> | + <a href="https://pics.niedzwiedzinski.cyou" title="Galeria zdjęć z obozów">Zdjęcia</a> | + </td> + <td id="links-contact" align="right"> + <span class="hidden"> | </span> + <a href="https://facebook.com/19pdhpuszcza">FB</a> | + <a href="https://github.com/19pdh">Git</a> | + <a href="atom_content.xml">RSS</a> | + <a href="mailto:${sitemail}" title="Wyślij maila">Mail</a> + </td> + </tr> + </table> + </nav> + <hr class="hidden" /> + <main id="mainwrap"> + <div id="main"> + <article> 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 @@ +<header> + <h1><a href="">${title}</a></h1> + <p><strong>Last modification on </strong> <time datetime="${updated}">${updated}</time></p> +</header> + +%{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 @@ +</channel> +</rss> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rss version="2.0" + xmlns:content="http://purl.org/rss/1.0/modules/content/" + xmlns:dc="http://purl.org/dc/elements/1.1/"> +<channel> + <title>${sitetitle}</title> + <description>${description}</description> + <link>${siteurl}</link> 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 @@ +<item> + <title>${title}</title> + <link>${siteurl}/${filename}</link> + <guid>${siteurl}/${filename}</guid> + <dc:date>${created}T00:00:00Z</dc:date> + <author>${author}</author> + <description>${description}</description> +</item> 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 @@ +</channel> +</rss> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rss version="2.0" + xmlns:content="http://purl.org/rss/1.0/modules/content/" + xmlns:dc="http://purl.org/dc/elements/1.1/"> +<channel> + <title>${sitetitle}</title> + <description>${description}</description> + <link>${siteurl}</link> 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 @@ +<item> + <title>${title}</title> + <link>${siteurl}/${filename}</link> + <guid>${siteurl}/${filename}</guid> + <dc:date>${created}T00:00:00Z</dc:date> + <author>${author}</author> + <description><![CDATA[<h1>${title}</h1> + <p><strong>Last modification on </strong> <time>${updated}</time></p> + %{contentfile}]]></description> +</item> 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 @@ +</urlset> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 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 @@ +<url> + <loc>${siteurl}/${filename}</loc> + <lastmod>${updated}</lastmod> +</url> diff --git a/templates/twtxt.txt/footer.txt b/templates/twtxt.txt/footer.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/templates/twtxt.txt/footer.txt diff --git a/templates/twtxt.txt/header.txt b/templates/twtxt.txt/header.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/templates/twtxt.txt/header.txt 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} |