A New Blog

By
Dave
Project
Published
21 Jun 2010 23:04
Last Modified
13 Jan 2013 18:21

I finally decided to switch to using my own blog engine. There were several reasons for this:

  1. I was getting too much spam with my existing engine
  2. I wanted complete control over rendering
  3. 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:

  1. Single author, single blog
  2. View posts, with filtering by category, tag, year, month, day, and name
  3. Paging on post views
  4. Submit comments
  5. View comments with post detail
  6. Author sign-in to create & edit posts, edit & delete comments
  7. Syndication
  8. Recent posts, archive list, tag cloud, blogroll

Going forward, the following were good candidate next-steps:

  1. Live-writer support
  2. SEO
  3. Further feed-format support for ATOM
  4. 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:

  1. http://{domain}/blog/ for all posts
  2. http://{domain}/blog/arhive/{year} for all posts in a given year>
  3. http://{domain}/blog/arhive/{year}/{month} for all posts in a given month
  4. http://{domain}/blog/arhive/{year}/{month}/{day} for all posts in a given day
  5. http://{domain}/blog/arhive/{year}/{month}/{day}/{name} for a specific post
  6. http://{domain}/blog/category/{name} for posts in a given category
  7. http://{domain}/blog/tag/{name} for posts with a given tag
  8. 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

By
Vinil
29 Jun 2010 07:52
Rob's also building one at http://robmensching.com/robmensching.blog/
By
Dave
1 Jul 2010 23:13
Thanks Vinil, I'll check it out!

Add Comment

*
*
*
Captcha
*
*Required