Permalink
Browse files

Added Feeds per Tag

Like the index, it currently contains all articles and the entire
contents of those articles.

They mostly validate, but it doesn't like the html bits.
Understandable.
I think GitSite would have had the same issue.
  • Loading branch information...
1 parent 87b48d9 commit 8609300f8a2cbad3c64d77c79587a3747b6ba7c0 @psycotica0 committed Dec 6, 2011
Showing with 59 additions and 0 deletions.
  1. +1 −0 all.do
  2. +50 −0 default.tagfeed.do
  3. +8 −0 deploy.do
View
1 all.do
@@ -7,3 +7,4 @@ sed 's/^\([^ ]*\) \(.*\)$/\2.\1.html/' < "tagindex" | xargs redo-ifchange
# And make a tagindex for each tag
sed 's/^\([^ ]*\) .*/\1.tagindex/' < "tagindex" | sort | uniq | xargs redo-ifchange
+sed 's/^\([^ ]*\) .*/\1.tagfeed/' < "tagindex" | sort | uniq | xargs redo-ifchange
View
@@ -0,0 +1,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"
+ echo ' </content>'
+ echo ' </entry>'
+done
+
+echo '</feed>'
View
@@ -17,3 +17,11 @@ ls *.tagindex | while read line; do
mkdir -p "$tag"
cp "$line" "$tag/index.html"
done
+
+# And move the feed files in too
+ls *.tagfeed | while read line; do
+ tag="$(basename "$line" ".tagfeed")"
+ # Just a precaution
+ mkdir -p "$tag"
+ cp "$line" "$tag/feed.atom"
+done

0 comments on commit 8609300

Please sign in to comment.