From f43e9a85d88f1769c2076312bf1103109652dcfc Mon Sep 17 00:00:00 2001 From: notkoutsie Date: Tue, 12 Dec 2023 16:51:02 +0200 Subject: [PATCH] noter 1.2.1 - feeds, holy shit! --- README.md | 5 +++- noter.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index de827be..9c3b588 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -a simple note taking system, that also generates weboages! +a simple note taking system, that also generates weboages with rss feeds! made with bash. +### see noter.sh for generation time options +### place your notes onto a foldier named "notes" in the directory noter.sh is in! + example of what a page looks like: https://k0.tel/ \ No newline at end of file diff --git a/noter.sh b/noter.sh index fd90e68..d1c142b 100755 --- a/noter.sh +++ b/noter.sh @@ -1,9 +1,10 @@ #!/bin/bash -# noter 1.1.7 - "verofoed" - @k@layer8.space - mit +# noter 1.2.1 - "feeds, holy shit!" - @k@layer8.space - mit showgenerator="true" backtotop="true" lastupdated="true" +#rssfeed="true" nlog() { local ORANGE='\033[0;33m' @@ -72,22 +73,81 @@ generate_top_year_bar() { echo "$top_bar" } + +# this took way too long but fuck it +# im faster than Google at getting a +# feed going goddamit! +generate_rss_feed() { + local rss_file="feed.xml" + local rss_title="koutsies telenotes" + local rss_description="thoughts about mainly computers... maybe recipes and cats too?" + local rss_link="https://k0.tel/" + local rss_pubdate=$(date -u +"%a, %d %b %Y %H:%M:%S GMT") + + xml_escape() { + local content="$1" + sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' <<< "$content" + } + + # im sorry for these crimes against humanity + echo " + + + $(xml_escape "$rss_title") + $rss_link + $(xml_escape "$rss_description") + $rss_pubdate + $rss_pubdate + https://cyber.harvard.edu/rss/rss.html + noter" >"$rss_file" + + if [ ! -d "notes" ]; then + echo "Directory 'notes' not found!" + return 1 + fi + + # this works, don't touch. + for file in $(find notes -name '*.txt' -type f -print0 | sort -zr | xargs -0); do + if [ -f "$file" ] && [ -s "$file" ]; then + local note_date=$(date -d "$(basename "$file" .txt)" +"%a, %d %b %Y %H:%M:%S GMT") + local note_link="$rss_link#$(basename "$file" .txt)" + local note_title=$(basename "$file" .txt) + local note_description=$(head -n 1 "$file") # Use the first line of the note as the description + + echo " + $(xml_escape "$note_title") + $note_link + $(xml_escape "$note_description") + $note_date + " >>"$rss_file" + fi + done + + echo " + " >>"$rss_file" + + nlog "rss feed generated, please remember to move it too with the site: $rss_file" +} + + + + notecount=$(find notes -name "*.txt" ! -empty | wc -l) # Create HTML file -output_file="notes.html" +output_file="index.html" echo " - Mastodon $notecount notes | noter - + + -

notes

" >"$output_file" +

koutsie's telenotes


fedi | rss | sauna
" >"$output_file" generate_top_year_bar >>"$output_file" # loop for every note in notes nlog "generating page..." @@ -153,6 +213,10 @@ for file in $(ls -r notes/*.txt); do fi done +# generate page's rss feed +# TODO: don't embed to site if not enabled:tm: +generate_rss_feed + # bottom navigation checksetting "
generated with noter
" "$showgenerator" checksetting "" "$backtotop"