From 8094bf42739f9a13c49e9a88f5d56ef66690561b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 18 Jul 2022 11:24:07 -0500 Subject: Add more links to each feed --- runsfeed | 7 +++++++ sfeed_html.sh | 10 +++++++++- sfeed_update_urls.sh | 18 ++++++++++++++++++ style.css | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 sfeed_update_urls.sh diff --git a/runsfeed b/runsfeed index f108031..da43529 100755 --- a/runsfeed +++ b/runsfeed @@ -23,6 +23,8 @@ main() { get_invidious_url "https://api.invidious.io/instances.json?sort_by=health" log Updating feeds... update "$sfeedrc" + log Updating urls... + update_urls "$sfeedrc" log Generating HTML... html "$sfeedpath"/* >"$SFEED_OUTPUT/index.html" log @@ -38,6 +40,11 @@ main() { log Done. } +update_urls() { + cmd="$(command -v sfeed_update_urls.sh || echo ./sfeed_update_urls.sh)" + "$cmd" "$@" +} + get_invidious_url() { curl -sL "$1" | jq -r .[][1].uri | diff --git a/sfeed_html.sh b/sfeed_html.sh index d9f1b43..a618ff9 100755 --- a/sfeed_html.sh +++ b/sfeed_html.sh @@ -147,7 +147,15 @@ html_feed() { # html_feed FEED(file) => HTML echo "
" # TODO: Include a link back to the website printf '

# %s

\n' "$filename" "$filename" - printf '%s
' "[back to top]" + echo "" + if [ -f "$SFEED_DATA/urls/$filename" ]; then + feed_url="$(sed -n '1p;1q' "$SFEED_DATA/urls/$filename")" + site_url="$(sed -n '2p;2q' "$SFEED_DATA/urls/$filename")" + [ -n "$site_url" ] && printf '%s\n//' "$site_url" site + [ -n "$feed_url" ] && printf '%s\n//' "$feed_url" feed + fi + printf '\n%s' top + echo "" echo "" echo "$entries" echo "
" diff --git a/sfeed_update_urls.sh b/sfeed_update_urls.sh new file mode 100755 index 0000000..a2ee2be --- /dev/null +++ b/sfeed_update_urls.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +. "$1" + +feed() { + printf '%s\t%s\t%s\n' "$1" "$2" "${3:-}" +} + +mkdir -p "$SFEED_DATA/urls" + +feeds | awk -v dir="$SFEED_DATA/urls" ' +BEGIN{FS="\t";} +{ + gsub(/\//, "_", $1); + file = dir "/" $1; + if ($2) print $2 > file; + if ($3) print $3 >> file; +}' diff --git a/style.css b/style.css index 9b5efca..abe4799 100644 --- a/style.css +++ b/style.css @@ -85,7 +85,7 @@ header h2, header h1 { margin: 0; } header h2 a { display: inline; } -header .top { +header .flinks { font-size: 80%; text-align: right; flex-grow: 1; -- cgit 1.4.1-21-gabe81