From 8d490839b7ef11549bee6c92fdd86ef60afd55e0 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 21 Jan 2019 01:25:07 -0200 Subject: Generate local RSS feed from buku tags. --- .gitignore | 3 +++ bash/aliases.sh | 1 + newsboat/urls | Bin 589 -> 653 bytes nixos/configuration.nix | 3 +++ scripts/atom.js | 22 ++++++++++++++++++++++ scripts/atom.sh | 19 +++++++++++++++++++ 6 files changed, 48 insertions(+) create mode 100644 scripts/atom.js create mode 100755 scripts/atom.sh diff --git a/.gitignore b/.gitignore index e671f1e..68b7e2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ mail/offlineimap.pyc tam_required /result + +/scripts/node_modules/ +/scripts/package-lock.json \ No newline at end of file diff --git a/bash/aliases.sh b/bash/aliases.sh index 52d24b4..e8ff449 100644 --- a/bash/aliases.sh +++ b/bash/aliases.sh @@ -24,6 +24,7 @@ alias sbcl="rlwrap sbcl" alias du="ncdu --color dark" alias perl6="rlwrap perl6" alias m="mail.sh" +alias a="atom.sh" alias gnome-control-center="XDG_CURRENT_DESKTOP=GNOME gnome-control-center" diff --git a/newsboat/urls b/newsboat/urls index 444e1a7..1047793 100644 Binary files a/newsboat/urls and b/newsboat/urls differ diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 36a2474..6f8c7e0 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -333,6 +333,9 @@ # Sync emails with mbsync every hour "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/mail.sh -s" + # Refresh local RSS files every hour + "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/atom.sh" + # Make read-only copy of TODOs.org every hour # "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cp-todos.sh -s" ]; diff --git a/scripts/atom.js b/scripts/atom.js new file mode 100644 index 0000000..878df05 --- /dev/null +++ b/scripts/atom.js @@ -0,0 +1,22 @@ +const RSS = require('rss'); + +const feedName = process.argv[2]; +const feedSrc = process.argv[3]; + +const feed = new RSS({ + title: `Buku feed tag for '${feedName}'.`, + description: `Buku feed tag for ${feedName}`, +}); + +const items = require(feedSrc); +items.forEach(({ title, description, uri }) => { + feed.item({ + title, + description, + url: uri + }); +}); + +const xml = feed.xml({indent: true}); + +console.log(xml); diff --git a/scripts/atom.sh b/scripts/atom.sh new file mode 100755 index 0000000..73c35ec --- /dev/null +++ b/scripts/atom.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" + +if [[ ! -d "node_modules" ]]; then + npm i rss +fi + +feed() { + local tag="$1" + local tmp="/tmp/$tag.json" + buku -t "$tag" --json > "$tmp" + node atom.js "$tag" "$tmp" +} + +mkdir -p ~/.newsboat +feed ril > ~/.newsboat/ril.xml +feed simple-archive > ~/.newsboat/simple-archive.xml +feed inbox > ~/.newsboat/inbox.xml -- cgit v1.2.3