From 8441ab71f334714d48f34a6e0fcc8a2e6f7aa8bb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 30 Apr 2021 09:56:31 +0100 Subject: can generate atom.xml gemini and http feeds --- buetow.org.conf | 12 +-- buetow.org.sh | 86 ++++++++++++++++------ content/gemtext/gemfeed/atom.xml | 12 +-- content/html/gemfeed/atom.xml | 31 ++++++++ ...-22-dtail-the-distributed-log-tail-program.meta | 5 ++ .../2021-04-24-welcome-to-the-geminispace.meta | 5 ++ header.html | 2 +- 7 files changed, 119 insertions(+), 34 deletions(-) create mode 100644 content/html/gemfeed/atom.xml create mode 100644 content/meta/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.meta create mode 100644 content/meta/gemfeed/2021-04-24-welcome-to-the-geminispace.meta diff --git a/buetow.org.conf b/buetow.org.conf index ba65a8cc..afe8b942 100644 --- a/buetow.org.conf +++ b/buetow.org.conf @@ -1,5 +1,7 @@ -declare -r DOMAIN=buetow.org -declare -r CONTENT_DIR=./content -declare -r AUTHOR="Paul Buetow" -declare -r EMAIL="comments@mx.buetow.org" -declare -r IMAGE_PATTERN='\.(jpg|png|gif)$' +readonly DOMAIN=buetow.org +readonly SUBTITLE='Having fun with computers!' +readonly CONTENT_DIR=./content +readonly AUTHOR='Paul Buetow' +readonly EMAIL='comments@mx.buetow.org' +readonly IMAGE_PATTERN='\.(jpg|png|gif)$' +readonly ATOM_MAX_ENTRIES=42 diff --git a/buetow.org.sh b/buetow.org.sh index 5275c3de..191f99eb 100755 --- a/buetow.org.sh +++ b/buetow.org.sh @@ -25,46 +25,85 @@ ERROR ## Atom module +atom::meta () { + local -r now=$1; shift + local -r gmi_file_path=$1; shift + local -r meta_file=$(sed 's|gemtext|meta|; s|.gmi$|.meta|;' <<< $gmi_file_path) + + local -r meta_dir=$(dirname $meta_file) + test ! -d $meta_dir && mkdir -p $meta_dir + + if [ ! -f $meta_file ]; then + # Extract first heading as post title. + local title=$(sed -n '/^# / { s/# //; p; q; }' $gmi_file_path) + # Extract first paragraph from Gemtext + local summary=$(sed -n '/^[A-Z]/ { p; q; }' $gmi_file_path) + + echo 'local meta_post_is_new=1' + cat < $atom.tmp + cat < $atom_file.tmp $DOMAIN feed - Putting the dot before the org! + $SUBTITLE gemini://$DOMAIN - $updated + $now ATOMHEADER - ls $gemfeed_dir | sort -r | grep '.gmi$' | while read post; do - local title=$(sed -n '/^# / { s/# //; p; q; }' $gemfeed_dir/$post) - local first_paragraph=$(sed -n '/^[A-Z]/ { p; q; }' $gemfeed_dir/$post) - cat <> $atom.tmp + while read gmi_file; do + # Load cached meta information about the post. + source <(atom::meta $now $gemfeed_dir/$gmi_file) + test $meta_post_is_new -eq 1 && changed=1 + + cat <> $atom_file.tmp - $title - - gemini://$DOMAIN/gemfeed/$post - $updated - $first_paragraph... + $meta_title + + gemini://$DOMAIN/gemfeed/$gmi_file + $meta_date + $meta_summary - $AUTHOR - $EMAIL + $meta_author + $meta_email ATOMENTRY - done + done < <(ls $gemfeed_dir | sort -r | grep '.gmi$' | head -n $ATOM_MAX_ENTRIES) - cat <> $atom.tmp + cat <> $atom_file.tmp ATOMFOOTER - mv $atom.tmp $atom - git add $atom + if [ $changed -eq 1 ]; then + echo "Feed got something new!" + mv $atom_file.tmp $atom_file + git add $atom_file + else + echo "Nothing really new in the feed" + rm $atom_file.tmp + fi } ## HTML module @@ -196,7 +235,8 @@ html::gemini2html () { } html::generate () { - find $CONTENT_DIR/gemtext -type f -name \*.gmi | while read src; do + find $CONTENT_DIR/gemtext -type f -name \*.gmi | + while read src; do local dest=${src/gemtext/html} dest=${dest/.gmi/.html} local dest_dir=$(dirname $dest) @@ -209,7 +249,8 @@ html::generate () { done # Add non-.gmi files to html dir. - find $CONTENT_DIR/gemtext -type f | egrep -v '(.gmi|atom.xml)$' | while read src; do + find $CONTENT_DIR/gemtext -type f | egrep -v '(.gmi|atom.xml|.tmp)$' | + while read src; do local dest=${src/gemtext/html} local dest_dir=$(dirname $dest) test ! -d $dest_dir && mkdir -p $dest_dir @@ -221,6 +262,7 @@ html::generate () { sed 's|.gmi|.html|g; s|gemini://|http://|g' \ < $CONTENT_DIR/gemtext/gemfeed/atom.xml \ > $CONTENT_DIR/html/gemfeed/atom.xml + git add $CONTENT_DIR/html/gemfeed/atom.xml # Remove obsolete files from ./html/ find $CONTENT_DIR/html -type f | while read src; do diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml index 77d00c27..1a80832b 100644 --- a/content/gemtext/gemfeed/atom.xml +++ b/content/gemtext/gemfeed/atom.xml @@ -1,19 +1,19 @@ buetow.org feed - Putting the dot before the org! + Having fun with computers! gemini://buetow.org - 2021-04-30T07:34:28+01:00 + 2021-04-30T09:53:18+01:00 Welcome to the Geminispace gemini://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.gmi - 2021-04-30T07:34:28+01:00 + 2021-04-30T09:53:18+01:00 Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:... - Paul Buetow + Paul comments@mx.buetow.org @@ -21,10 +21,10 @@ DTail - The distributed log tail program gemini://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.gmi - 2021-04-30T07:34:28+01:00 + 2021-04-30T09:53:18+01:00 This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too.... - Paul Buetow + Paul comments@mx.buetow.org diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml new file mode 100644 index 00000000..fe72f8cf --- /dev/null +++ b/content/html/gemfeed/atom.xml @@ -0,0 +1,31 @@ + + + buetow.org feed + Having fun with computers! + + + http://buetow.org + 2021-04-30T09:53:18+01:00 + + Welcome to the Geminispace + + http://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.html + 2021-04-30T09:53:18+01:00 + Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:... + + Paul + comments@mx.buetow.org + + + + DTail - The distributed log tail program + + http://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html + 2021-04-30T09:53:18+01:00 + This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too.... + + Paul + comments@mx.buetow.org + + + diff --git a/content/meta/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.meta b/content/meta/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.meta new file mode 100644 index 00000000..d5acfd2d --- /dev/null +++ b/content/meta/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.meta @@ -0,0 +1,5 @@ +local meta_date=2021-04-30T09:53:18+01:00 +local meta_author=Paul Buetow +local meta_email=comments@mx.buetow.org +local meta_title="DTail - The distributed log tail program" +local meta_summary="This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too...." diff --git a/content/meta/gemfeed/2021-04-24-welcome-to-the-geminispace.meta b/content/meta/gemfeed/2021-04-24-welcome-to-the-geminispace.meta new file mode 100644 index 00000000..6748d03b --- /dev/null +++ b/content/meta/gemfeed/2021-04-24-welcome-to-the-geminispace.meta @@ -0,0 +1,5 @@ +local meta_date=2021-04-30T09:53:18+01:00 +local meta_author=Paul Buetow +local meta_email=comments@mx.buetow.org +local meta_title="Welcome to the Geminispace" +local meta_summary="Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:..." diff --git a/header.html b/header.html index 669cf034..7fadf752 100644 --- a/header.html +++ b/header.html @@ -1,7 +1,7 @@ -buetow.org +buetow.org - Having fun with computers!