Permalink
Browse files

Say who the RSS Feed is for

  • Loading branch information...
1 parent 6f05476 commit f9ea99c82b27fe287939dcb95d76b8b3360ea57f @ayende committed Feb 10, 2012
Showing with 14 additions and 9 deletions.
  1. +14 −9 RaccoonBlog.Web/Controllers/SyndicationController.cs
@@ -45,11 +45,15 @@ public ActionResult Rss(string tag, string token)
var postsQuery = RavenSession.Query<Post>()
.Statistics(out stats);
- int take = 20;
- if (string.IsNullOrEmpty(token) == false)
+ int take = 20;
+ var title = BlogConfig.Title;
+ if (string.IsNullOrEmpty(token) == false)
{
- var numberOfDays = GetNumberOfDays(token);
+ int numberOfDays;
+ string user;
+ GetNumberOfDays(token, out numberOfDays, out user);
take = Math.Max(numberOfDays, take);
+ title = title + " for " + user;
postsQuery = postsQuery.Where(x => x.PublishAt < DateTimeOffset.Now.AddDays(numberOfDays).AsMinutes());
}
else
@@ -66,15 +70,15 @@ public ActionResult Rss(string tag, string token)
string responseETagHeader;
if (CheckEtag(stats, out responseETagHeader))
- return HttpNotModified();
-
+ return HttpNotModified();
+
var rss = new XDocument(
new XElement("rss",
new XAttribute("version", "2.0"),
new XElement("channel",
- new XElement("title", BlogConfig.Title),
+ new XElement("title", title),
new XElement("link", Url.RelativeToAbsolute(Url.RouteUrl("homepage"))),
- new XElement("description", BlogConfig.MetaDescription ?? BlogConfig.Title),
+ new XElement("description", BlogConfig.MetaDescription ?? title),
new XElement("copyright", String.Format("{0} (c) {1}", BlogConfig.Copyright, DateTime.Now.Year)),
new XElement("ttl", "60"),
from post in posts
@@ -94,7 +98,7 @@ public ActionResult Rss(string tag, string token)
}
- private int GetNumberOfDays(string token)
+ private void GetNumberOfDays(string token, out int numberOfDays, out string user)
{
using (var rijndael = Rijndael.Create())
{
@@ -109,7 +113,8 @@ private int GetNumberOfDays(string token)
if (DateTime.UtcNow > expiry)
throw new InvalidOperationException("The key has already expired.");
- return reader.ReadInt32();
+ numberOfDays = reader.ReadInt32();
+ user = reader.ReadString();
}
}
}

0 comments on commit f9ea99c

Please sign in to comment.