Contains coding, but not narcotic.

Rump gets more CRUDdy

July 10th, 2010 1:22:32 pm pst by Sterling Camden

Since the MetaWebLog API provides “getPost”, “editPost”, and sometimes “deletePost” methods, I’ve added corresponding operations to rump (my text-editor-oriented blogging tool) via three new command-line switches:

-u ID

Updates the post identified by ID. This overrides the default operation of adding a new post. It has no effect if -p (preview), -f (fetch), or -d (delete) are also specified.

-d ID

Deletes the post identified by ID. This overrides the default operation of adding a new post, or any -u switch. It has no effect if -p (preview) or -f (fetch) are also specified. Since deletePost is not included in the MetaWebLog API specification, you’ll have to see whether your blogging framework provides it. WordPress does.

-f ID

Fetches the post identified by ID. This overrides the default operation of adding a new post, or any -u or -d switch. It has no effect if -p (preview) is specified.

When fetching, replacements are performed on the resulting post, which is then sent to $stdout in rump source format. That allows you to edit it and then resubmit it either as an update to the original or as a new post.

This opens up a number of new possible uses for rump. You could use it to backup your blog to rump files. You could retrieve and edit posts in vim (or your preferred text editor, as long as it can read/write pipes) without ever saving them to a local file. You could construct a fetch/update pipe in a loop to perform mass edits. Your blog is now entirely pipable.

download

BitBucket repository

Posted in Ruby, Web | 1 Comment » RSS 2.0

Rump – Ruby Upload Metaweblog Post

June 16th, 2010 3:14:42 pm pst by Sterling Camden

Ever since moving to vim as my primary editor, I’ve wished that I could also use it as my blogging platform, without having to copy/paste and reformat everything. Well, now I can — in fact, I’m posting this directly from vim.

I created a Ruby script named rump — it’s an acronym for Ruby Upload Metaweblog Post, but it also reflects the fact that blogging is a form of showing your ass. You can download this script below, or access it from its Bitbucket repository.

See the included README file for details. Essentially, you write your blog post as Ruby code — but rump provides some methods to keep that code to a minimum. For instance, in this post, I have a command for title, categories, tags, and content — the latter using a Here document as its parameter. Let me illustrate:

title "Rump - Ruby Upload Metaweblog Post"

tags "ruby, blogging, metaweblogapi, vim"
category "Ruby"
category "Web"

content <<EOF

(content goes here)

EOF 

The rump script takes this file, or any number of files, as arguments. So, I use a configuration file as the first argument to set up static things like what server to access, followed by the file that contains the post. You can also override settings in the command line with -e “commands”. The special file name “-” represents STDIN.

To make this even easier, I set up a separate directory on my local system for each blog, then put all the configuration commands into a file named .rump. Then, I mapped F12 in vim to post using that file, by adding the following to my .vimrc:

:map <F12> :w !rump .rump -^M

That “^M” is an actual return character.

So, now that I’m done with this post, I’ll press F12 and it will magically appear on Chip’s Tips.

download

Posted in Ruby, Web | 10 Comments » RSS 2.0