Put full article text into the rss feed

This commit is contained in:
Konstantin Nazarov 2023-09-26 21:18:47 +01:00
parent d352b6afc6
commit f3a6c45b0c
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
2 changed files with 47 additions and 7 deletions

36
bin/mdpage_plain.sh Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e
render() {
NOTITLE="$1"
LASTLINE=""
TITLE=""
while read -r line ; do
if [[ "$line" =~ ^Subject:\ .*$ ]]; then
TITLE="${line#* }"
fi
if [[ "$line" =~ ^X-Date:\ .*$ ]]; then
DATE="${line#* }"
fi
if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then
LASTLINE="$line"
break
fi
done
{
[ "$NOTITLE" == "0" ] && echo "# $TITLE";
echo "$LASTLINE";
cat
} | awk -f ./bin/markdown.awk
}
if [ -t 0 ]; then
echo "Missing Markdown body"
exit 1
fi
render "$NOTITLE"

View file

@ -67,16 +67,18 @@ list_items() {
}
render_item() {
base_url="$1"
item="$2"
DIR="$1"
base_url="$2"
item="$3"
site_url="$(echo "$base_url"| sed 's#\(.*//.*\)/.*#\1#')"
date=$(echo "$item"|awk '{print $1}')
url=$(echo "$item"|awk '{print $2}')
page=$(echo "$item"|awk '{print $2}')
title=$(echo "$item"| cut -d ' ' -f 3- )
guid="$base_url/$(echo "$url" | sed 's#^/##')"
guid="$base_url/$(echo "$page" | sed 's#^/##')"
content=$(cat $DIR/$page/note.md | ./bin/mdpage_plain.sh)
cat <<-EOF
<item>
@ -84,16 +86,18 @@ render_item() {
<link>$guid</link>
<pubDate>$(date_to_rfc_822 "$date")</pubDate>
<title>$title</title>
<description><![CDATA[$content]]></description>
</item>
EOF
}
render_items() {
base_url="$1"
DIR="$1"
base_url="$2"
while read -r i
do render_item "$1" "$i"
do render_item "$DIR" "$base_url" "$i"
done
}
@ -118,4 +122,4 @@ render_feed() {
EOF
}
list_items "$1" | sort | render_items "$2$3" | render_feed "$2" "Konstantin Nazarov" "Konstantin Nazarov's blog"
list_items "$1" | sort | tail -10 | render_items "$1" "$2$3" | render_feed "$2" "Konstantin Nazarov" "Konstantin Nazarov's blog"