2021-10-08 23:36:43 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
template () {
|
2021-10-11 19:13:38 +00:00
|
|
|
echo "<!doctype html>"
|
|
|
|
echo "<meta charset=utf-8>"
|
|
|
|
echo "<meta name=viewport content='width=device-width, initial-scale=1.0'>"
|
|
|
|
echo "<link rel=stylesheet href=drip.css>"
|
2022-02-01 21:12:56 +00:00
|
|
|
echo "<link rel=icon href=cowboy.svg>"
|
2021-10-11 19:13:38 +00:00
|
|
|
echo "<title>$1</title>"
|
2021-10-11 19:18:21 +00:00
|
|
|
: "${inicio:=}"
|
2021-10-08 23:36:43 +00:00
|
|
|
if test "$inicio" != true; then
|
2021-10-11 19:13:38 +00:00
|
|
|
echo "<a href=.>☚ Volver al inicio</a>"
|
2021-10-08 23:36:43 +00:00
|
|
|
fi
|
|
|
|
if test -n "$2"; then
|
2021-10-11 19:13:38 +00:00
|
|
|
echo "<header>"
|
|
|
|
echo "<h1>$1</h1>"
|
|
|
|
echo "<p><small>Último cambio: <time datetime='$(git log -1 --format=%ai "$2")'>$(date -d "@$(git log -1 --format=%at "$2")" '+%Y-%m-%d %H:%M')</time></small></p>"
|
|
|
|
echo "</header>"
|
2021-10-08 23:36:43 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-10-11 19:27:56 +00:00
|
|
|
markdown () {
|
|
|
|
# TODO: hacky
|
|
|
|
cmark --unsafe "$1" \
|
2021-12-10 14:54:21 +00:00
|
|
|
| sed "s/<a h/<a rel='noopener noreferrer' h/gi" \
|
2021-10-11 19:27:56 +00:00
|
|
|
| sed 's/\[\[\(.*\)\]\]/<a href="\1.html">\1<\/a>/g'
|
|
|
|
}
|
|
|
|
|
2021-10-08 23:36:43 +00:00
|
|
|
outdir=build
|
|
|
|
mkdir -p $outdir
|
|
|
|
# Autocopiarnos :)
|
2022-02-03 04:18:15 +00:00
|
|
|
cp ./*.sh ./*.md ./*.css ./*.png ./*.mp4 ./*.svg ./*.html "$outdir"
|
2021-10-08 23:36:43 +00:00
|
|
|
|
|
|
|
index="$outdir/index.html"
|
|
|
|
inicio=true header=false template "nulo.in" > "$index"
|
2021-10-11 19:27:56 +00:00
|
|
|
markdown index.md >> "$index"
|
2021-10-08 23:36:43 +00:00
|
|
|
|
|
|
|
for file in *.md; do
|
2021-10-11 19:10:08 +00:00
|
|
|
test "$(basename "$file")" = index.md && continue
|
2021-10-08 23:36:43 +00:00
|
|
|
title="$(basename "$file" .md)"
|
|
|
|
outfile="$outdir/$title.html"
|
|
|
|
template "$title" "$file" > "$outfile"
|
2021-10-11 19:27:56 +00:00
|
|
|
markdown "$file" >> "$outfile"
|
2021-10-08 23:36:43 +00:00
|
|
|
done
|
|
|
|
|
2021-12-10 20:44:26 +00:00
|
|
|
for file in *.gen; do
|
|
|
|
title="$(basename "$file" .gen)"
|
|
|
|
outfile="$outdir/$title.html"
|
|
|
|
template "$title" "$file" > "$outfile"
|
|
|
|
"./$file" >> "$outfile"
|
|
|
|
done
|
|
|
|
|