From 7b2dc83a3a3b2da494e1b1370e3ecac94a9c9342 Mon Sep 17 00:00:00 2001 From: Bradley Taunt Date: Thu, 6 Jun 2024 08:36:27 -0400 Subject: Include RSS feed generation, check operating system to set aliases --- barf | 51 ++++++ build/about/index.html | 1 + build/atom.xml | 2 +- build/cleanup/index.html | 1 + build/dark-mode/index.html | 1 + build/index.html | 1 + build/macos/index.html | 1 + build/markdown-examples/index.html | 1 + build/openbsd/index.html | 1 + build/rss.xml | 332 +++++++++++++++++++++++++++++++++++++ build/websites/index.html | 1 + footer.html | 1 + 12 files changed, 393 insertions(+), 1 deletion(-) create mode 100644 build/rss.xml diff --git a/barf b/barf index 81bbcd2..528dece 100755 --- a/barf +++ b/barf @@ -1,4 +1,15 @@ #!/bin/sh + +# Check the operating system +os_name=$(uname -s) + +if [ "$os_name" = "OpenBSD" ]; then + alias sed=gsed +elif [ "$os_name" = "Darwin" ]; then + alias sed=gsed + alias date=gdate +fi + set -eu MARKDOWN=smu IFS=' ' @@ -74,6 +85,45 @@ EOF echo '' } +rss_xml() { + uri=$(sed -rn '/rss.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) + domain=$(echo "$uri" | sed 's/rss.xml//g' | sed 's|/[^/]*$||') + first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1) + + cat < + + + $(sed -n '/^# /{s/# //p; q}' index.md) + $domain/rss.xml + Feed description here + $(date -u +"%a, %d %b %Y %H:%M:%S %z") + $(date -u +"%a, %d %b %Y %H:%M:%S %z") + Custom RSS Generator + 1800 +EOF + + while read -r f title created; do + content=$($MARKDOWN "$f" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g') + post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|') + basic_date=$(echo $(head -3 "$f" | tail -1)) + published_date=$(date -d "$basic_date" -u +"%a, %d %b %Y %H:%M:%S %z") + + cat < + $title + + $domain/$post_link + $domain/$post_link + $published_date + +EOF + done < "$1" + + echo '' + echo '' +} + write_page() { filename=$1 directory=$(echo $(basename "$filename" .md)) @@ -94,6 +144,7 @@ rm -rf build && mkdir build index_tsv posts | sort -rt " " -k 3 > build/posts.tsv index_html build/posts.tsv > build/index.html atom_xml build/posts.tsv > build/atom.xml +rss_xml build/posts.tsv > build/rss.xml while read -r f title created; do write_page "$f" "$title" "$created" done < build/posts.tsv diff --git a/build/about/index.html b/build/about/index.html index f172116..be0489e 100644 --- a/build/about/index.html +++ b/build/about/index.html @@ -29,6 +29,7 @@
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/build/atom.xml b/build/atom.xml index dc8835d..dfe09d2 100644 --- a/build/atom.xml +++ b/build/atom.xml @@ -2,7 +2,7 @@ barf - 2024-06-04T11:19:14Z + 2024-06-06T08:34:47Z Bradley Taunt diff --git a/build/cleanup/index.html b/build/cleanup/index.html index 62b6f54..16b7672 100644 --- a/build/cleanup/index.html +++ b/build/cleanup/index.html @@ -42,6 +42,7 @@ pre{overflow:auto;}
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/build/dark-mode/index.html b/build/dark-mode/index.html index dca8874..a5aaf19 100644 --- a/build/dark-mode/index.html +++ b/build/dark-mode/index.html @@ -35,6 +35,7 @@
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/build/index.html b/build/index.html index 10a7f83..b47b9af 100644 --- a/build/index.html +++ b/build/index.html @@ -39,6 +39,7 @@
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/build/macos/index.html b/build/macos/index.html index 466f6bb..f3d1d74 100644 --- a/build/macos/index.html +++ b/build/macos/index.html @@ -43,6 +43,7 @@ sudo ln -fs /opt/homebrew/bin/gdate /usr/local/bin/date
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/build/markdown-examples/index.html b/build/markdown-examples/index.html index 94fe221..043a664 100644 --- a/build/markdown-examples/index.html +++ b/build/markdown-examples/index.html @@ -257,6 +257,7 @@ tags.

  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/build/openbsd/index.html b/build/openbsd/index.html index 1099502..7d75ce1 100644 --- a/build/openbsd/index.html +++ b/build/openbsd/index.html @@ -33,6 +33,7 @@
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/build/rss.xml b/build/rss.xml new file mode 100644 index 0000000..065e51d --- /dev/null +++ b/build/rss.xml @@ -0,0 +1,332 @@ + + + + barf + /rss.xml + Feed description here + Thu, 06 Jun 2024 12:34:47 +0000 + Thu, 06 Jun 2024 12:34:47 +0000 + Custom RSS Generator + 1800 + + Running `barf` on OpenBSD + + /openbsd + /openbsd + Sat, 12 Aug 2023 00:00:00 +0000 + + + Markdown Examples in barf + + /markdown-examples + /markdown-examples + Thu, 05 Jan 2023 00:00:00 +0000 + + + Running `barf` on MacOS + + /macos + /macos + Wed, 18 Jan 2023 00:00:00 +0000 + + + Supporting Basic Dark Mode + + /dark-mode + /dark-mode + Tue, 07 Mar 2023 00:00:00 +0000 + + + Cleaning Up barf's Structure + + /cleanup + /cleanup + Mon, 09 Oct 2023 00:00:00 +0000 + + + diff --git a/build/websites/index.html b/build/websites/index.html index f2ba617..417afa5 100644 --- a/build/websites/index.html +++ b/build/websites/index.html @@ -32,6 +32,7 @@
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    diff --git a/footer.html b/footer.html index 861f246..caef879 100644 --- a/footer.html +++ b/footer.html @@ -8,6 +8,7 @@
  • Source Code
  • + Feeds: Atom | RSS
    Built with barf.
    The code for this site is MIT.
    -- cgit v1.2.3-54-g00ecf