commit 3a2940a9648a4a6e3b47b5a55643f357fc7e6790
parent 555bbbac1a475639b21a8ceebdd3cf0a06c742d3
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sat, 19 Aug 2023 18:22:10 +0200
Refactored build script; bye gemini
Diffstat:
3 files changed, 36 insertions(+), 67 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,20 +1,16 @@
DEST="tronto.net:/var/www/htdocs/sebastiano.tronto.net"
-DESTGEMINI="tronto.net:/var/gemini"
RSYNC=$$( (command -V rsync 2>&1 > /dev/null && echo rsync) || echo openrsync)
all: clean
./build.sh
clean:
- rm -rf http gemini
- mkdir -p http gemini
+ rm -rf http
+ mkdir -p http
-deploy: syncgemini synchttp
-
-syncgemini:
- ${RSYNC} -rv --delete --rsync-path=openrsync gemini/ ${DESTGEMINI}
+deploy: synchttp
synchttp:
${RSYNC} -rv --delete --rsync-path=openrsync http/ ${DEST}
-.PHONY: all clean deploy syncgemini synchttp
+.PHONY: all clean deploy synchttp
diff --git a/build.sh b/build.sh
@@ -2,53 +2,46 @@
recursivebuild() {
local destdir=$(echo $1 | sed 's|^src|http|')
- local destdir_gmi=$(echo $1 | sed 's|^src|gemini|')
mkdir -p "$destdir"
- mkdir -p "$destdir_gmi"
for file in $(ls $1); do
if [ -d "$1/$file" ]; then
mkdir -p "$destdir/$file"
- mkdir -p "$destdir_gmi/$file"
recursivebuild "$1/$file"
else
- extension=$(echo "$file" | sed 's/.*\.//')
- if [ "$extension" = "md" ]; then
- sed "s/TITLE/$(grep '^\# ' < "$1/$file" \
- | head -n 1 \
- | sed 's/^\# //')/" < top.html \
- > "$destdir/index.html"
- lowdown "$1/$file" >> "$destdir/index.html"
- cat bottom.html >> "$destdir/index.html"
-
- # TODO: the following lines contain a dirty fix
- # to deal with a bug in lowdown. Remove all the
- # sed lines when fixed.
- lowdown -Tgemini --gemini-link-roman \
- "$1/$file" \
- | sed '/```./i\
-```
- ' \
- | sed '/```./ s/```//' \
- > "$destdir_gmi/index.gmi"
- cat bottom.gmi >> "$destdir_gmi/index.gmi"
- elif [ "$extension" = "html" ]; then
- cat top.html "$1/$file" bottom.html \
- | sed "s/TITLE/$(grep '<!--TITLE: ' <\
- "$1/$file" \
- | sed 's/^<!--TITLE: //' \
- | sed 's/-->$//')/" \
- > "$destdir/index.html"
- elif [ "$extension" = "gmi" ]; then
- cat "$1/$file" bottom.gmi > \
- "$destdir_gmi/index.gmi"
- else
- cp "$1/$file" "$destdir/$file"
- cp "$1/$file" "$destdir_gmi/$file"
- fi
+ copyfile "$1/$file" "$destdir"
fi
done
}
+copyfile() {
+ file=$1
+ dest=$2
+ ind=$dest/index.html
+ extension=$(echo "$file" | sed 's/.*\.//')
+ case "$extension" in
+ md)
+ t="$(markdowntitle $file)"
+ sed "s/TITLE/$t/" < top.html > "$ind"
+ lowdown "$file" >> "$ind"
+ cat bottom.html >> "$ind"
+ ;;
+ html)
+ t="$(htmltitle $file)"
+ cat top.html "$file" bottom.html | sed "s/TITLE/$t/" > "$ind"
+ ;;
+ *)
+ cp "$file" "$dest/$(basename $file)"
+ esac
+}
+
+markdowntitle() {
+ grep '^# ' $1 | head -n 1 | sed 's/^# //'
+}
+
+htmltitle() {
+ grep '<!--TITLE: ' "$1" | sed 's/^<!--TITLE: //' | sed 's/-->$//'
+}
+
makeblog() {
bf=src/blog/blog.md
ff=src/blog/feed.xml
@@ -85,27 +78,5 @@ makeblog() {
echo "</rss>" >> $ff
}
-gemblog() {
- bg=gemini/blog/index.gmi
-
- printf "# Blog\n\n=> feed.xml RSS Feed\n\n" > $bg
- for i in $(ls src/blog | sort -r); do
- if [ -d src/blog/$i ]; then
- d=$(echo $i | grep -oE '^[0-9]{4}-[0-9]{2}-[0-9]{2}')
- t=$(head -n 1 src/blog/$i/*.md | sed 's/# //')
-
- thisyear=$(echo $d | sed 's/-.*//')
- if [ "$thisyear" != "$lastyear" ]; then
- printf "\n## $thisyear\n\n" >> $bg
- lastyear=$thisyear
- fi
- echo "=> $i $d $t" >> $bg
- fi
- done
- echo "" >> $bg
- cat bottom.gmi >> $bg
-}
-
makeblog
recursivebuild src
-gemblog
diff --git a/src/blog/2022-06-04-gemini/gemini.md b/src/blog/2022-06-04-gemini/gemini.md
@@ -191,3 +191,5 @@ stay html-first. This means that inline links will look a bit ugly in gemini
and, more annoyingly for the few gemini users, I am going to use
http(s) links even when a gemini counterpart is available.
+*Update: as of August 2023, my website is still available on gemini,
+but new blog posts are no longer mirrore there*