# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Copyright 2020 Emilis Dambauskas ### Instructions --------------------------------------------------------------- # # Example directory structure to get you started: # . # ├── Makefile # ├── _posts # │   └── 2020 # │   └── 11 # │   └── 16-first-post.gmi # └── _src # ├── index-footer.gmi # ├── index-header.gmi # ├── post-footer.gmi # ├── post-header.gmi # ├── rss-footer.txt # └── rss-header.txt # # Run `make`. # # It will add these files: # # . # ├── 2020 # │   └── 11 # │   └── 16-first-post.gmi # ├── atom.xml # ├── feed.gmi # ├── index.gmi # # If you are going to use Git to version your files. You can add this to a # .gitignore: # # /2020/ # atom.xml # index.gmi # feed.gmi ### Variables: ----------------------------------------------------------------- AUTHOR= ~emilis BASE_URL= gemini://tilde.team/~emilis CURRENT_YEAR= $(shell date +%Y) FIND_POSTS= find _posts -type f -name \*gmi -printf '%P\0' SERVER_PATH= tilde.team:public_gemini ### Tasks ---------------------------------------------------------------------- .PHONY: default default: build .PHONY: build build: \ atom.xml \ index.gmi \ feed.gmi \ feed.xml \ ${CURRENT_YEAR} .PHONY: deploy deploy: rsync -rv \ --exclude=.git \ --exclude=.gitignore \ --exclude=_posts \ --exclude=_src \ ./ "${SERVER_PATH}/" ### Targets -------------------------------------------------------------------- ${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 > {}' index.gmi: Makefile _src ${CURRENT_YEAR} cat "_src/index-header.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' \ >> "$@" cat _src/index-footer.gmi >> "$@" feed.gmi: Makefile ${CURRENT_YEAR} echo "# ${AUTHOR}" > "$@" find 20* -type f -name \*.gmi \ | sort -r \ | head -20 \ | 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' \ >> "$@" feed.xml: atom.xml cp atom.xml feed.xml atom.xml: Makefile _src ${CURRENT_YEAR} cat "_src/atom-header.txt" > "$@" echo -n "" >> $@ date --iso-8601=seconds | tr -d '\n' >> "$@" echo "" >> "$@" find 20* -type f -name \*.gmi \ | sort -r \ | head -20 \ | xargs grep -H -m 1 -E '^# ' \ | xargs -d '\n' -n 1 -I {} \ bash -c ' \ FILE_NAME=`echo "{}" | sed -E -e "s/.gmi:#.*$$/.gmi/"`; \ TITLE=`echo "{}" | sed -E -e "s/^.*.gmi:# //"`; \ echo "" >> "$@"; \ echo -n "" >> "$@"; \ date --iso-8601=seconds -r "_posts/$$FILE_NAME" | tr -d "\n" >> "$@"; \ echo "" >> "$@"; \ echo "$$TITLE" >> "$@"; \ echo "" >> "$@"; \ echo "${BASE_URL}/$$FILE_NAME" >> "$@"; \ echo "" >> "$@"; \ echo "" >> "$@"; \ ' cat "_src/atom-footer.txt" >> "$@" gemini://tilde.team/~emilis/Makefile

-- Leo's gemini proxy

-- Connecting to tilde.team:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/plain

-- Response ended

-- Page fetched on Fri May 3 19:16:02 2024