/
default.tagfeed.do
50 lines (43 loc) · 1.55 KB
/
default.tagfeed.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# This file makes feed, for each tag, of recent articles, etc.
tag="$1"
author_name="Name"
author_email="email@domain.com"
icon="http://icon.com"
title="Tag: $tag"
home="http://example.com"
this_tag="$home/$tag"
this_feed="$this_tag/feed.atom"
atom_format="%Y-%m-%dT%H:%M:%SZ"
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<feed xmlns="http://www.w3.org/2005/Atom">'
echo " <title>$title</title>"
echo " <link href='$this_feed' rel='self' />"
echo " <link href='$home' />"
echo " <id>$this_feed</id>"
echo " <updated>$(date "+$atom_format")</updated>"
echo " <author>
<name>$author_name</name>
<email>$author_email</email>
</author>"
echo ' <generator uri="https://github.com/psycotica0/redo-blog2">Redo-Blog2</generator>'
echo " <icon>$icon</icon>"
# Contents Go Here
redo-ifchange "tagindex"
grep "^$tag " < "tagindex" | cut -d ' ' -f 2- | tac | while read file; do
redo-ifchange "$file.converted"
title="$(sed -n 's/Title:[ ]*\(.*\)/\1/p' < "$file.converted")"
mod_date="$(sed -n 's/Date-Modified:[ ]*\(.*\)/\1/p' < "$file.converted")"
create_date="$(sed -n 's/Date-Created:[ ]*\(.*\)/\1/p' < "$file.converted")"
echo ' <entry>'
echo " <link rel='alternate' type='text/html' href='$this_tag/$file.html' />"
echo " <id>$this_tag/$file.html</id>"
echo " <title>$title</title>"
echo " <published>$create_date</published>"
echo " <updated>$mod_date</updated>"
# Now spit out the body
echo ' <content type="html">'
sed '1,/^$/d' < "$file.converted" | sed 's/</\</g' | sed 's/>/\>/g'
echo ' </content>'
echo ' </entry>'
done
echo '</feed>'