Storybot - An email interface to EFX

Okay... The gawk work paid off. I have an alpha-quality email conduit into EFX called Storybot. It is written (currently) in under 1000 lines of gawk.

Storybot downloads pop email, validates the user for publishing rights, splits up the mime attachments, decodes base64 attachments, formats both HTML and plain text, links (or in the case of images: inlines) in the attachments and places the results in the content section of the site (for later publishing).

Eventually, the whole "email approval by editor" thing will be implemented too. Right now, you either have publishing rights or not.

Here is the current rendering pipeline (from fetching email from the POP3 server to copying the files over to the content area):

export STORYBOT_BASEDIR=/home/todd/src/efx/storybot/root
./pop3fetch | ./maketicket | ./headers  | ./verify  | ./mimesplit \ 
    | ./decode64 | ./fiximgfile | ./choosebodyformat | ./formathtml \ 
    | ./formattext | ./genstory | ./submitstory | ./cleanup
Its all done in 100% gawk (plus "cp" for file copying)!

Permalink |  Thursday, December 29 11:45 PM

EFX content tools in (g)awk?

I'm doing a bit of AWK at work, and so that caused me to revisit the classic book The AWK Programming Language. This is one of those books that significantly changed the way I programmed. It is simply and amazing (and short) read, even if you don't use AWK.

So, I maybe feeling a bit nostalgic, but I really like AWK. It is dead simple, elegant (IMHO), and integrates very nicely with other Unix apps.

I was curious to see what would happen when I googled AWK and stumbled upon this amazing page: .

Wow. Here is a snippet:

     BEGIN {
       "/inet/tcp/0/localhost/daytime" |& getline
       print $$0

This vaguely reminds me of how Plan 9 uses the file system to represent services. I like it. They basically just introduced a bi-directional pipe operator ''|&'' to gawk and the notion that /inet starts the description a protocol stack/path.

Here is a more pertinent example (from the manual):

     BEGIN {
       POPService  = "/inet/tcp/0/emailhost/pop3"
       RS = ORS = "\r\n"
       print "user name"            |& POPService
       POPService                    |& getline
       print "pass password"         |& POPService
       POPService                    |& getline
       print "retr 1"                |& POPService
       POPService                    |& getline
       if ($$1 != "+OK") exit
       print "quit"                  |& POPService
       RS = "\r\n\\.\r\n"
       POPService |& getline
       print $$0
You may see where I am going with this...

Of course, now, this would just be plain crazy ;-)

Permalink |  Friday, December 16 12:35 PM