Now Does Atom Feeds.

Christopher Vollick [2010-03-20 23:28]
Now Does Atom Feeds.

At some point I need to make a lot of this stuff more generic and optional.

For now, though, this will do.
Filename
gitsite
diff --git a/gitsite b/gitsite
index ba5d4cb..e4d08ff 100755
--- a/gitsite
+++ b/gitsite
@@ -3,6 +3,9 @@
 srcDir="$1"
 destDir="$2"

+# This is the number of items to include in our feeds
+feedNum="10"
+
 # Make the destDir if it doesn't exist
 mkdir -p "$destDir"

@@ -34,6 +37,10 @@ mkdir -p "$tmpArticleDir"
 tmpArticleTemplateDir="$tmpDir/articleTemplated"
 mkdir -p "$tmpArticleTemplateDir"

+# Initialize the atom temp file
+tmpAtom="$tmpDir/temp-atom"
+echo -n "" > "$tmpAtom"
+
 # Get the list, in order of creation, of all articles
 articlesAndIds="$(ls articles/ | while read article; do echo "$(git log --follow --pretty=format:%at "articles/$article" | sed -n '$p')	$article"; done | sort -r)"

@@ -83,8 +90,16 @@ for index in $(seq 1 $numArticles); do

 	# And make a permalink
 	ln -f "$articleDestDir/$encTitle" "$idDestDir/$id"
+
+	# If this article is within the first feedNum, run it through there.
+	if [ "$index" -le "$feedNum" ]; then
+		templates/atom-entry Content "|$tmpArticleDir/$title" Title "$title" NextTitle "$next" NextLink "$nextLink" PreviousTitle "$prev" PreviousLink "$prevLink" CreationDate "$published" ModificationDate "$modified" ID "$id" >> "$tmpAtom"
+	fi
 done

+# Now generate the atom feed
+templates/atom-feed Content "|$tmpAtom" > "$absDestDir/feed.atom"
+
 rm -rf "$tmpDir"

 # Copy over the static content
ViewGit