Writing blog posts in a web browser has always been a clunky compromise with a thin veneer. Native apps have a home field advantage that make the process butter-smooth. MarsEdit is the clearcut winner for managing blogs on the Mac. I bought it on a whim a while back and love using it to manage posts. The quickest way to bridge the gap between MarsEdit and a Rails-based blog is implementing the metaWeblog blogging API that MarsEdit can talk to.
The catch to adding metaWeblog support to a Rails blog is that metaWeblog is an XML-RPC API and Rails really really really prefers providing a JSON-based REST API. Who could blame it?
Luckily, like most problems in life, there is a gem for that. Getting up and running with metaWeblog is a 3 step process on Rails:
- Add the
rails-xmlrpcgem to your
- Add the xml-rpc route to
- Implement the metaWeblog API methods
Let’s walk through this.
First, add the following to your Gemfile:
Then run a quick
Second, we need to add a route in
config/routes.rb for our upcoming xmlrpc controller:
post 'xmlrpc' => 'xmlrpc#xe_index'
Third, we need to implement all the methods that metaWeblog requires into a controller that can talk to the
I could plaster a huge block of code in this post but I won’t because that would be rude. Because every Rails blog does the same thing in it’s own special snowflake ❄️ way, your implementation of these methods will depend on how you manage your articles in Rails. You can look over what methods you need and how I implemented them here. I’ve lazily named my controller
XmlrpcController in this example. Make sure your route from Step 2 reflects the name you give it. Feel free to copy and paste if you want to.
After our site speaks metaWeblog we can add it into MarsEdit and begin writing.
Add the blog in MarsEdit via File ➡️ New Blog.
MarsEdit won’t be able to automagically detect your custom settings so select Edit Settings.
Change System Name to Other and change System API to MetaWeblog.
Set your API Endpoint URL to the route we created in the last section.
Make sure to set your Blog ID to whatever you need it to be. If you only have one blog then it won’t be too important.
Then press OK.
Wait! Wait right there! Don’t start yet! I saw you try!
If you require authentication to post to your blog you need to right-click on your blog in the Blogs column and select Enter Password and enter your username and password for logging in to your blog. If you don’t require authentication then you should change that.
After all that sweat and toil, your Rails blog should now be able to do what most every blog has been able to do out-of-the-box since 2003. 👍