I finally decided to switch to using my own blog engine. There were several reasons for this:
- I was getting too much spam with my existing engine
- I wanted complete control over rendering
- But really...I needed an excuse to learn the ASP.NET MVC2 Framework! :)
I didn't need anything particularly fancy, and the following requirements would initially suffice:
- Single author, single blog
- View posts, with filtering by category, tag, year, month, day, and name
- Paging on post views
- Submit comments
- View comments with post detail
- Author sign-in to create & edit posts, edit & delete comments
- Syndication
- Recent posts, archive list, tag cloud, blogroll
Going forward, the following were good candidate next-steps:
- Live-writer support
- SEO
- Further feed-format support for ATOM
- Mobile support
Storage
I decided to stick with XML files for the time-being, mainly since my previous engine used them and it would save having to migrate the content to a database. Going forward, a database would clearly be a more scalable option, but it will be a while before I generate enough content for this to be an issue.
Syndication
I used the WCF SyndicationFeed and SyndicationItem classes to build an RSS 2.0 feed, and returned the feed from my controller as a derived ActionResult, using an approach outlined in this post on Joe Wardell's blog, and shown below in Listing 1.
public class RssResult : ActionResult
{
public SyndicationFeed Feed { get; set; }
public RssResult() { }
public RssResult(SyndicationFeed feed)
{
this.Feed = feed;
}
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
Rss20FeedFormatter formatter = new Rss20FeedFormatter(this.Feed);
using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
formatter.WriteTo(writer);
}
}
}
Listing 1. Returning an RSS feed as a derived ActionResult
URL Structure
Backwards-compatibility with any links to the existing blog were something I needed to consider. An appropriate route specification should ensure compatibility, but at the expense of having to use .aspx extensions.
Looking at popular blog engines such as WordPress and MSDN, I decided to use the following scheme:
- http://{domain}/blog/ for all posts
- http://{domain}/blog/arhive/{year} for all posts in a given year
- http://{domain}/blog/arhive/{year}/{month} for all posts in a given month
- http://{domain}/blog/arhive/{year}/{month}/{day} for all posts in a given day
- http://{domain}/blog/arhive/{year}/{month}/{day}/{name} for a specific post
- http://{domain}/blog/category/{name} for posts in a given category
- http://{domain}/blog/tag/{name} for posts with a given tag
- http://{domain}/blog/feed for an RSS 2.0 feed
Posts are paged and ordered chronologically with newest posts first.
I'm hoping to switch in a couple of days, at which point any feed subscriptions will need updating. Apologies for any inconvenience.
Comments
Add Comment