It's been a while since I've written here, but I've been busy! I've always written more code than prose (follow me on GitHub!) but a couple of months ago I set out to change that. I was in the mood to share something that I had learned, and was struck again, as always, by how awkward it is to post sample code in WordPress (and every other blogging platform that I can find).
So I set out to fix that, and instead of writing a blog post I wrote myself a new blogging platform! It's called Balisong, and it aims to be the best blogging platform for coders. I'll create more documentation for it soon, but in the meantime you can read more about it and follow the code on GitHub. I didn't really want to create something entirely new, I'm happy to build on someone else's foundation, but I looked around for something to use (or at least fork and modify) and I just wasn't satisfied with the options.
Balisong solves the many problems that occur when including code samples in a blog post by allowing source code sections in blog articles to be first-class citizens. Source code is stored as source files rather than cut & pasted into the article text. It's simply referenced in the article, and Balisong includes the specified lines, complete with syntax highlighting. That way you can run and test your code, and edit it in your favorite editor, but have it presented beautifully in your post.
Here's an example of a post with code included in it, and here is the source for that article. The markdown file main.md is the main article, and it simply references the source code files. Title and other metadata is in attributes.json.
Balisong stores the articles, along with all included code samples and images, in a Git repository. (You can follow the content of this blog here). Balisong posts are written using one of several rich text formats (I use markdown), and edited in whichever editor you like. Simply commit the new article to the local Git repo and then "git push" to push the content live. There are many static site generators that let you do this (e.g. Jekyll), but I wanted more than a static site. As a software developer my site should be a showcase for my skills, or at least a place to try out new things.
So needless to say I'm now using Balisong for this site, I hope you like it! If you want to use it for your site you can find the code and documentation on GitHub, and feel free to ask me if the documentation is unclear (it will be improved soon!) or if you have questions.
Oh, and while writing Balisong, I also created GitModel, an ActiveModel-compliant persistence framework for Ruby that uses Git for versioning and remote syncing. It reads & writes ruby objects (in a human-editable format) to/from a Git repo. More on that later...