diff options
Diffstat (limited to 'web/mount-ave')
-rwxr-xr-x | web/mount-ave | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/web/mount-ave b/web/mount-ave new file mode 100755 index 0000000..e3b9ad9 --- /dev/null +++ b/web/mount-ave @@ -0,0 +1,34 @@ +#!/bin/sh +# Updates the Mount Avenue tracker - to do this, an entry must be made in +# trk/mount-avenue, and then this is copied over to the website where a new +# entry is made, by replacing the contents of <!-- ma:begin --> and +# <!-- ma:end -->. + +# Constants # +WEBPAGE_PATH="$BLOG_PATH/training/mount-ave.html" +DELIMITER_BEGIN="<!-- ma:begin -->" +DELIMITER_END="<!-- ma:end -->" +TABLE_FILE='/tmp/ma-tbl-formatted' + +trk_path="$(orgdresolv "ORGD_TRK_PATH")"/mount-avenue + + +# Modify the document and check for changes. +hash_before="$(sha256sum "$trk_path")" +trk mount-avenue +hash_after="$(sha256sum "$trk_path")" + +if [ "$hash_before" = "$hash_after" ] ; then + echo "No changes made - exitting early." + exit 0 +fi +table_formatted="$(ma-fmt-tbl "$trk_path")" + +echo "$table_formatted" > "$TABLE_FILE" +sed -i -ne "/$DELIMITER_BEGIN/ {p; r $TABLE_FILE" -e ":a; n; /$DELIMITER_END/ {p; b}; ba}; p" "$WEBPAGE_PATH" + +# Commit and push the changes +cd "$(dirname "$WEBPAGE_PATH")" +git add "$(basename "$WEBPAGE_PATH")" +git commit -m "Mount Avenue: updated $(date +"%Y-%m-%d %H:%M")" +git-push-all |