aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-08-19 18:22:10 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2023-08-19 18:22:10 +0200
commit3a2940a9648a4a6e3b47b5a55643f357fc7e6790 (patch)
treeb9226f19078297665848344c198b97080b521662
parent555bbbac1a475639b21a8ceebdd3cf0a06c742d3 (diff)
downloadsebastiano.tronto.net-3a2940a9648a4a6e3b47b5a55643f357fc7e6790.tar.gz
sebastiano.tronto.net-3a2940a9648a4a6e3b47b5a55643f357fc7e6790.zip
Refactored build script; bye gemini
-rw-r--r--Makefile12
-rwxr-xr-xbuild.sh89
-rw-r--r--src/blog/2022-06-04-gemini/gemini.md2
3 files changed, 36 insertions, 67 deletions
diff --git a/Makefile b/Makefile
index ea13048..63cd48b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,16 @@
1DEST="tronto.net:/var/www/htdocs/sebastiano.tronto.net" 1DEST="tronto.net:/var/www/htdocs/sebastiano.tronto.net"
2DESTGEMINI="tronto.net:/var/gemini"
3RSYNC=$$( (command -V rsync 2>&1 > /dev/null && echo rsync) || echo openrsync) 2RSYNC=$$( (command -V rsync 2>&1 > /dev/null && echo rsync) || echo openrsync)
4 3
5all: clean 4all: clean
6 ./build.sh 5 ./build.sh
7 6
8clean: 7clean:
9 rm -rf http gemini 8 rm -rf http
10 mkdir -p http gemini 9 mkdir -p http
11 10
12deploy: syncgemini synchttp 11deploy: synchttp
13
14syncgemini:
15 ${RSYNC} -rv --delete --rsync-path=openrsync gemini/ ${DESTGEMINI}
16 12
17synchttp: 13synchttp:
18 ${RSYNC} -rv --delete --rsync-path=openrsync http/ ${DEST} 14 ${RSYNC} -rv --delete --rsync-path=openrsync http/ ${DEST}
19 15
20.PHONY: all clean deploy syncgemini synchttp 16.PHONY: all clean deploy synchttp
diff --git a/build.sh b/build.sh
index 6e8e74e..8f3034a 100755
--- a/build.sh
+++ b/build.sh
@@ -2,53 +2,46 @@
2 2
3recursivebuild() { 3recursivebuild() {
4 local destdir=$(echo $1 | sed 's|^src|http|') 4 local destdir=$(echo $1 | sed 's|^src|http|')
5 local destdir_gmi=$(echo $1 | sed 's|^src|gemini|')
6 mkdir -p "$destdir" 5 mkdir -p "$destdir"
7 mkdir -p "$destdir_gmi"
8 for file in $(ls $1); do 6 for file in $(ls $1); do
9 if [ -d "$1/$file" ]; then 7 if [ -d "$1/$file" ]; then
10 mkdir -p "$destdir/$file" 8 mkdir -p "$destdir/$file"
11 mkdir -p "$destdir_gmi/$file"
12 recursivebuild "$1/$file" 9 recursivebuild "$1/$file"
13 else 10 else
14 extension=$(echo "$file" | sed 's/.*\.//') 11 copyfile "$1/$file" "$destdir"
15 if [ "$extension" = "md" ]; then
16 sed "s/TITLE/$(grep '^\# ' < "$1/$file" \
17 | head -n 1 \
18 | sed 's/^\# //')/" < top.html \
19 > "$destdir/index.html"
20 lowdown "$1/$file" >> "$destdir/index.html"
21 cat bottom.html >> "$destdir/index.html"
22
23 # TODO: the following lines contain a dirty fix
24 # to deal with a bug in lowdown. Remove all the
25 # sed lines when fixed.
26 lowdown -Tgemini --gemini-link-roman \
27 "$1/$file" \
28 | sed '/```./i\
29```
30 ' \
31 | sed '/```./ s/```//' \
32 > "$destdir_gmi/index.gmi"
33 cat bottom.gmi >> "$destdir_gmi/index.gmi"
34 elif [ "$extension" = "html" ]; then
35 cat top.html "$1/$file" bottom.html \
36 | sed "s/TITLE/$(grep '<!--TITLE: ' <\
37 "$1/$file" \
38 | sed 's/^<!--TITLE: //' \
39 | sed 's/-->$//')/" \
40 > "$destdir/index.html"
41 elif [ "$extension" = "gmi" ]; then
42 cat "$1/$file" bottom.gmi > \
43 "$destdir_gmi/index.gmi"
44 else
45 cp "$1/$file" "$destdir/$file"
46 cp "$1/$file" "$destdir_gmi/$file"
47 fi
48 fi 12 fi
49 done 13 done
50} 14}
51 15
16copyfile() {
17 file=$1
18 dest=$2
19 ind=$dest/index.html
20 extension=$(echo "$file" | sed 's/.*\.//')
21 case "$extension" in
22 md)
23 t="$(markdowntitle $file)"
24 sed "s/TITLE/$t/" < top.html > "$ind"
25 lowdown "$file" >> "$ind"
26 cat bottom.html >> "$ind"
27 ;;
28 html)
29 t="$(htmltitle $file)"
30 cat top.html "$file" bottom.html | sed "s/TITLE/$t/" > "$ind"
31 ;;
32 *)
33 cp "$file" "$dest/$(basename $file)"
34 esac
35}
36
37markdowntitle() {
38 grep '^# ' $1 | head -n 1 | sed 's/^# //'
39}
40
41htmltitle() {
42 grep '<!--TITLE: ' "$1" | sed 's/^<!--TITLE: //' | sed 's/-->$//'
43}
44
52makeblog() { 45makeblog() {
53 bf=src/blog/blog.md 46 bf=src/blog/blog.md
54 ff=src/blog/feed.xml 47 ff=src/blog/feed.xml
@@ -85,27 +78,5 @@ makeblog() {
85 echo "</rss>" >> $ff 78 echo "</rss>" >> $ff
86} 79}
87 80
88gemblog() {
89 bg=gemini/blog/index.gmi
90
91 printf "# Blog\n\n=> feed.xml RSS Feed\n\n" > $bg
92 for i in $(ls src/blog | sort -r); do
93 if [ -d src/blog/$i ]; then
94 d=$(echo $i | grep -oE '^[0-9]{4}-[0-9]{2}-[0-9]{2}')
95 t=$(head -n 1 src/blog/$i/*.md | sed 's/# //')
96
97 thisyear=$(echo $d | sed 's/-.*//')
98 if [ "$thisyear" != "$lastyear" ]; then
99 printf "\n## $thisyear\n\n" >> $bg
100 lastyear=$thisyear
101 fi
102 echo "=> $i $d $t" >> $bg
103 fi
104 done
105 echo "" >> $bg
106 cat bottom.gmi >> $bg
107}
108
109makeblog 81makeblog
110recursivebuild src 82recursivebuild src
111gemblog
diff --git a/src/blog/2022-06-04-gemini/gemini.md b/src/blog/2022-06-04-gemini/gemini.md
index db258e8..b04a8ac 100644
--- 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
191and, more annoyingly for the few gemini users, I am going to use 191and, more annoyingly for the few gemini users, I am going to use
192http(s) links even when a gemini counterpart is available. 192http(s) links even when a gemini counterpart is available.
193 193
194*Update: as of August 2023, my website is still available on gemini,
195but new blog posts are no longer mirrore there*

Generated with cgit - Back to sebastiano.tronto.net