summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorp4bl0 <r _at_ uzy .dot. me>2016-02-16 23:49:28 (CET)
committerp4bl0 <r _at_ uzy .dot. me>2016-02-16 23:49:28 (CET)
commit902f18cf6352cda682455db8e21bc56f93c98734 (patch)
tree47d4704c3852d171d4451ecff287a49396e7b09e
parent6bd329d7284140d043883294a5e11562d4a4f862 (diff)
downloadmyutils-902f18cf6352cda682455db8e21bc56f93c98734.zip
myutils-902f18cf6352cda682455db8e21bc56f93c98734.tar.gz
improve terss
-rwxr-xr-xterss44
1 files changed, 31 insertions, 13 deletions
diff --git a/terss b/terss
index ddf807e..17ebc7d 100755
--- a/terss
+++ b/terss
@@ -48,6 +48,7 @@ Usage:
terss update: update your local feed from your server.
terss follow USER URL: subscribe to USER who's feed is at URL.
terss unfollow USER: unsubscribe from USER's feed.
+ terss subscriptions: list subscriptions.
terss list [MAX]: list the last MAX message from your subscriptions
(default 10).
EOF
@@ -89,15 +90,21 @@ function terss_post(){
local MSG="$1"
local DATE="$(date -R)"
xml2 < "$TERSSDIR/feed" | grep -v -E '^/rss/channel/item' > "$TERSSDIR/tmp"
- cat >>"$TERSSDIR/tmp" <<EOF
+ xml2 < "$TERSSDIR/feed" | grep -E '^/rss/channel/item' > "$TERSSDIR/tmp2" || true
+ cat >> "$TERSSDIR/tmp" <<EOF
/rss/channel/item/title=$MSG
/rss/channel/item/pubDate=$DATE
-/rss/channel/item
EOF
- xml2 < "$TERSSDIR/feed" | grep -E '^/rss/channel/item' >> "$TERSSDIR/tmp"
+ if [[ -s "$TERSSDIR/tmp2" ]]; then
+ echo "/rss/channel/item" >> "$TERSSDIR/tmp"
+ cat "$TERSSDIR/tmp2" >> "$TERSSDIR/tmp"
+ fi
echo '<?xml version="1.0" encoding="utf-8"?>' > "$TERSSDIR/feed"
2xml < "$TERSSDIR/tmp" >> "$TERSSDIR/feed"
- scp "$TERSSDIR/feed" "$SERVER:$FEED"
+ scp -q "$TERSSDIR/feed" "$SERVER:$FEED"
+ rm "$TERSSDIR/tmp" "$TERSSDIR/tmp2"
+ _terss_log "message posted."
+ return 0
}
function terss_update(){
@@ -112,7 +119,6 @@ function terss_update(){
fi
}
-
function terss_follow(){
local NAME="$1"
local URL="$2"
@@ -133,6 +139,17 @@ function terss_unfollow(){
fi
}
+function terss_subscriptions(){
+ _terss_log "subscriptions:"
+ while read SUB; do
+ SUB=($SUB)
+ _terss_echo -n green_u "${SUB[0]}"
+ _terss_echo -n white_b ": "
+ _terss_echo white "${SUB[1]}"
+ done < "$TERSSDIR/subscriptions"
+ return 0
+}
+
function _terss_fetch(){
local NAME="$1"
local URL="$2"
@@ -179,6 +196,7 @@ function terss_list(){
echo
done < "$TERSSDIR/timeline"
rm "$TERSSDIR/timeline"
+ return 0
}
#####
@@ -198,12 +216,12 @@ if [[ -z "$USERNAME" || -z "$SERVER" || -z "$FEED" ]]; then
fi
case "$1" in
- f|follow) terss_follow "$2" "$3" ;;
- u|unfollow) terss_unfollow "$2" ;;
- p|post) shift; terss_post "$*" ;;
- up|update) terss_update ;;
- l|list) terss_list "${2:-10}" ;;
- *) terss_help ;;
+ i|init) terss_init ;;
+ f|follow) terss_follow "$2" "$3" ;;
+ u|unfollow) terss_unfollow "$2" ;;
+ s|subscriptions) terss_subscriptions ;;
+ p|post) shift; terss_post "$*" ;;
+ up|update) terss_update ;;
+ l|list) terss_list "${2:-10}" ;;
+ *) terss_help ;;
esac
-
-exit 1
Pablo Rauzy — generated by cgit