Friday, November 27, 2009

SVN::Notify::HTML::ColorDiff modification

We are using SVN to save our works and hooking a post-commit script which one of the function is to send e-mail regarding the changes that had just made. We are using the wonderful SVN::Notify, a perl application to do the job. It already have the functionality to produce a beautifully diff colored HTML email using the SVN::Notify::HTML::ColorDiff module as the handler.

However, since we are using web based Google Apps Gmail interface as our email client, the HTML was not rendered nicely because the CSS is not applied inside the interface. We need to change the CSS to the inline style. And then I found a patch done here. Because it is a direct hack, I want it to be more generic that the user can choose the inline style or not, then I modified a little bit more. I added optional parameter --css-inline to generate CSS style directly inline with the HTML tags. I had submitted the changes to the original author hoping he will include this option in the next revision. Just in case, I also put it here.

Snippets to add the additional parameter:

package SVN::Notify::HTML;

# $Id: HTML.pm 4617 2009-03-19 17:04:53Z david $

use strict;
use HTML::Entities;
use SVN::Notify ();

$SVN::Notify::HTML::VERSION = '2.79';
@SVN::Notify::HTML::ISA = qw(SVN::Notify);

__PACKAGE__->register_attributes(
    linkize   => 'linkize',
    css_url   => 'css-url=s',
    wrap_log  => 'wrap-log',
    css_inline => 'css-inline',
);

You may download the full source below:

1 comments:

Unknown said...

Very nice work!

Thanks, and let's push the community to add this solution as well, as I am sure many others may take advantage of it (Google for one, which is currently sending plain text only for SVN diffs).

:-)