diff --git a/README.md b/README.md index 35e5a2f..8d1149b 100644 --- a/README.md +++ b/README.md @@ -20,20 +20,15 @@ You’ve done it! ## Configuration ### sfeed -We need to create a config file and feed directory for sfeed — they can be anywhere, your choice. +We need to create a config file and feed directory for sfeed_update. +You can use the sfeedrc.example file in this repo as a base for your own config file. ``` $ mkdir ~/.config/sfeed/ -$ cat > ~/.config/sfeed/config < /dev/null)" + if test -z "$previous_max_date"; then + previous_max_date=0 + fi + + # Update the date of the last-processed post. + local latest_date="$(latest_date "$newfile")" + attr -qs sfeed_latest -V "$latest_date" "$oldfile" 2> /dev/null + + # Output only new and unprocessed posts. + after_date "$newfile" "$previous_max_date" +} + + +# Given an sfeed file, this returns the date of the latest post (in seconds +# since the UNIX epoch). +latest_date() { + local file="$1" + awk -F '\t' \ + '$1 > latest { latest = $1 } END { print latest }' \ + "$file" +} + + +# This outputs only lines of an sfeed file with a date after the given min_date +# (in seconds since UNIX epoch). +after_date() { + local file="$1" + local min_date="$2" + awk -F '\t' -v min_date="$min_date" \ + '$1 > min_date { print $0 }' \ + "$file" +}