secluded/justfile

118 lines
3.3 KiB
Makefile
Raw Normal View History

2023-03-20 01:09:00 +00:00
# Build everything then deploy
# default: site (docs "pdf") (docs "epub") (docs "txt") images deploy
default: site images deploy
2023-03-20 01:09:00 +00:00
# Deploy website
deploy:
# Deploying website ...
rsync -qavmzz public/ hel1:/var/www/secluded/
# Website deployed
# Build website
site:
# Building website ...
hugo --quiet
## Build documents of filetype ext
#docs ext:
# #!/usr/bin/env bash
#
# echo -e '\033[1m# Checking whether there are new {{uppercase(ext)}}s to generate ...\033[0m'
#
# export WEBROOT=public
#
# published=$(grep -ilr --include \*.md "draft: false" content)
#
# todo=""
#
# # Iterate through all non-drafts
# for path in $published
# do
# filename=$(basename "$path")
# name=$(echo "${filename%.*}")
# # Check whether target doc is newer than Markdown file
# if [ "$path" -nt "public/$name/$name.{{ext}}" ]
# then
# todo+="$path "
# fi
# done
#
# if [ -z "$todo" ]
# then
# echo "No {{uppercase(ext)}}s to generate"
# exit 0
# else
# for path in $todo
# do
# filename=$(basename "$path")
# name=$(echo "${filename%.*}")
# echo "Generating $name.{{ext}}"
#
# if [ "{{ext}}" == "pdf" ]
# then
# 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
# elif [ "{{ext}}" == "epub" ]
# then
# 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
# elif [ "{{ext}}" == "txt" ]
# then
# pandoc --quiet -f markdown -t plain --lua-filter=pandoc_config/images.lua $path -o public/$name/$name.txt
# fi
# done
# fi
2023-03-20 01:09:00 +00:00
# Generate cover images
images:
2023-03-20 14:51:59 +00:00
#!/usr/bin/env bash
echo -e '\033[1m# Checking whether there are cover images to generate ...\033[0m'
2023-04-03 17:13:15 +00:00
published=$(grep -ilr --include \*.md "draft: false" content)
2023-03-31 21:02:41 +00:00
todo=""
# Iterate through all non-drafts
for path in $published
do
filename=$(basename "$path")
name=$(echo "${filename%.*}")
# Check whether target doc is newer than Markdown file
if [ "$path" -nt "public/$name/cover.png" ]
then
todo+="$path "
fi
done
2023-04-11 21:33:48 +00:00
if [ "content/_index.md" -nt "public/cover.png" ]
then
2023-04-11 23:16:23 +00:00
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"
2023-04-11 21:33:48 +00:00
fi
2023-03-31 21:02:41 +00:00
if [ -z "$todo" ]
then
echo "No covers to generate"
exit 0
else
for path in $todo
do
filename=$(basename "$path")
name=$(echo "${filename%.*}")
echo "Generating cover for $name"
p2c -i $path -o public/$name/cover.png
done
fi
2023-03-20 01:09:00 +00:00
2023-05-01 17:19:03 +00:00
# Generate feeds post from OPML file in /tmp/subscriptions.opml
opml:
go install git.sr.ht/~amolith/opml2md@latest
2024-01-25 04:35:32 +00:00
opml2md -i /tmp/subscriptions.opml -o content/feeds.md -x static/feeds.opml -t opml.tmpl -g "Software Updates,Newsletters"
2023-05-01 17:19:03 +00:00
2023-03-20 01:09:00 +00:00
# Run development server
serve:
2023-05-31 17:03:50 +00:00
hugo server
# Run development server
served:
2023-03-20 01:09:00 +00:00
hugo server -D