sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 4ac91a1a07cc9186cbe8536f4dbd384fc569bf66
parent 62e2a0f9aff22892cc8c2270655b82d3ccb54db9
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu,  6 Sep 2018 21:24:01 +0200

use heredocs instead of files scattered around

Given how ad-hoc is the script, there is no need for such a strong
separation between the content and the script.

Using heredocs make it also easier to edit the whole layout.

Diffstat:
Abuild | 1+
Abuild-page | 138+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddomains | 7-------
Dfoot.html | 5-----
Dhead.html | 14--------------
Dlinks.html | 4----
Dmake | 90-------------------------------------------------------------------------------
7 files changed, 139 insertions(+), 120 deletions(-)

diff --git a/build b/build @@ -0,0 +1 @@ +find * -type d -exec sh -exc './build-page "$0" >$0/index.html' {} \; diff --git a/build-page b/build-page @@ -0,0 +1,138 @@ +#!/bin/sh -e + +# Given a directory name, generate a static page out of: +# - ./**/index.md - the markdown files +# - ./title - the title of the website +# - ./domains - file with one domain per line (corresponding to ./<domain>/) +# - ./*/title - one file per subdirectory with the subtitle + + +## setup ## + +page="$1/index.md" +this_domain="${page%%/*}" + +domain_list=' + home.suckless.org + dwm.suckless.org + st.suckless.org + core.suckless.org + surf.suckless.org + tools.suckless.org + libs.suckless.org +' + + +## functions ## + +#1 current page +#2 directory to list +nav() { + ls "$2" | while IFS= read dir + do + test -d "$2/$dir" || continue + expr "$1" : "$2/$dir/." >/dev/null && + match=' class="thisPage"' || + match= + printf '<li><a%s href="%s">' "$match" "//$2/$dir/" + printf '%s/</a>' "$dir" | tr _- ' ' + if test "$match" + then + printf '<ul>\n' + nav "$1" "$2/$dir" + printf '</ul>\n' + fi + printf '</li>\n' + done +} + + +## header ## + +test -f "$page" && + title=$(sed 's,^#* *,,; q' "$page") || + title=$(basename "$(dirname "$page")") + +cat <<EOF +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <title>$title | suckless.org software that sucks less</title> + <link rel="stylesheet" type="text/css" href="//suckless.org/pub/style.css"> +</head> + +<div id="header"> + <a href="//suckless.org/"><img src="//suckless.org/logo.svg"/></a> + <a id="headerLink" href="//suckless.org/">suckless.org</a> + <span id="headerSubtitle">$subtitle</span> +</div> +EOF + + +## nav bar ## + +printf '<div id="menu">\n' +for domain in $domain_list +do + printf '<a href="%s"' "//$domain" + test "$this_domain" = "$domain" && printf ' class="thisSite"' + printf '">%s</a>\n' "${domain%%.*}" +done + +cat <<EOF +<span class="right"> + <a href="//dl.suckless.org">download</a> + <a href="//git.suckless.org">source</a> +</span> +EOF + +printf '</div>\n\n' + + +printf '<div id="content">\n\n' + + +## menu panel ## + +printf '<div id="nav">\n<ul>\n<li><a' +test "${page%/*}" = "$this_domain" && printf ' class="thisPage"' +printf ' href="/">about</a></li>' +nav "$page" "$this_domain" +printf '</ul>\n</div>\n\n' + + +## content ## + +printf '<div id="main">\n' +if test -f "$page" +then + smu "$page" +else + printf '<ul>\n' + ls "${page%/index.md}" | while IFS= read -r dir + do + path=${page%/index.md}/$dir/ + test -d "$path" || continue + printf '<li><a href="%s">' "//$path" + printf '%s</a></li>\n' "$dir" | tr _- ' ' + done + printf '</ul>\n' +fi +printf '</div>\n\n' + + +printf '</div>\n\n' # end of id="content" + + +## footer ## + +cat <<EOF +<div id="footer"> +<span class="right"> +&copy; 2006-2018 suckless.org community +| <a href="//ev.suckless.org/impressum">Impressum</a> +| <a href="//ev.suckless.org">e.V.</a> +</span> +</div> +EOF diff --git a/domains b/domains @@ -1,7 +0,0 @@ -home.suckless.org -dwm.suckless.org -st.suckless.org -core.suckless.org -surf.suckless.org -tools.suckless.org -libs.suckless.org diff --git a/foot.html b/foot.html @@ -1,5 +0,0 @@ -<div id="footer"> -<span class="right"> -&copy; 2006-2018 suckless.org community | <a href="//ev.suckless.org/impressum">Impressum</a> | <a href="//ev.suckless.org">e.V.</a> -</span> -</div> diff --git a/head.html b/head.html @@ -1,14 +0,0 @@ -<!doctype html> -<html> -<head> -<link rel="stylesheet" type="text/css" href="/static/css/banner-styles.css?v=1533593143.0" /> -<link rel="stylesheet" type="text/css" href="/static/css/iconochive.css?v=1533593143.0" /> -<title>%t | suckless.org software that sucks less</title> -<link rel="stylesheet" type="text/css" href="//suckless.org/pub/style.css"> -<meta charset="utf-8"> -</head> -<body> -<div id="header"> - <a href="//suckless.org/"><img src="//suckless.org/logo.svg"/></a> - <a id="headerLink" href="//suckless.org/">suckless.org</a> <span id="headerSubtitle">%s</span> -</div> diff --git a/links.html b/links.html @@ -1,4 +0,0 @@ -<span class="right"> - <a href="//dl.suckless.org">download</a> - <a href="//git.suckless.org">source</a> -</span> diff --git a/make b/make @@ -1,90 +0,0 @@ -#!/bin/sh -e - -# Generate a static website out of: -# - ./**.md - the markdown files. Must be "*/index.md" -# - ./title - the title of the website -# - ./domains - file with one domain per line (corresponding to ./<domain>/) -# - ./*/title - one file per subdirectory with the subtitle -# - ./head.html - content added at the top, -# - ./foot.html - content added at the bottom, -# - ./links.html - content added at the right side of the navigation bar, - -#1 current page -#2 directory to list -nav() { - ls "$2" | while read dir - do - test -d "$2/$dir" || continue - test -z "${1##$2/$dir/*?}" && match=' class="thisPage"' || match= - printf '<li><a%s href="%s">' "$match" "//$2/$dir/" - printf '%s/</a>' "$dir" | tr _- ' ' - if test "$match" - then - printf '<ul>\n' - nav "$1" "$2/$dir" - printf '</ul>\n' - fi - printf '</li>\n' - done -} - -find * -type d | while IFS='' read -r page -do - exec >$page/index.html - page="$page/index.md" - this_domain="${page%%/*}" - printf 'Generating %s\n' "$page" 1>&2 - - # header - if test -f "$page" - then - title=$(sed 's,^#* *,,; q' "$page") - else - title=$(basename "$(dirname "$page")") - fi - awk -v title="$title" -v subtitle="$(cat "$this_domain/title")" \ - '{ gsub("%t", title); gsub("%s", subtitle); print; }' head.html - - # navigation bar - printf '<div id="menu">\n' - while IFS='' read -r domain - do - printf '<a href="%s"' "//$domain" - test "$this_domain" = "$domain" && printf ' class="thisSite"' - printf '">%s</a>\n' "${domain%%.*}" - done <domains - cat links.html - printf '</div>\n\n' - - printf '<div id="content">\n\n' - - # left navigation panel - printf '<div id="nav">\n<ul><li><a' - test "${page%/*}" = "$this_domain" && printf ' class="thisPage"' - printf ' href="/">about</a></li>' - nav "$page" "$this_domain" - printf '</ul></div>\n\n' - - # main - printf '<div id="main">\n' - if test -f "$page" - then - smu "$page" - else - printf '<ul>\n' - ls "${page%/index.md}" | while IFS='' read -r dir - do - path=${page%/index.md}/$dir/ - test -d "$path" || continue - printf '<li><a href="%s">' "//$path" - printf '%s</a></li>\n' "$dir" | tr _- ' ' - done - printf '</ul>\n' - fi - printf '</div>\n\n' - - printf '</div>\n\n' # end of id="content" - - # footer - cat foot.html -done