Changeset 34
- Timestamp:
- 02/06/06 07:42:19
- Files:
-
- trunk/plagger/config.yaml.sample (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm (modified) (3 diffs)
- trunk/plagger/templates/plugins/gmail_notify.tt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/config.yaml.sample
r25 r34 41 41 mailto: miyagawa@example.com 42 42 mailfrom: miyagawa@example.net 43 group_items: 144 43 mailroute: 45 44 via: smtp trunk/plagger/lib/Plagger/Plugin/Publish/Gmail.pm
r33 r34 22 22 my($self, $context, $feed) = @_; 23 23 24 my @items = $feed->entries;25 if ($self->conf->{group_items}) {26 $self->send_email_feed($context, $feed, \@items);27 } else {28 for my $item (@items) {29 $self->send_email_item($context, $feed, $item);30 }31 }32 }33 34 sub send_email_feed {35 my($self, $context, $feed, $items) = @_;36 24 my $subject = $feed->title || '(no-title)'; 37 my $body = join '<hr />', map $self->templatize($context, $feed, $_), @$items; 38 $self->do_send_mail($context, $feed, $subject, $body); 39 } 40 41 sub send_email_item { 42 my($self, $context, $feed, $item) = @_; 43 my $subject = $item->title || '(no-title)'; 44 my $body = $self->templatize($context, $feed, $item); 45 $self->do_send_mail($context, $feed, $subject, $body); 46 } 47 48 sub do_send_mail { 49 my($self, $context, $feed, $subject, $body) = @_; 50 51 $body = $self->htmlize($body); 25 my $body = $self->templatize($context, $feed); 52 26 53 27 my $cfg = $self->conf; … … 66 40 Type => 'multipart/related', 67 41 ); 42 68 43 $msg->attach( 69 44 Type => 'text/html; charset=utf-8', … … 84 59 } 85 60 86 sub htmlize {87 my($self, $body) = @_;88 return <<HTML;89 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">90 <html>91 <head>92 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />93 </head>94 <body>95 $body96 </body>97 </html>98 HTML99 }100 101 61 sub templatize { 102 my($self, $context, $feed , $item) = @_;62 my($self, $context, $feed) = @_; 103 63 my $tt = $context->template(); 104 64 $tt->process('gmail_notify.tt', { 105 65 feed => $feed, 106 item => $item,107 cfg => $self->conf,108 66 }, \my $out) or $context->error($tt->error); 109 67 $out; trunk/plagger/templates/plugins/gmail_notify.tt
r10 r34 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 5 </head> 6 <body> 7 [% FOREACH entry = feed.entries -%] 1 8 <div> 2 9 <div> 3 10 [% IF feed.image %]<a href="[% feed.image.link %]"><img style="border:0" align="right" src="[% feed.image.url | html %]" alt="[% feed.image.title | html %]" /></a>[% END %] 4 [% IF cfg.group_items %]<strong style="font-weight:bold;font-size:1.2em">[% item.title %]</strong><br />[% END %] 5 [% SET link = item.link || item.id -%]11 <strong style="font-weight:bold;font-size:1.2em">[% entry.title %]</strong><br /> 12 [% SET link = entry.link || entry.id -%] 6 13 Link: <a href="[% link | html %]">[% link | html %]</a><br /> 7 [% IF item.author %]by [% item.author | html %][% END %][% IF item.tags.size %] on [% item.tags.join(',') %][% END %]</div>8 [% IF item.body -%]9 [% IF item.body.match('(?i)^<p[ >]') %][% item.body %][% ELSE %]<div style="padding: 1em 0">[% item.body %]</div>[% END %]14 [% IF entry.author %]by [% entry.author | html %][% END %][% IF entry.tags.size %] on [% entry.tags.join(',') %][% END %]</div> 15 [% IF entry.body -%] 16 [% IF entry.body.match('(?i)^<p[ >]') %][% entry.body %][% ELSE %]<div style="padding: 1em 0">[% entry.body %]</div>[% END %] 10 17 [% ELSE %]<br />[% END %] 11 <div style="font-size:0.8em">[% IF item.date %]Posted on [% item.date.format('Mail') %][% END %] | <a href="[% link | html %]">permalink</a> | <a href="[% feed.link | html %]">[% feed.title | html %]</a>[% FOREACH widget = item.widgets %] | [% widget.html(item) %][% END %]<br clear="all" /></div>18 <div style="font-size:0.8em">[% IF entry.date %]Posted on [% entry.date.format('Mail') %][% END %] | <a href="[% link | html %]">permalink</a> | <a href="[% feed.link | html %]">[% feed.title | html %]</a>[% FOREACH widget = entry.widgets %] | [% widget.html(entry) %][% END %]<br clear="all" /></div> 12 19 </div> 20 [% UNLESS loop.last %]<hr />[% END %] 21 [%- END %] 22 </body> 23 </html>
