From dcfb172704f3afb68a30425029ec834be2883274 Mon Sep 17 00:00:00 2001 From: bt Date: Sat, 8 Jun 2024 13:22:19 -0400 Subject: More content porting, on-going markdown changes for lowdown support --- barf | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) mode change 100644 => 100755 barf (limited to 'barf') diff --git a/barf b/barf old mode 100644 new mode 100755 index e13b901..c53ed7b --- a/barf +++ b/barf @@ -1,6 +1,21 @@ #!/bin/sh + +domain="https://btxx.org" + +# Check the operating system +os_name=$(uname -s) + +if [ "$os_name" = "OpenBSD" ]; then + alias sed=gsed + alias date=gdate + alias rsync=openrsync +elif [ "$os_name" = "Darwin" ]; then + alias sed=gsed + alias date=gdate +fi + set -eu -MARKDOWN=smu +MARKDOWN=lowdown IFS=' ' # Create tab separated file with filename, title, creation date, last update @@ -26,10 +41,10 @@ index_html() { while read -r f title created; do link=$(echo "$f" | sed -E 's|.*/(.*).md|\1/|') created=$(echo $(head -3 "$f" | tail -1)) - echo "$created · $title
" + echo "$created · $title
" done < "$1" | sort -r - echo "" + echo "
" # Print footer after post list cat footer.html @@ -37,7 +52,6 @@ index_html() { atom_xml() { uri=$(sed -rn '/atom.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) - domain=$(echo "$uri" | sed 's/atom.xml//g' | sed 's|/[^/]*$||') first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1) cat <' } +rss_xml() { + uri=$(sed -rn '/rss.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) + 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 + $content + $domain/$post_link + $domain/$post_link + $published_date + +EOF + done < "$1" + + echo '' + echo '' +} + write_page() { filename=$1 directory=$(echo $(basename "$filename" .md)) @@ -94,6 +146,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 -- cgit v1.2.3-54-g00ecf