The Accidental Rubyist

invalid byte sequence in UTF-8

multi-blog blogging with Curl

leave a comment »

Finally, the multi-email multi-blog version of the Blogger for Google’s blog is ready for a release. A lot of changes have happened since the past release. Still some to iron up…

Getting the blogger to work with multi-blogs was no issue at all. But then i started using XSL for formatting the incoming XML. Seemed nice, but XSL can be quite a fight, if you don’t know it. After havin an XSL version ready, while adding more features, i decided to check out REXML, and i was able to do XML translation in REXML in a few minutes of starting, whereas XSL was proving to be too much of a pain with its syntax etc.

So now the simple 3 line config file has been replaced with a YAML file which i parse through ruby.
There is an option for generating the YAML file by giving email and password. So it’s not like a lot of work.

Now files and feeds are no longer dumped in the current directory. If a localcopy setting is present in the config file, all retrieves are populated there.
One may also specify the format of the directories and filenames (whether they should contain blog-id or name or alias, post-id or post-name etc).

In order to do multi-alias (an alias is a short mnemonic for a blog) work, I played around with some Vim scripting, and one may select an alias before any operation. The list of aliases is fetched from the config file and prompted. (The old mappings still work with the default alias, no prompting).

At some time i would like to rewrite this in ruby for two reasons.

  1. Currently almost every second line is a call to sed or tr or grep. There are also several calls to ruby (to read the YAML, or do some regexp work where sed was giving a seg fault). So it would make more sense to just put it all in one language, one process.
    Also there is a possibility that some “sed” command may not work on some unix system.

  2. Unix scripting is fine as a glue to other applications, but when each line is a call to some other application, then the interfacing can become clumsy. I ran into many quoting problems where a string being replaced contained single quotes.

I therefore looked at curb (ruby wrapper over libcurl) to do the CURL related work. Curb looks great but it not part of the standard ruby dist. For a program to run on a client, i did not want the user to have to install curb and rubygems. Especially if he is just checking out this software, and is not a ruby developer. The dependencies and installs must be as simple as possible to get someone to try this out.

So i will probably use the inbuilt Net:HTTP.

But for the moment, this Unix version of Blogger (aka My Curly Thing ™ ) is working fine. I shall continue to update it with any bug-fixes or refinements.

I shall prolly do some more testing, add some small plugins and make a 1.0 release in a few days.

[Edited in Vim using HTML.vim]


Written by totalrecall

March 12, 2007 at 9:06 pm

Posted in unix

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

%d bloggers like this: