Kijana Woodard

Software Minimalism


Building My Own Blog

Saturday, December 8, 2012

Why not? I took a day and wrote a blog engine. I had a few goals in mind. I started by stealing, er, uh, learning from the blog of Tim G Thomas whose source code is conveniently on GitHub.

Minimalism

I didn't go bare minimum, but I feel like I got pretty close.

I cheated a bit. I didn't want a db, but I figured a blog has to have comments, so I went with Disqus. So, technically, Disqus has a db on my behalf and loads through js. But those things aren't in my code base which means I don't have to maintain them. Win.

I'm still deciding whether I should go with Gists for code or plain html code blocks. Gists look a bit nicer, can be forked and downloaded, but they introduce more javascript and the code is not in the actual markdown. If the gist goes away, that code is gone. What do you think?

For CSS, I could have gone with Twitter Bootstrap or Foundation, but when I was making my decision, they seemed pretty heavy weight for a blog. Kube plus Font Awesome seem to be doing quite well.

I considered adding an archive page, like on Tim Thomas' blog. Since I only have 20 posts as of now, I'll just list the all posts. Once I have a hundred posts, I can come back and add that feature.

I added an Atom feed just to see what that is like. It's trivial. Now, do I need it?

Speed

I was going for speed as well. I wanted page onload to be under 250ms. I was stoked when it was clocking in around 50ms.....until I added Disqus and Gist. The pops me to ~400ms, but I'll live with that for the features of Disqus. That fact may kill gists for me though. ;-)

Markdown

I've wondered what it would be like to write in Markdown. I have to say, having written these posts once in html having fought with the editor, writing in Markdown is very nice. It flows quite naturally. I like the use of labels for links. It makes it easy to refer to the same link many times in a document and you can have a nice bibliography. Check out the raw source of this post.

No DB!?! Where are the posts?

The posts are Markdown, so they are in the content folder. The meta data for posts are in classes. I have just enough infrastructure there to post into the future. I nixed some code about putting posts in "active status". Pure YAGNI.

I also didn't want a formula for the Slug. I wanted to tweak the slug, title, and file name without having to think about the output of a method somewhere. I also avoided a base class since I just describe the shape of the class. I created a ReSharper live template to output a new class and I fill in the details. Works well.

I'm giving up the ability to "blog on the go". In reality, that never happened with my WordPress blog. Writing blog posts takes hours, for me anyway. Also, I could always edit directly on GitHub and push to production if I wanted.

IoC

Yes. I actually typed IoC. I've been so negative on IoC lately, I wanted to give it a try again. I wanted to use it in a minimal way where it could provide value rather than blindly using it everywhere.

I actually setup some interfaces in the project. gasp

I wanted posts to follow the Open/Closed principle and have the ability to create a new blog post and have it be picked up by the infrastructure automatically without modifying some particular class. When FilteredPostValult.cs gets instantiated by the container, all the posts are there. That bit of magic is accomplished by this line of code.

I decided to use Autofac since I hadn't tried that one before. It works fine IMO and there are nuget packages to get all the bits you need.

Don't Fight the Framework

MVC 4 doesn't add trailing slashes to routes. For consistency, your routes should always end the same way. On my old wordpress blog, there was a trailing slash. I added a url rewrite rule to the web.config to redirect to the canonical form. I also normalized to lower case and to a non-www host name.

Except when you Fight the Framework

I wanted to see what it is like to put the model, view, and controller together in a folder instead of spreading them out across the project structure. I think I am striving for organization by feature, but this blog has too few features to know if that's working. :-D

In order to get this structure to work, I had to tweak the view engine. It's shockingly straight forward. This is customized exactly to the needs of this project.

Deployment

I used GitHub for source control, of course. I decided to see how easy it would be to launch a site on azure from github. I logged into Azure. Clicked on New -> Website. On the landing screen it asked me if I wanted to deploy from GitHub (amongst other choices). I picked the repo. Deployed. Wow.

Summary

I'm pretty happy with this all in all. There's not a whole lot of code. The idea that I spent as much time working on the posts as on the blog engine tells me I'm on the right track.

Tell me what you think.



If you see a mistake in the post *or* you want to make a comment, please submit an edit.

You can also contact me and I'll post the comment.

5 Comments...
Landon
Landon • 12 years ago

I'm a HUGE fan of minimalism in general. Sometimes that philosophy can get me into a bit of trouble because I often try to oversimplify complicated issues by focusing on the absolute essential. Even still, if I overlook a detail here or there I can go back and fix it when needed. I find thinking like a minimalist helps produce targeted solutions.

Now if you could just convince people to publish their deployment plans and their training guides in markdown instead of in random word documents littered throughout SharePoint sites! Then things would become indexed and searchable. The world would be a better place.

Brian O'Donnell
Brian O'Donnell • 12 years ago

First Comment!

Aisha Woodard
Aisha Woodard • 12 years ago

sweeeeet!

Iya Omitade Ifatoosin
Iya Omitade Ifatoosin • 12 years ago

I think you should stick to HTML 5. It is compact, easy and can be under your control no matter what the rest of the world it doing. It also probably loads faster than gist.

Joey Guerra
Joey Guerra • 12 years ago

I'm not convinced about using markdown as the data source. I still think HTML is better so that editors can include meta data about an article.