sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit a44ec5a5b22719d15b28e8da13027176bf8105f1
parent 71815afcf0577ff1fb5e65fcdb3b8041c72c7623
Author: gearsix <gearsix@tuta.io>
Date:   Thu, 15 Apr 2021 19:29:18 +0100

tidied sfeed read script

Diffstat:
Dsfeed-read | 74--------------------------------------------------------------------------
Dsfeed-read.1 | 32--------------------------------
Asfeed_read | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asfeed_read.1 | 34++++++++++++++++++++++++++++++++++
4 files changed, 114 insertions(+), 106 deletions(-)

diff --git a/sfeed-read b/sfeed-read @@ -1,74 +0,0 @@ -#!/bin/sh - -# sfeed-read -# author: gearsix -# description: sfeed_update; backup outfile; generates outifle; xdg-open outfile; -# usage: "sfeed-read [$ENGINE]"; $ENGINE is optional and sets the sfeed_* engine to use (default is html) - -engine=sfeed_html -sfeed_files=~/.sfeed/feeds -sfeed_outfile=~/docs/sfeed/feed - -if [ ! -z $1 ]; then - case "$1" in - "html" | "HTML" | "sfeed_html") - ;; - "atom" | "Atom" | "sfeed_atom") - engine=sfeed_atom - sfeed_outfile=$sfeed_outfile.atom - ;; - "plain" | "Plain" | "plain-text" | "Plain-Text" | "sfeed_plain") - engine=sfeed_plain - sfeed_outfile=$sfeed_outfile.txt - ;; - "frames" | "frame" | "sfeed_frames") - engime=sfeed_frames - ;; - "mbox" | "mail" | "mailbox" | "sfeed_mbox") - engine=sfeed_mbox - ;; - "twtxt" | "sfeed_twtxt") - engine=sfeed_twtxt - sfeed_outfile=$sfeed_outfile.txt - ;; - "gopher" | "sfeed_gopher") - engine=sfeed_gopher - sfeed_outfile=$sfeed_outfile.gopher - ;; - *) - echo "invalid ENGINE \"$1\"!" - printf "\nsfeed-read [ENGINE]\n\n" - echo "ENGINE:" - echo " html, HTML, sfeed_html" - echo " atom, Atom, sfeed_atom" - echo " plain, Plain, plain-text, Plain-Text, sfeed_plain" - echo " frame, frames, sfeed_frames" - echo " mbox, mail, mailbox, sfeed_mbox" - echo " twtxt, sfeed_twtxt" - echo " gopher, sfeed_gopher." - exit - ;; - esac -else - sfeed_outfile=$sfeed_outfile.html -fi - -if [ ! -e $(dirname $sfeed_outfile) ]; then - mkdir -pv $sfeed_outfile -fi - -echo "updating feed..." -sfeed_update - -if [ -e $sfeed_outfile ]; then - echo "backing up feed..." - mv -fv $sfeed_outfile $sfeed_outfile.yesterday -fi - -echo "generating $sfeed_outfile..." -$engine $sfeed_files/* > $sfeed_outfile$outext - -echo "opening $sfeed_outfile..." -xdg-open "$sfeed_outfile" - -echo "done" diff --git a/sfeed-read.1 b/sfeed-read.1 @@ -1,32 +0,0 @@ -.Dd September 19, 2020 - -.Dt SFEED-READ 1 - -.Sh NAME -.Nm sfeed-read -.Nd sfeed_update & xdg-open feed - -.Sh SYNOPSIS -.Nm -.Op Ar ENGINE - -.Sh DESCRIPTION -.Bd -literal -1. update the feed using sfeed_update -2. backup any existing $sfeed_outfile to $sfeed_outfile.yesterday -3. regenerate $sfeed_outfile; xdg-open $sfeed_outfile - -.Sh ARGUMENTS -.Bl -tag -.It Ar ENGINE -Specify the sfeed engine to use (defaults to sfeed_html). - -.Sh DEFAULTS -.Bl -tag -.It Ar sfeed_outfile -The file output sfeed results to -.Pa ~/docs/sfeed/feeds -I was lazy and didn't make this an environment variable or -anything,you'll need to modify it in the the source file. - -.Os Unix; BSD diff --git a/sfeed_read b/sfeed_read @@ -0,0 +1,80 @@ +#!/bin/sh + +# sfeed_read +# author: gearsix +# description: sfeed_update; generate $FOUT && xdg-open $FOUT +# usage: "sfeed_read [ENGINE]" ENGINE (optional) sets the sfeed_X tool to use (default is sfeed_html) + +TIMESTAMP=$(date +%F) +ENGINE= +EXT= +SFEED= +FEEDS= + +# determine ENGINE & EXT values +if [ -n "$1" ]; then + case "$1" in + "html" | "HTML" | "sfeed_html") + EXT=".html" + ENGINE=sfeed_html + ;; + "atom" | "sfeed_atom") + EXT=".atom" + ENGINE=sfeed_atom + ;; + "plain" | "txt" | "plain-text" | "sfeed_plain") + EXT=".txt" + ENGINE=sfeed_plain + ;; + "frame" | "frames" | "sfeed_frames") + EXT=".html" + ENGINE=sfeed_frames + ;; + "mbox" | "mail" | "mailbox" | "feed_mbox") + ENGINE=sfeed_mbox + ;; + "twtxt" | "sfeed_twtxt") + EXT=".txt" + ENGINE=sfeed_twtxt + ;; + "gopher" | "sfeed_gopher") + EXT=".gopher" + ENGINE=sfeed_gopher + ;; + *) + echo "invalid ENGINE \"$1\"" + printf "\nsfeed_read [ENGINE]\n\n" + echo "ENGINE:" + echo " html, HTML, sfeed_html" + echo " atom, sfeed_atom" + echo " plain, txt, plain-text, sfeed_plain" + echo " frame, frames, sfeed_frames" + echo " mbox, mail, mailbox, sfeed_mbox" + echo " twtxt, sfeed_twtxt" + echo "gopher, sfeed_gopher" + exit + ;; + esac +else + EXT=".html" + ENGINE=sfeed_html +fi + +# determine SFEED location +SFEED=~/.sfeed/feeds +if [ -n "$SFEED" ]; then SFEED=$SFEED; fi + +# determine FEEDS location +if [ -n "$FEEDS" ]; then + FEEDS=$FEEDS +elif [ -n "$(command -v xdg-user-dir)" ]; then + FEEDS=$(xdg-user-dir DOCUMENTS)/feeds +else + FEEDS=~/Documents/feeds +fi +if [ -n "$(dirname $FEEDS)" ]; then mkdir -pv $FEEDS; fi + +# main actions +sfeed_update +$ENGINE $SFEED/* > "$FEEDS/$TIMESTAMP$EXT" +xopen "$FEEDS/$TIMESTAMP$EXT" diff --git a/sfeed_read.1 b/sfeed_read.1 @@ -0,0 +1,34 @@ +.Dd April 15, 2021 + +.Dt SFEED_READ 1 + +.Sh NAME +.Nm sfeed_read +.Nd update and read sfeed feeds + +.Sh SYNOPSIS +.Nm +.Op Ar ENGINE + +.Sh DESCRIPTION +.Bd -literal +Call sfeed_update and use the sfeed $ENGINE (default sfeed_html) to generate +a file in $FEEDS named after the current date, then call xdg-open on said +file. + +.Sh ARGUMENTS +.Bl -tag +.It Ar ENGINE +Specify the sfeed engine to use (defaults to sfeed_html). + +.Sh ENVIRONMENT VARIABLES +.Bl -tag +.It Ar FEEDS +The file output sfeed results to (defaults to +.Pa ~/$(xdg-user-dir DOCUMENTS)/feeds) + +.It Ar SFEED +The directory containing sfeed feeds (defaults to +.Pa ~/.sfeed/feeds) + +.Os Unix; BSD