dybr2fedi/rss_atom_gen.sh

43 lines
1 KiB
Bash
Executable file

#!/bin/sh
atom_xml() {
cat <<EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Ледяной автобус в Нифльхейм</title>
<link href="$uri" rel="self" />
<updated>$(date --iso=seconds)</updated>
<author>
<name>Лиэс.</name>
</author>
<id>tag:default-atom-feed</id>
EOF
for i in $1/*.gmi; do
if [ -n "$(echo "$i" | grep -Eo 'atom|index')" ]; then continue; fi
raw_id=$(echo "$i" | rev | cut -d'/' -f 1 | rev)
title=$(head -n 1 $i | tr -d '#')
created=$(date -r $i --iso-8601=seconds)
updated=$created
if [ "$created" = "draft" ]; then continue; fi
day=$(echo "$created" | sed 's/T.*//')
#content=$($MARKDOWN "$f" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')
cat <<EOF
<entry>
<title>$title</title>
<link href="$(echo "$raw_id")"/>
<id>tag:$day:$raw_id</id>
<published>$created</published>
<updated>$updated</updated>
</entry>
EOF
done
echo '</feed>'
}
uri="pub.phreedom.club/~localhost/Lies_dybr/" atom_xml $1