summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <git@mx.buetow.org>2021-04-30 09:56:31 +0100
committerPaul Buetow <git@mx.buetow.org>2021-05-21 05:11:04 +0100
commit8441ab71f334714d48f34a6e0fcc8a2e6f7aa8bb (patch)
tree061b96230d3f919483ec2872777911a624692cf6
parentb595d0309d2c26fd6eca1399e8a502b8bb76f5be (diff)
can generate atom.xml gemini and http feeds
-rw-r--r--buetow.org.conf12
-rwxr-xr-xbuetow.org.sh86
-rw-r--r--content/gemtext/gemfeed/atom.xml12
-rw-r--r--content/html/gemfeed/atom.xml31
-rw-r--r--content/meta/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.meta5
-rw-r--r--content/meta/gemfeed/2021-04-24-welcome-to-the-geminispace.meta5
-rw-r--r--header.html2
7 files changed, 119 insertions, 34 deletions
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 <<META | tee $meta_file
+local meta_date=$now
+local meta_author=$AUTHOR
+local meta_email=$EMAIL
+local meta_title="$title"
+local meta_summary="$summary..."
+META
+ git add $meta_file
+ return
+ fi
+
+ echo 'local meta_post_is_new=0'
+ cat $meta_file
+}
+
atom::generate () {
local -r gemfeed_dir=$CONTENT_DIR/gemtext/gemfeed
- local -r atom=$gemfeed_dir/atom.xml
- local -r updated=$(date --iso-8601=seconds)
+ local -r atom_file=$gemfeed_dir/atom.xml
+ local -r now=$(date --iso-8601=seconds)
+ local -i changed=0
- cat <<ATOMHEADER > $atom.tmp
+ cat <<ATOMHEADER > $atom_file.tmp
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>$DOMAIN feed</title>
- <subtitle>Putting the dot before the org!</subtitle>
+ <subtitle>$SUBTITLE</subtitle>
<link href="gemini://$DOMAIN/gemfeed/" rel="self" />
<link href="gemini://$DOMAIN/" />
<id>gemini://$DOMAIN</id>
- <updated>$updated</updated>
+ <updated>$now</updated>
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 <<ATOMENTRY >> $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 <<ATOMENTRY >> $atom_file.tmp
<entry>
- <title>$title</title>
- <link href="gemini://$DOMAIN/gemfeed/$post" />
- <id>gemini://$DOMAIN/gemfeed/$post</id>
- <updated>$updated</updated>
- <summary>$first_paragraph...</summary>
+ <title>$meta_title</title>
+ <link href="gemini://$DOMAIN/gemfeed/$gmi_file" />
+ <id>gemini://$DOMAIN/gemfeed/$gmi_file</id>
+ <updated>$meta_date</updated>
+ <summary>$meta_summary</summary>
<author>
- <name>$AUTHOR</name>
- <email>$EMAIL</email>
+ <name>$meta_author</name>
+ <email>$meta_email</email>
</author>
</entry>
ATOMENTRY
- done
+ done < <(ls $gemfeed_dir | sort -r | grep '.gmi$' | head -n $ATOM_MAX_ENTRIES)
- cat <<ATOMFOOTER >> $atom.tmp
+ cat <<ATOMFOOTER >> $atom_file.tmp
</feed>
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 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>buetow.org feed</title>
- <subtitle>Putting the dot before the org!</subtitle>
+ <subtitle>Having fun with computers!</subtitle>
<link href="gemini://buetow.org/gemfeed/" rel="self" />
<link href="gemini://buetow.org/" />
<id>gemini://buetow.org</id>
- <updated>2021-04-30T07:34:28+01:00</updated>
+ <updated>2021-04-30T09:53:18+01:00</updated>
<entry>
<title>Welcome to the Geminispace</title>
<link href="gemini://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.gmi" />
<id>gemini://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.gmi</id>
- <updated>2021-04-30T07:34:28+01:00</updated>
+ <updated>2021-04-30T09:53:18+01:00</updated>
<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:...</summary>
<author>
- <name>Paul Buetow</name>
+ <name>Paul</name>
<email>comments@mx.buetow.org</email>
</author>
</entry>
@@ -21,10 +21,10 @@
<title>DTail - The distributed log tail program</title>
<link href="gemini://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.gmi" />
<id>gemini://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.gmi</id>
- <updated>2021-04-30T07:34:28+01:00</updated>
+ <updated>2021-04-30T09:53:18+01:00</updated>
<summary>This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too....</summary>
<author>
- <name>Paul Buetow</name>
+ <name>Paul</name>
<email>comments@mx.buetow.org</email>
</author>
</entry>
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>buetow.org feed</title>
+ <subtitle>Having fun with computers!</subtitle>
+ <link href="http://buetow.org/gemfeed/" rel="self" />
+ <link href="http://buetow.org/" />
+ <id>http://buetow.org</id>
+ <updated>2021-04-30T09:53:18+01:00</updated>
+ <entry>
+ <title>Welcome to the Geminispace</title>
+ <link href="http://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.html" />
+ <id>http://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.html</id>
+ <updated>2021-04-30T09:53:18+01:00</updated>
+ <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:...</summary>
+ <author>
+ <name>Paul</name>
+ <email>comments@mx.buetow.org</email>
+ </author>
+ </entry>
+ <entry>
+ <title>DTail - The distributed log tail program</title>
+ <link href="http://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html" />
+ <id>http://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html</id>
+ <updated>2021-04-30T09:53:18+01:00</updated>
+ <summary>This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too....</summary>
+ <author>
+ <name>Paul</name>
+ <email>comments@mx.buetow.org</email>
+ </author>
+ </entry>
+</feed>
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 @@
<!DOCTYPE html>
<html lang="en">
<head>
-<title>buetow.org</title>
+<title>buetow.org - Having fun with computers!</title>
<meta charset='utf-8'>
<style>
body { background-color: #282c34; color: #dfdfdf; margin: auto; max-width: 900px; }