A Makefile-powered gemlog
This is my first post in my new gemlog.
I am generating the pages with some shell scripts in a single Makefile.
Source code
Makefile:
CURRENT_YEAR= $(shell date +%Y)
FIND_POSTS= find _posts -type f -name \*gmi -printf '%P\0'
SERVER_PATH= tilde.team:public_gemini
.PHONY: default
default: build
.PHONY: deploy
deploy:
rsync -rv \
--exclude=.git \
--exclude=.gitignore \
--exclude=Makefile \
--exclude=_posts \
--exclude=_src \
./ "${SERVER_PATH}/"
.PHONY: build
build: index.gmi
index.gmi: Makefile _src ${CURRENT_YEAR}
cat _src/index-header.gmi > index.gmi
find 20* -type f -name \*.gmi \
| sort -r \
| head -10 \
| xargs grep -H -m 1 -E '^# ' \
| sed -E -e 's/^([0-9]{4})\/([0-9]{2})\/([0-9]{2})([^#]+).gmi:# /=> \1\/\2\/\3\4.gmi \1-\2-\3 /g' \
>> index.gmi
cat _src/index-footer.gmi >> index.gmi
${CURRENT_YEAR}: Makefile _src _posts
rm -rf ${CURRENT_YEAR}/*
${FIND_POSTS} | xargs -0 dirname | sort | uniq | xargs mkdir -p
${FIND_POSTS} | xargs -0 -n 1 -I {} \
bash -c 'cat _src/post-header.gmi _posts/{} _src/post-footer.gmi > {}'
_src/index-header.gmi:
# ~emilis Site
## Gemlog entries:
_src/index-footer.gmi:
## Other:
=> pirmas-lietuviškas-puslapis.gmi The first Gemini page in Lithuanian language.
_src/post-header.gmi: (currently empty)
_src/post-footer.gmi:
--- --- ---
=> /~emilis/ Back to ~emilis Home
■
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
If you want to reply to this post, email me your reply or a gemini:// link to emilis [at] emilis.net.
Back to ~emilis Home
Atom feed
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
SPDX-License-Identifier: CC-BY-NC-SA-4.0