Well, here we are: my new blog is online! I've dropped the old code base, which was a Rails 2.3.8 app, and completely rewritten the blogging engine as a Rails 3 Engine called Mist.
Mist doesn't use any database adapters at all. Instead, the articles I write are committed to a back-end git repository. When you read the article, Mist is pulling the article from the git repository, doing some magic behind the scenes to turn it into an ActiveModel, and then sending it out to a Rails view. The whole process is completely seamless, and a
Post feels just like an instance of
One major benefit of backing all the posts with a git repository is that any time I need a copy of the blog or want to make a backup, I can simply
git pull from the repo, and I'm done!
I had originally planned to make the web app's
public/ directory part of the repo so that each post is effectively page cached and served directly from Apache for maximum throughput. However, I decided this wasn't really viable due to things like the Rails layout and whatnot. It would make posts very unfriendly to changes going forward, and this effect would only be slightly mitigated by rendering partials and sending those to the application layout.
Besides, Rails already offers some very flexible caching options. Why reinvent all that?
I also decided that Mist should automatically convert code examples into Gists. As I started coding this, though, it became apparent that there was no reason that this part of the system should be coupled so tightly to Mist.
Instead, I created another gem altogether which Mist now claims as a dependency: ActiveGist! ActiveGist is a wrapper around the GitHub Gist API which, just like my Git-backed Posts, feels just like an instance of
ActiveRecord. It's designed to be as friendly as possible to Rails developers, and in my humble opinion it has done exactly that.
So Mist uses ActiveGist to embed Gists into posts. This gives you syntax highlighting for free, while allowing people to fork your example code, submit patches to it, and do all those amazing things that GitHub has made possible.
The App Itself
So as I mentioned, Mist is an Engine. It can be dropped into any Rails app pretty quickly and easily. I just tested exactly that by dropping Mist into the app running this blog. I added
omniauth so that we can sign in using our GitHub accounts, and then tied that into the Mist authorization hooks (which occupies about 3 lines of code). That was pretty much all I did!
The user account is still tied to ActiveRecord, but user accounts are much more dynamic than posts and so I believe that is probably the right call.
User will inherit from
ActiveRecord::Base from here on.
As you can see, the blog is still pretty sparse. I'm still deciding whether I like the look and feel (some parts yes, some parts not so much) and will probably continue iterating on that for some time.
I haven't implemented comments yet, nor the ability to parse pingbacks. I will do so eventually, but they were "nice to have" and not "must have". The old code base was really not cutting it and I needed to ship something fast, so I decided to hold off and ship!
I used to have a section for each post for Twitter mentions ("tweetbacks", if you will). I may reimplement that at some point, but it's a low priority item.
But what about the content?
You can still get to all of my old blog posts. I even found time to fix the RDoc formatter today, which turned out to be a fairly simple dependency problem. So it's displaying properly, for the most part.
I'm going to slowly start taking the most popular posts from the old blog software and re-publish them under my new one. But I have also amassed quite a list of new topics I'd like to discuss! Expect a little of both to start making its way here, as my spare time permits.