Encode the Next and Previous Links.

Christopher Vollick [2010-03-20 19:42]
Encode the Next and Previous Links.

So, it was dumb of me to be passing those through as titles.
So, now I pass through the encoded ones, and the titles.
Win Win!
Filename
gitsite
diff --git a/gitsite b/gitsite
index 6203f22..4c99b57 100755
--- a/gitsite
+++ b/gitsite
@@ -49,6 +49,10 @@ for index in $(seq 1 $numArticles); do
 	prev="$(echo "$articles" | sed -n "$(expr $index - 1)p")"
 	next="$(echo "$articles" | sed -n "$(expr $index + 1)p")"

+	# And get the links to them
+	prevLink="$(echo "$prev" | ./encode_filename)"
+	nextLink="$(echo "$next" | ./encode_filename)"
+
 	# Get the title
 	title="$(echo "$articles" | sed -n "${index}p")"

@@ -72,10 +76,10 @@ for index in $(seq 1 $numArticles); do
 	./markup_engine < "articles/$title" > "$tmpArticleDir/$title"

 	# Now, run the article template on the content.
-	templates/article Content "|$tmpArticleDir/$title" Title "$title" Next "$next" Previous "$prev" CreationDate "$published" ModificationDate "$modified" ID "$id" > "$tmpArticleTemplateDir/$title"
+	templates/article Content "|$tmpArticleDir/$title" Title "$title" NextTitle "$next" NextLink "$nextLink" PreviousTitle "$prev" PreviousLink "$prevLink" CreationDate "$published" ModificationDate "$modified" ID "$id" > "$tmpArticleTemplateDir/$title"

 	# Finish off with the site template
-	templates/site Content "|$tmpArticleTemplateDir/$title" Title "$title" Next "$next" Previous "$prev" CreationDate "$published" ModificationDate "$modified" ID "$id" > "$articleDestDir/${encTitle}"
+	templates/site Content "|$tmpArticleTemplateDir/$title" Title "$title" NextTitle "$next" NextLink "$nextLink" PreviousTitle "$prev" PreviousLink "$prevLink" CreationDate "$published" ModificationDate "$modified" ID "$id" > "$articleDestDir/${encTitle}"

 	# And make a permalink
 	ln -f "$articleDestDir/$encTitle" "$idDestDir/$id"
ViewGit