I've begun work on a branch to allow administrators to e-mail the full body of an article to subscribers as and when they are first published (following the example of James Edward Gray II's "Rubies in the Rough").
In order to retain the rich formatting shown on the Practicing Ruby web site, I'm experimenting with a multipart email showing HTML content for those who support it but gracefully degrading to plain text for those without (see CampaignMonitor's "Guide to CSS support in Email re support). It would also make sense to allow users to choose their delivery format in case they wish to receive only the plain text version.
However, to be more representative of actual Practicing Ruby content, could I please have the original Markdown source of a representative article, perhaps one that is already free to the public such as "Unobtrusive Ruby" in Practice" or perhaps one with images such as "Using games to practice domain modeling"?
At the moment, I believe @sandal manually sends announcement emails (please correct me if I'm wrong) so perhaps it would be good to allow for that freeform announcement message to be specified in the mailshot as well (though this could wait).
Here you go: https://raw.github.com/gist/2719212/d6488b4a38dcc79cdf894f00e84c64fb8cdb7763/unobtrusive.md
To prove the concept, I wouldn't bother working through the details of what the final feature would look like. Instead, I would try to come up with a template that would represent the above article very nicely in HTML emails. We will need to verify that it's possible to have a good reading experience in email before we can even consider this feature.
@sandal I just sent a test email to your Gmail account with a prototype for the given article. The message itself is multipart with the raw Markdown source as the plain text component (as Markdown was originally optimised for such purposes) and a styled HTML part for mail clients that support it.
Note the HTML part uses inline styles on every element for its design for maximal support in clients such as Gmail.
This was done by modifying the output with Nokogiri much like you already do in https://github.com/elm-city-craftworks/practicing-ruby-web/blob/master/config/initializers/markdown.rb#L15-23
@mudge: wow, that looks great! Please submit a pull request and I'll test on a larger corpus of articles.
@sandal I just sent you an updated version with some fixes for the inline code blocks and updated the syntax highlighting to match the styles used on the site.
For others that want to review this, you can see the email source at https://gist.github.com/d7d67d00b2e34c899ff3
I'll hook this up with the app and then submit a pull request as soon as possible.
@sandal I've uploaded an EmailHelper that provides a single md_for_email function you can use the test a wider corpus at https://gist.github.com/52441298f6f1f0ed4b43
If you're happy with it then we can hash out how best to incorporate it into the app along with some sort of ArticleMailer.
I need to sort out some issues with mailing, right now we're using Gmail but plan to move to SendGrid. We've got a lot on our plate right now, but I will definitely test this out in the next couple weeks and see how we might be able to integrate it. Please ping me again if I somehow forget.
@mudge: Just so you know, we will probably try to integrate this feature first as a way to send full text comments (that's a feature we have on our short list of things to do anyway), and then from there processing the whole articles should be easy.
Sounds good; let me know if there is anything I can do to help (re-organising the helper into some other form, etc.)
@mudge did you take a look at the inline-style gem? It seems like a good fit for this feature. From reading the documentation it should pull in the styles from our style sheets and inline them automatically. That's much better than having to maintain the styles in two places (in both sass and CSS in the helper)
@jordanbyron Ah no, that'd be great for reducing the duplication (particularly for the syntax highlighting). In my code for the original mock-up, I ended up parsing pygments.css to dynamically add in-line styles but thought it best to make it more explicit in the helper.
The only issue is whether we can rely on the browser HTML styling being compatible with email styling (e.g. font-family should be used over font for compatibility, etc.)
@mudge I'm really sorry that we never properly investigated merging this patch. I'm sure at this point its pretty far out of sync with our app. That's the cost of having very limited development resources on our end :-/
That said, this was a great feature idea, and if and when I get around to building this, I'll come back to this patch and use your work as a guide. Thanks for contributing!
No problem at all, I hope it can still be of use as I would love to receive full articles by email.