💾 Archived View for tilde.team › ~emilis › Makefile captured on 2024-07-09 at 01:54:32.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
# 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 <https://www.gnu.org/licenses/>. # # Copyright 2020 Emilis Dambauskas <emilis@emilis.net> ### 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 "<updated>" >> $@ date --iso-8601=seconds | tr -d '\n' >> "$@" echo "</updated>" >> "$@" 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 "<entry>" >> "$@"; \ echo -n "<updated>" >> "$@"; \ date --iso-8601=seconds -r "_posts/$FILE_NAME" | tr -d "\n" >> "$@"; \ echo "</updated>" >> "$@"; \ echo "<title>$TITLE</title>" >> "$@"; \ echo "<link href=\"${BASE_URL}/$FILE_NAME\"/>" >> "$@"; \ echo "<id>${BASE_URL}/$FILE_NAME</id>" >> "$@"; \ echo "<summary />" >> "$@"; \ echo "</entry>" >> "$@"; \ ' cat "_src/atom-footer.txt" >> "$@"