| 1 | package SVN::Notify::Filter::Trac; | ||||||||||
| 2 | |||||||||||
| 3 | 39 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 39 | ▶ | use Text::Trac; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 39 | ▶ | use SVN::Notify; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 39 | $SVN::Notify::Filter::Trac::VERSION = '2.86'; | |||||||||
| 8 | |||||||||||
| 9 | =begin comment | ||||||||||
| 10 | |||||||||||
| 11 | Fake out Test::Pod::Coverage. | ||||||||||
| 12 | |||||||||||
| 13 | =head3 log_message | ||||||||||
| 14 | |||||||||||
| 15 | =head3 css | ||||||||||
| 16 | |||||||||||
| 17 | =end comment | ||||||||||
| 18 | |||||||||||
| 19 | =cut | ||||||||||
| 20 | |||||||||||
| 21 | 39 | SVN::Notify->register_attributes( trac_url => 'trac-url=s' ); | |||||||||
| 22 | |||||||||||
| 23 | sub log_message { | ||||||||||
| 24 | 63 | ▶ | my ($notify, $lines) = @_; | ||||||||
|
Subroutine
log_message: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 25 | 63 | ▶ | return $lines unless $notify->content_type eq 'text/html'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 31 | my $trac = Text::Trac->new( trac_url => $notify->trac_url ); | |||||||||
| 27 | 31 | my $msg = join $/, @{ $lines }; | |||||||||
| 28 | 31 | $msg =~ s/^\n+//g; | |||||||||
| 29 | 31 | $msg =~ s/\n+$//g; | |||||||||
| 30 | 31 | return [ $trac->parse( $msg ) ]; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | sub css { | ||||||||||
| 34 | 31 | ▶ | my ($notify, $css)= @_; | ||||||||
|
Subroutine
css: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 35 | 31 | ▶ | return $css unless $notify->content_type eq 'text/html'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 31 | push @$css, ( | |||||||||
| 37 | qq(#logmsg blockquote.citation { padding: 0; border: 0; border-left: solid 2px #b44; padding-left: .75em; background: transparent; }\n), | ||||||||||
| 38 | qq(#logmsg blockquote.citation .citation { border-color: #4b4; }\n), | ||||||||||
| 39 | qq(#logmsg blockquote.citation .citation .citation { border-color: #44b; }\n), | ||||||||||
| 40 | qq(#logmsg blockquote.citation .citation .citation .citation { border-color: #c55; }\n), | ||||||||||
| 41 | qq(#logmsg ol.loweralpha { list-style-type: lower-alpha; }\n), | ||||||||||
| 42 | qq(#logmsg ol.upperalpha { list-style-type: upper-alpha; }\n), | ||||||||||
| 43 | qq(#logmsg ol.lowerroman { list-style-type: lower-roman; }\n), | ||||||||||
| 44 | qq(#logmsg ol.upperroman { list-style-type: upper-roman; }\n), | ||||||||||
| 45 | qq(#logmsg ol.arabic { list-style-type: decimal; }\n), | ||||||||||
| 46 | ); | ||||||||||
| 47 | 31 | return $css; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 39 | 1; | |||||||||
| 51 | |||||||||||
| 52 | =head1 Name | ||||||||||
| 53 | |||||||||||
| 54 | SVN::Notify::Filter::Trac - Filter SVN::Notify output in Trac format | ||||||||||
| 55 | |||||||||||
| 56 | =head1 Synopsis | ||||||||||
| 57 | |||||||||||
| 58 | Use F<svnnotify> in F<post-commit>: | ||||||||||
| 59 | |||||||||||
| 60 | svnnotify --p "$1" --r "$2" --to you@example.com --handler HTML \ | ||||||||||
| 61 | --filter Trac --trac-url http://trac.example.com | ||||||||||
| 62 | |||||||||||
| 63 | Use the class in a custom script: | ||||||||||
| 64 | |||||||||||
| 65 | use SVN::Notify; | ||||||||||
| 66 | |||||||||||
| 67 | my $notifier = SVN::Notify->new( | ||||||||||
| 68 | repos_path => $path, | ||||||||||
| 69 | revision => $rev, | ||||||||||
| 70 | to => 'you@example.com', | ||||||||||
| 71 | handler => 'HTML::ColorDiff', | ||||||||||
| 72 | filters => [ 'Trac' ], | ||||||||||
| 73 | trac_url => 'http://trac.example.com/', | ||||||||||
| 74 | ); | ||||||||||
| 75 | $notifier->prepare; | ||||||||||
| 76 | $notifier->execute; | ||||||||||
| 77 | |||||||||||
| 78 | =head1 Description | ||||||||||
| 79 | |||||||||||
| 80 | This module filters SVN::Notify log message output from Trac markup into HTML. | ||||||||||
| 81 | Essentially, this means that if you write your commit log messages using Trac | ||||||||||
| 82 | wiki markup and like to use L<SVN::Notify::HTML|SVN::Notify::HTML> or | ||||||||||
| 83 | L<SVN::Notify::HTML::ColorDiff|SVN::Notify::HTML::ColorDiff> to format your | ||||||||||
| 84 | commit notifications, you can use this filter to convert the Trac formatting | ||||||||||
| 85 | in the log message to HTML. | ||||||||||
| 86 | |||||||||||
| 87 | If you specify an extra argument, C<trac_url> (or the C<--trac-url> parameter | ||||||||||
| 88 | to C<svnnotify>), it will be used to generate Trac links for revision numbers | ||||||||||
| 89 | and the like in your log messages. | ||||||||||
| 90 | |||||||||||
| 91 | =head1 See Also | ||||||||||
| 92 | |||||||||||
| 93 | =over | ||||||||||
| 94 | |||||||||||
| 95 | =item L<SVN::Notify|SVN::Notify> | ||||||||||
| 96 | |||||||||||
| 97 | =item L<svnnotify|svnnotify> | ||||||||||
| 98 | |||||||||||
| 99 | =back | ||||||||||
| 100 | |||||||||||
| 101 | =head1 Author | ||||||||||
| 102 | |||||||||||
| 103 | David E. Wheeler <david@justatheory.com> | ||||||||||
| 104 | |||||||||||
| 105 | =head1 Copyright and License | ||||||||||
| 106 | |||||||||||
| 107 | Copyright (c) 2008-2016 David E. Wheeler. Some Rights Reserved. | ||||||||||
| 108 | |||||||||||
| 109 | This module is free software; you can redistribute it and/or modify it under | ||||||||||
| 110 | the same terms as Perl itself. | ||||||||||
| 111 | |||||||||||
| 112 | =cut | ||||||||||