More than a year ago, I’ve built a website for the community garden by the Jerusalem Natural History Museum. Building is fun, but maintaining — that is manually converting each and every mail Amnon sends into a form Pelican can read, as well as saving the attachments and link them — is unimaginative and boring, and therefore… how shall I put it… I wasn’t very active with the updates (in fact I rather abandoned the website).
But wait a moment, Juda, isn’t that’s exactly what computers are meant for, doing tedious, unimaginative, boring tasks? They are, so that is what I wanted to do. After searching the web, the closest thing I could find was JekyllMail; it seems to work well for 88 people, but for me it has several disadvantages:
- It’s non-generic design is for Jekyll (not a big deal: it is easy to write a conversion script, and I’m quite sure someone already have written such a script).
- It isn’t static: instead of working on local files, it connects to servers and does stuff which should be done by small, sharp tools (in our case, OfflineIMAP and Git).
- It assumes an exclusive mail address, which is IMHO just an unnecessary complication.
- It works with POP3, which I just hate, when IMAP is well-supported.
Therefore, I wrote a small tool, named mail2staticsite1, which does a very simple task:
- It takes the mail within a certain Maildir,
- parses and processes it (for example, it removes prefixes such s
re:
andfwd:
from the subject), - saves the attachments and links them (images are embedded (
<img>
) and other files are just linked (<a>
)), - it spits out the result into local directories which can be read by Pelican, Jekyll or any other static site generator.
Right now it works fine for the community garden2, but there is a lot to be done. If you want to join in and improve the code, you are welcome ☺
-
It is an opportunity to announce I’ve moved from GitHub to GitLab, because I think we should eat our own dog food, meaning: the current situation where many FOSS projects use proprietary closed-source software for their version control is absurd. ↩
-
Except when attachments have their name in Hebrew. I think the problem is due to Gmail’s treatment of Unicode filenames. I hope I’ll fix this soon. ↩