Name
podgraph – Create an email from XHTML + inline images and send it to posterous.com.
Synopsis
podgraph [options] [file.html]
Description
It is a simple program that reads a XHTML file (or stdin), extracts subject and body from the file, constructs an email and delivers it to local MTA.
The options are as follows:
-v Be more verbose.
-S Don't send, just dump the mail to stdout.
-m ARG 1 of modes: related, mixed.
--from EMAIL 'From' address
--to EMAIL 'To' address
The file is supposed to be a XHTML generated by python’s docutils from reStructuredText. The idea is:
-
Write a post (for example, for posterous.com) in reStructuredText in Emacs.
-
Convert it with help of docutils to the XHTML.
-
Finally, create a proper MIME mail from the raw XHTML and send it to posterous.com.
Step 3 is what podgraph does.
Features
-
Generates mail with inline images if it can found links to local images in the XHTML file.
-
Charset of ‘text/html’ portion of a mail is always UTF-8.
Exit status
Program exits 0 on success (something was generated or even delivered), or >= 1 if en error occurs.
Examples
Create a config.yaml file in the directory with your writings. For example:
% cd ~/lib/writing/posterous
% cat config.yaml
:to: [email protected]
:from: [email protected]
(‘–to’ & ‘–from’ command line options override values in config.yaml.)
Start writing a .rest file:
% emacsclient 0001.rest &
- …
-
To give podgraph a chance to find a subject for the mail, write .rest file as:
This is a subject ----------------- My usual reStructuredText.
Or in another words, the first 2 tags in the body of the the XHTML must be:
<div><h1>My subject</h1> [...]
Convert it to XHTML:
% rst2html < 0001.rest > 0001.html
Send to posterous.com:
% podgraph 0001.html
Also, you can preview the mail without sending it:
% podgraph -S 0001.html
If you have links to local images in your .rest file (and correspondingly in .html) then podgraph will include images in the mail as inline images. But if you don’t want this and want images to become a typical gallery on posterous.com, run:
% podgraph -m mixed 0001.html
This will generate the mail with usual boring attachments.