I didn't go bare minimum, but I feel like I got pretty close.
- No DB.
- A minimal css framework called Kube.
- CSS icons from Font Awesome.
- Markdown for posts (like this one).
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 considered adding an archive page, like on Tim Thomas' blog. Since I only have 20 posts as of now, I'll juts 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?
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. ;-)
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.
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.
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.
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.