1# Build everything then deploy
2# default: site (docs "pdf") (docs "epub") (docs "txt") images deploy
3default: site images deploy
4
5# Deploy website
6deploy:
7 # Deploying website ...
8 rsync -qavmzz public/ hel1:/var/www/secluded/
9 # Website deployed
10
11# Build website
12site:
13 # Building website ...
14 hugo --quiet
15
16## Build documents of filetype ext
17#docs ext:
18# #!/usr/bin/env bash
19#
20# echo -e '\033[1m# Checking whether there are new {{uppercase(ext)}}s to generate ...\033[0m'
21#
22# export WEBROOT=public
23#
24# published=$(grep -ilr --include \*.md "draft: false" content)
25#
26# todo=""
27#
28# # Iterate through all non-drafts
29# for path in $published
30# do
31# filename=$(basename "$path")
32# name=$(echo "${filename%.*}")
33# # Check whether target doc is newer than Markdown file
34# if [ "$path" -nt "public/$name/$name.{{ext}}" ]
35# then
36# todo+="$path "
37# fi
38# done
39#
40# if [ -z "$todo" ]
41# then
42# echo "No {{uppercase(ext)}}s to generate"
43# exit 0
44# else
45# for path in $todo
46# do
47# filename=$(basename "$path")
48# name=$(echo "${filename%.*}")
49# echo "Generating $name.{{ext}}"
50#
51# if [ "{{ext}}" == "pdf" ]
52# then
53# pandoc --quiet -f markdown -t pdf --lua-filter=pandoc_config/images.lua --pdf-engine=xelatex -V 'linkcolor:blue' --listings -H pandoc_config/styles.tex $path -o public/$name/$name.pdf
54# elif [ "{{ext}}" == "epub" ]
55# then
56# pandoc --quiet -f markdown -t epub3 --lua-filter=pandoc_config/images.lua --pdf-engine=xelatex -V 'linkcolor:blue' --listings -H pandoc_config/styles.tex $path -o public/$name/$name.epub
57# elif [ "{{ext}}" == "txt" ]
58# then
59# pandoc --quiet -f markdown -t plain --lua-filter=pandoc_config/images.lua $path -o public/$name/$name.txt
60# fi
61# done
62# fi
63
64# Generate cover images
65images:
66 #!/usr/bin/env bash
67
68 echo -e '\033[1m# Checking whether there are cover images to generate ...\033[0m'
69
70 published=$(grep -ilr --include \*.md "draft: false" content)
71
72 todo=""
73
74 # Iterate through all non-drafts
75 for path in $published
76 do
77 filename=$(basename "$path")
78 name=$(echo "${filename%.*}")
79 # Check whether target doc is newer than Markdown file
80 if [ "$path" -nt "public/$name/cover.png" ]
81 then
82 todo+="$path "
83 fi
84 done
85
86 if [ "content/_index.md" -nt "public/cover.png" ]
87 then
88 p2c -o public/cover.png -t "A Secluded Home" -s "Personal corner of the web for a musician, developer, sysadmin, podcaster, and small business owner"
89 fi
90
91 if [ -z "$todo" ]
92 then
93 echo "No covers to generate"
94 exit 0
95 else
96 for path in $todo
97 do
98 filename=$(basename "$path")
99 name=$(echo "${filename%.*}")
100 echo "Generating cover for $name"
101
102 p2c -i $path -o public/$name/cover.png
103 done
104 fi
105
106# Generate feeds post from OPML file in /tmp/subscriptions.opml
107opml:
108 go install git.sr.ht/~amolith/opml2md@latest
109 opml2md -i /tmp/subscriptions.opml -o content/feeds.md -x static/feeds.opml -t opml.tmpl -g "Software updates,Newsletters"
110
111# Run development server
112serve:
113 hugo server
114
115# Run development server
116served:
117 hugo server -D