help()
{
printf "usage:\n"
printf "\t%s -n <nick> -u <feed url> -t <feed title> -x <twtxt.txt url> twtxt.txt\n" "$0"
exit 1
}
nick=""
url=""
title=""
twtxturl=""
while getopts 'n:u:t:x:h' c
do
case $c in
n) nick="${OPTARG}" ;;
u) url="${OPTARG}" ;;
t) title="${OPTARG}" ;;
x) twtxturl="${OPTARG}" ;;
h) help ;;
esac
done
shift $((OPTIND - 1))
test -z "$nick" && help
test -z "$url" && help
test -z "$title" && help
HEADER="
${url}
${nick}
"
LAST="$(awk 'END {print $1}' $1)"
printf '%s' "$HEADER"
printf '%s\n' "$LAST"
grep -Ev '^#|^$' "${1}" | while read -r TS MSG; do
# ID must be unique, use sha256 on it
if [[ "$OSTYPE" == "linux-gnu" ]]; then
ID="$(printf '%s' "$1 $TS $MSG" | sha256sum | cut -f 1 -d " " )"
else
ID="$(printf '%s' "$1 $TS $MSG" | sha256)"
fi
# Can't have ]]> in CDATA
ESCAPED="$(printf "%s" "${MSG}" | awk '{gsub("]]>", "]]]]><![CDATA[>")}1')"
# output the entry
printf '<entry>\n'
printf '<id>urn:hash::sha256:%s</id>\n' "${ID}"
printf '<title type="text"><![CDATA[%s]]></title>\n' "${ESCAPED}"
printf '<updated>%s</updated>\n' "${TS}"
printf '<content type="text"><![CDATA[%s]]></content>\n' "${ESCAPED}"
printf '<link rel="alternate" type="text/plain" href="%s" />\n' "${twtxturl}"
printf '</entry>\n'
done
printf '%s' ''
exit 0
application/octet-stream
This content has been proxied by September (ba2dc).