sfeed

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

sfeed_read (1740B)


      1 #!/bin/sh
      2 
      3 # sfeed_read
      4 # author: gearsix
      5 # description: sfeed_update; generate $FOUT && xdg-open $FEEDS (xdg-user-dir DOCUMENTS or ~/Documents)
      6 # usage: "sfeed_read [ENGINE]" ENGINE (optional) sets the sfeed_X tool to use (default is sfeed_html)
      7 
      8 TIMESTAMP=$(date +%F)
      9 ENGINE=
     10 EXT=
     11 SFEED=
     12 FEEDS=
     13 
     14 # determine ENGINE & EXT values
     15 if [ -n "$1" ]; then
     16 	case "$1" in
     17 		"html" | "HTML" | "sfeed_html")
     18 			EXT=".html"
     19 			ENGINE=sfeed_html
     20 			;;
     21 		"atom" | "sfeed_atom")
     22 			EXT=".atom"
     23 			ENGINE=sfeed_atom
     24 			;;
     25 		"plain" | "txt" | "plain-text" | "sfeed_plain")
     26 			EXT=".txt"
     27 			ENGINE=sfeed_plain
     28 			;;
     29 		"frame" | "frames" | "sfeed_frames")
     30 			EXT=".html"
     31 			ENGINE=sfeed_frames
     32 			;;
     33 		"mbox" | "mail" | "mailbox" | "feed_mbox")
     34 			ENGINE=sfeed_mbox
     35 			;;
     36 		"twtxt" | "sfeed_twtxt")
     37 			EXT=".txt"
     38 			ENGINE=sfeed_twtxt
     39 			;;
     40 		"gopher" | "sfeed_gopher")
     41 			EXT=".gopher"
     42 			ENGINE=sfeed_gopher
     43 			;;
     44 		*)
     45 			echo "invalid ENGINE \"$1\""
     46 			printf "\nsfeed_read [ENGINE]\n\n"
     47 			echo "ENGINE:"
     48 			echo " html, HTML, sfeed_html"
     49 			echo " atom, sfeed_atom"
     50 			echo " plain, txt, plain-text, sfeed_plain"
     51 			echo " frame, frames, sfeed_frames"
     52 			echo " mbox, mail, mailbox, sfeed_mbox"
     53 			echo " twtxt, sfeed_twtxt"
     54 			echo "gopher, sfeed_gopher"
     55 			exit
     56 			;;
     57 	esac
     58 else
     59 	EXT=".html"
     60 	ENGINE=sfeed_html
     61 fi
     62 
     63 # determine SFEED location
     64 SFEED=~/.sfeed/feeds
     65 if [ -n "$SFEED" ]; then SFEED=$SFEED; fi
     66 
     67 # determine FEEDS location
     68 if [ -n "$FEEDS" ]; then
     69 	FEEDS=$FEEDS
     70 elif [ -n "$(command -v xdg-user-dir)" ]; then
     71 	FEEDS=$(xdg-user-dir DOCUMENTS)/feeds
     72 else
     73 	FEEDS=~/Documents/feeds
     74 fi
     75 if [ -n "$(dirname $FEEDS)" ]; then mkdir -pv $FEEDS; fi
     76 
     77 # main actions
     78 sfeed_update
     79 $ENGINE $SFEED/* > "$FEEDS/$TIMESTAMP$EXT"
     80 xopen "$FEEDS/$TIMESTAMP$EXT"