Pete Hamilton

Society Newsletters powered by Node.js

Last year when I was secretary of Imperial College’s Computing Society or DoCSoc) we decided to clean up the amount of email we sent to students, compiling everything into a weekly newsletter. The mailing list is internal to university, so sending a pretty email using something like Mailchimp or Campaign Monitor is basically impossible.

At the time, I created a quick digest-email rubygem which took a YAML file containing all the news items, a basic html template, css file and process it all to produce html for the email. It was a pretty neat project and saved me a tonne of time. People contributed their YAML snippets and I just pressed “GO”.

This year, I wanted to continue using this newsletter style of communication. However I wanted to try something new technology-wise, so I’ve created a similar tool but using completely different technologies.

All email content is done in Markdown, your templating is done in Jade, your CSS in Stylus and NodeJS then pulls it all together, pushes it through Juice to inline all the CSS for email compatibility and outputs it to an HTML file.

You can see more on the project here

The obvious advantage is that people can design templates and CSS as they would normal webpages, albeit with a few caveats for HTML emails

Whilst this is similar to the ruby version, this project does a few nifty things like extracting primary headers automatically and using them to create an automatic agenda at the top of the newsletter.

This was just for fun, but who knows, maybe someone else will find it useful. From my point of view, it was just fun to play with NodeJS for the first time properly. If I’ve done something boneheaded and evidently just don’t understand javascript, please do comment below ;)