Wednesday, March 10, 2010


If you are like me--a person who hates to fire up wysiwyg editors (or even worse--an editor in a browser) to make a blog post, then you may like a tiny Ruby program called podgraph.

It parses an XHTML file and creates a proper MIME mail from it. "Proper" means that if you have included some local images in your html, they will be encoded and bundled with the mail as inline images (see RFC2387).

After creating the mail, podgraph can automatically send it somewhere, probably to your mail-to-blog gateway.

To install podgraph 0.0.1, make sure that you have Ruby 1.9 on your machine and type as root:

# gem install podgraph

For the help, type:

% ri Podgraph


As starting a brand new blog at, I came up with an old problem: how to post to <my lousy blog> from Emacs? There is no working posterous client for Emacs (at least I don't know any), but thank g-d we can use just html emails for simulating that.

A long time ago before joining to Ruby camp, I fell in love with python's reStructuredText. It gives me an ability not to struggle with damn html tags but to write blog posts in (more or less) human readable text and then convert it to lame html.

So, at the present time any posting to posterous looks like this:

  1. Editing (in Emacs)

  2. Typing gmake in the directory with Makefile:

    PODGRAPH := ~/lib/software/alex/podgraph/trunk/bin/podgraph
    #PODGRAPH := podgraph
    .PHONY : clean html
    XHTML := $(addsuffix .html,$(basename $(wildcard *.rest)))
    all: html
    .SUFFIXES: .rest .html .sent
       rst2html -o koi8-r < $< > $@
       $(PODGRAPH) $<
       touch $@
    html: $(XHTML)
       rm -f *.html

    Which brings to me file.html.

  3. Previewing in the browser the result: firefox3 file.html.

  4. Typing gmake file.sent--and podgraph suddenly creates the MIME mail and delivers it to posterous.

Btw, the whole process tested only on FreeBSD. I don't see any possible Linux quirks here, but if you'll find some, don't forget to tell me.

No comments:

Post a Comment