Logo 61e73bc61c0e1780102320e879dc3cac0e29303ea8894dd8f10c942f3ba8120f

otters.io

An adorable little blog

Making a Better Rails Blog with MarsEdit

Friday — December 18th, 2015

MarsEdit

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:


  1. Add the rails-xmlrpc gem to your Gemfile
  2. Add the xml-rpc route to config/routes.rb
  3. Implement the metaWeblog API methods

Let’s walk through this.


First, add the following to your Gemfile:

gem 'rails-xmlrpc'


Then run a quick bundle install.


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 rails-xmlrpc gem.

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.


Screen Shot 2015 12 18 at 12 28 23 AMScreen Shot 2015 12 18 at 12 28 55 AM

MarsEdit won’t be able to automagically detect your custom settings so select Edit Settings.


Screen Shot 2015 12 18 at 4 46 50 PM

Change System Name to Other and change System API to MetaWeblog.


Screen Shot 2015 12 18 at 12 29 55 AM

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.


Screen Shot 2015 12 18 at 12 30 10 AMScreen Shot 2015 12 18 at 12 30 21 AM

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. 👍