aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile21
-rw-r--r--dynamic.mk18
-rw-r--r--src/development/config.env5
-rwxr-xr-xsrc/development/dynmake.sh22
-rwxr-xr-xsrc/development/genhtml.sh112
-rwxr-xr-xtests/assert-frontmatter.sh3
6 files changed, 165 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 4773052..fd63df5 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,7 @@ torrents-in = \
torrents = $(torrents-in:=.torrent)
derived-assets = \
+ $(pastebins) \
$(lilypond) \
$(favicons) \
$(podcasts.ogg) \
@@ -50,8 +51,21 @@ derived-assets = \
TODOs.html \
-all: public
+all: public dynamic
+
+dynamic: generated.mk
+ $(MAKE) -f dynamic.mk all
+
+JEKYLL_COMPAT: deps.mk files.mk
+ sh src/development/JEKYLL_COMPAT/copy-content.sh
+
+generated.mk: ALWAYS JEKYLL_COMPAT
+ sh src/development/dynmake.sh > $@
+
+# NOOP rule to assert that the targets that depend on it are
+# always considered stale.
+ALWAYS:
$(lilypond.pdf): $(lilypond.midi)
@@ -70,6 +84,7 @@ deps.mk: torrent-files.txt
awk '{ printf "%s.torrent: %s\n", $$1, $$1 }' torrent-files.txt >> $@
$(torrents): files.mk deps.mk
+ $(MAKE) generated.mk
$(MAKE) -f dynamic.mk torrents
static/lord-favicon.png: static/lord-favicon.svg
@@ -100,7 +115,9 @@ clean:
rm -rf \
public/ .jekyll-cache \
$(derived-assets) \
- torrent-files.txt files.mk deps.mk
+ torrent-files.txt files.mk deps.mk \
+ src/content/ generated.mk \
+
JEKYLL = JEKYLL_ENV=production jekyll
public: $(derived-assets)
diff --git a/dynamic.mk b/dynamic.mk
index 89791c9..c02d934 100644
--- a/dynamic.mk
+++ b/dynamic.mk
@@ -1,3 +1,13 @@
+.POSIX:
+
+.SUFFIXES: .md .env .html
+
+.md.env:
+ sh src/development/frontmatter-env.sh < $< > $@
+
+.md.html:
+ sh src/development/genhtml.sh $< > $@
+
include files.mk
include deps.mk
@@ -5,3 +15,11 @@ torrents: $(torrent-files)
$(torrent-files): files.mk deps.mk
mktorrent -f -v -d -n $@ -o $@ -c '' "$$(echo $@ | sed 's/\.torrent$$//')"
+
+
+include generated.mk
+
+pastebins.env = $(pastebins.md:.md=.env)
+pastebins.html = $(pastebins.md:.md=.html)
+
+all: $(pastebins.env) $(pastebins.html)
diff --git a/src/development/config.env b/src/development/config.env
new file mode 100644
index 0000000..69466be
--- /dev/null
+++ b/src/development/config.env
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+FQDN='euandre.org'
+BASE_URL='' # '/subfolder'
+lang=en
diff --git a/src/development/dynmake.sh b/src/development/dynmake.sh
index 3f173da..9c60b88 100755
--- a/src/development/dynmake.sh
+++ b/src/development/dynmake.sh
@@ -4,7 +4,7 @@ set -eu
usage() {
cat <<-'EOF'
Usage:
- dynmake.sh -n VARNAME -d DIR
+ dynmake.sh
dynmake.sh -h
EOF
}
@@ -32,14 +32,8 @@ for flag in "$@"; do
esac
done
-while getopts 'd:n:h' flag; do
+while getopts 'h' flag; do
case "$flag" in
- d)
- DIR="$OPTARG"
- ;;
- n)
- NAME="$OPTARG"
- ;;
h)
usage
help
@@ -55,18 +49,18 @@ shift $((OPTIND - 1))
assert_arg() {
if [ -z "$1" ]; then
- printf 'Missing %s.' "$2" >&2
+ printf 'Missing %s.\n' "$2" >&2
exit 2
fi
}
-assert_arg "${DIR:-}" '-d DIR'
-assert_arg "${NAME:-}" '-n NAME'
-
-printf '%s = \\\n' "$NAME"
-find "$DIR" -type f |
+printf 'pastebins.md = \\\n'
+find src/content/pastebin -name '*.md' |
sed -e 's/^/ /' \
-e 's/$/ \\/'
printf '\n'
+
+find src/content/pastebin -name '*.md' |
+ sed 's/^\(.*\)\.md$/\1.html: \1.env/'
diff --git a/src/development/genhtml.sh b/src/development/genhtml.sh
new file mode 100755
index 0000000..34588ef
--- /dev/null
+++ b/src/development/genhtml.sh
@@ -0,0 +1,112 @@
+#!/bin/sh
+set -eu
+
+MD="$1"
+
+escape() {
+ sed 's/a/a/'
+}
+
+url_for() {
+ printf 'https://%s%s%s' "$FQDN" "$BASE_URL" "$1"
+}
+
+_() {
+ printf '%s' "$1"
+}
+
+# FIXME
+langs='en pt fr eo es'
+# langs=''
+. src/development/config.env
+. "${MD%.md}.env"
+
+cat <<-EOF
+ <!DOCTYPE html>
+ <html lang="$lang">
+ <head>
+ <meta charset="UTF-8" />
+ <meta viewport content="width=device-width, initial-scale=1" />
+ <link rel="stylesheet" type="text/css" href="$(url_for '/static/styles.css')" />
+ <link rel="icon" type="image/svg+xml" href="$(url_for '/static/lord-favicon.svg')" />
+ <link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for '/feed.articles.en.atom')" title="$(_ "EuAndreh's blog" | escape)" />
+ <link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for '/feed.tils.en.atom')" title="$(_ "EuAndreh's TIL" | escape)" />
+ <link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for '/feed.podcasts.en.atom')" title="$(_ "EuAndreh's podcasts" | escape)" />
+ <link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for '/feed.screencasts.en.atom')" title="$(_ "EuAndreh's screencasts" | escape)" />
+
+ <title>EuAndreh</title>
+
+ <meta name="author" content="EuAndreh" />
+ <meta property="og:site_name" content="$(_ 'FIXME 1')" />
+ <meta property="og:locale" content="$lang" />
+ <meta property="og:title" content="$(_ 'FIXME 2')" />
+
+ <link rel="canonical" href="$(url_for '/')" />
+ <meta property="og:url" content="$(url_for '/')" />
+ <!-- FIXME: link to next and prev -->
+ </head>
+ <body>
+ <header>
+ <nav>
+ <ul>
+ <a href="$(url_for "/$lang/")">$(_ 'FIXME homepage link name')</a>
+ <a href="$(url_for "$(_ '/about.html')")">$(_ 'About')</a>
+ </ul>
+EOF
+
+if [ -n "$langs" ]; then
+ printf ' <ul>\n'
+ for l in $langs; do
+ cat <<-EOF
+ <li>
+ <a href="FIXME 3">$l</a>
+ </li>
+ EOF
+ done
+ printf ' </ul>\n'
+fi
+
+cat <<-EOF
+ </nav>
+ </header>
+ <main>
+ <article>
+EOF
+
+awk '
+ BEGIN {
+ separator = 0
+ should_print = 0
+ }
+
+ /^---$/ {
+ separator++
+ }
+
+ should_print {print}
+
+ separator == 2 && !should_print { should_print = !should_print }
+' "$MD" |
+ md2html
+
+cat <<-EOF
+ </article>
+ </main>
+ <footer>
+ <ul>
+ <li>
+ <img class="FIXME" src="$(url_for '/static/envelog.svg' alt="FIXME")" />
+ <a href="mailto:eu@euandre.org">eu@euandre.org</a>
+ </li>
+ <li>
+ <img class="FIXME" src="$(url_for '/static/lock.svg' alt="FIXME")" />
+ <a href="$(url_for '/static/public.asc')">81F90EC3CD356060</a>
+ </li>
+ </ul>
+ <p>
+ $(_ 'The content for this site is licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>. The <a href="https://euandreh.xyz/website.git">code</a> is <a rel="license" href="https://euandreh.xyz/website.git/tree/COPYING">AGPLv3 or later</a>. Patches welcome.')
+ </p>
+ </footer>
+ </body>
+ </html>
+EOF
diff --git a/tests/assert-frontmatter.sh b/tests/assert-frontmatter.sh
new file mode 100755
index 0000000..d9f58bf
--- /dev/null
+++ b/tests/assert-frontmatter.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+# all have the attribute "lang"