MetaweblogFS: Ruby, FUSE, XML-RPC, oh my

I have been wanting to learn [Ruby](, and
I recently started playing with [FUSE](, for
creating file systems in user space in Unix.

And a couple of days ago, [Marcel]( asks
me if I knew of any blogging client that would allow complete offline
editing of the posts as files, and then synchronize them. That was
enough to plant the seed in my mind…

So I give you [MetaWeblogFS](/brt/files/metaweblogfs.rb), a quite
simple Ruby script that uses the
[FuseFS]( Ruby-FUSE bindings to
mount a filesystem in which your blog posts (for any blog that
implements the MetaWeblog API, including WordPress) appear as
files. The filenames are the titles, and you can edit posts simply by
editing the files, and create new posts by creating new files.

Here is how to use it:

ruby metaweblogfs.rb mountdirectory password host path user [blogid]

You can specify values for all the parameters at the beginning of the
script. It will connect to your blog, read the list of posts, and
create a file system in the mountpoint you specified. You can edit or
create new files there. Press Ctrl-C to finish the script and unmount
the filesystem.

This was in total about two hours of coding, having _never_ written a
Ruby program before. FUSE is just too cool, and the Ruby bindings make
it very easy to use.

Some tips, issues and (maybe) future development:

* Posts are saved as drafts by default (you can modify this at the top
of the script). To set a post to “published”, simply “touch” the

* “touch reload” to reload the list of posts (it is automatically reloaded after you modify or create files).

* FuseFS doesn’t allow to specify the mtime or atime of a file, so
post creation dates cannot be used as the file timestamp.

* For now it’s just a flat directory. Could be made to show
directories for categories, or time ranges, etc.

* New posts are created in the default category. I guess this could be fixed by having a directory structure representing categories, so you could create new files in the correct one.

Credit where credit is due: I took the XML-RPC code from [crafterm’s
and borrowed a lot from the FuseFS sample programs.

I’m writing this post in Emacs, directly on my blog’s mounted
directory 🙂


9 responses to “MetaweblogFS: Ruby, FUSE, XML-RPC, oh my

  1. Wow. That’s uber-cool! I haven’t gotten to install Fuse on my Mac (recently released by Google) but now I have no excuse 😉

  2. Thanks, Diego! It was surprisingly simple to set up on Gentoo: enable FUSE in the kernel, emerge fuse, and for Ruby support emerge fusefs.

    Next experiment: combine FUSE and Unison file synchronisation for offline capability.

  3. No, Unison does not work yet. When it propagates an update from the offline directory to the FUSE directory, it creates a temporary file and changes permissions on it. The chmod step fails with the message “Function not implemented”.

    Then I tried rsync. It does not have the chmod problem. But it leaves temporary files around, one for each file, even if the file hasn’t changed. Finally the problem remains that files that were updated are moved to Drafts.

  4. Hey this is pretty cool… your file doesn’t list a license used for it. Do you mind if I make changes to it and post the changes if they are useful?

  5. Jason: by all means, go ahead! Consider it as freeware. I haven’t had time to continue developing it, but I’d be happy to see new features added to it.

  6. Pingback: Jason E. Ormes - Linux, OS X, programming, tips, and other stuff that I find interesting…. » First release of modifications to metaweblogfs.rb

  7. Pingback: Jason E. Ormes - Linux, OS X, programming, tips, and other stuff that I find interesting…. » Question for the small masses that read this blog

  8. Pingback: /* Litchis ? */ » Blog Archive » Ruby, Trac and XML-RPC

  9. Pingback: » Fun with FUSE

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s