Friday, May 19, 2006

Blogger in VIm!

Last summer I spent some time putting together a Python API for blogger utilizing their ATOM publishing support. Its sat dormant for the most part except for a small script I threw together to post entries I wrote.

The problem with this approach was that the writing-posting-editing-posting sequence looked like this:

  • Open VIm
  • Write post
  • Exit VIm
  • $ cmd_blog.py path/to/entry
  • "Shoot! Its wrong!"
  • Load Firefox
  • Go to blogger.com
  • Clickity Clickity
  • Load just posted article
  • Edit
  • Click submit.
As you can see, that was majorly lame so this week in my few spare cycles away from work, I started reading about VIm's python support. Within an hour I had a basic UI working. I could load up the entry list, and view each entry by double clicking on the line.

Much thanks goes to TagList for which I did much learning with.

Tonight I spent some more time on it and have the following working:

  • Entry List - When you first load up the script, it will connect to blogger.com and download the articles stored in your blogger account. The limit is about 100, per blogger.com's limitations.
  • Load Entries - Double Click on a line in the Entry List and a window on the right will open allowing you to see the xhtml contents of the entry, properly highlighted.
  • Edit Entries - After you double click on an entry, just edit it to your heart's content and then (figure out how to easily do this, keybinding?) go into command mode and type: :python UpdateEntry()
  • Post new entries. Open a new buffer, type away, then type: :python PostEntry()
  • Fame - Be the envy of your vim or blogger using friends!
It looks like this:

Not pretty, but who ever said vim was pretty looking?

Still haven't done anything else with this but to get it to load (a reminder):
  export PYTHONPATH=~/src/code:./:$PYTHONPATH;
  load vim
  :so vim_blogger.vim