Changeset 346

Show
Ignore:
Timestamp:
03/06/06 18:54:44
Author:
miyagawa
Message:
  • Add new plugin Filter::ImageInfo? to fetch width & height from feed images. Fixes #80
  • Plagger::TT plugins
  • Plagger::Util::dumbnail function to resize images using img attributes
  • Add $feed->image to $entry->icon when copied to SmartFeed?
  • Fixed Frepa regular expression since they updated HTML
  • Updated Gmail template to fix big logo issue. Fixes #68
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/assets/plugins/publish-gmail/gmail_notify.tt

    r300 r346  
     1[% USE util = Plagger.Util -%] 
    12<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
    23<html> 
     
    89<div> 
    910<div> 
    10 [% IF entry.icon %]<a href="[% entry.link | html %]"><img style="border:0" align="right" src="[% entry.icon.url | html %]" alt="[% (entry.icon.title || entry.title) | html %]" /></a> 
    11 [% ELSIF feed.image %]<a href="[% feed.link | html %]"><img style="border:0" align="right" src="[% feed.image.url | html %]" alt="[% feed.title | html %]" /></a> 
     11[% IF entry.icon %]<a href="[% entry.link | html %]"><img [% util.dumbnail(entry.icon, width=150, height=60) %] style="border:0" align="right" src="[% entry.icon.url | html %]" alt="[% (entry.icon.title || entry.title) | html %]" /></a> 
     12[% ELSIF feed.image %]<a href="[% feed.link | html %]"><img [% util.dumbnail(feed.image, width=150, height=60) %] style="border:0" align="right" src="[% feed.image.url | html %]" alt="[% feed.title | html %]" /></a> 
    1213[% END -%] 
    1314<strong style="font-weight:bold;font-size:1.2em">[% entry.title %]</strong><br /> 
  • trunk/plagger/lib/Plagger/Plugin/CustomFeed/Frepa.pm

    r235 r346  
    228228 
    229229<a href="([^"]+?/blog/show[^"]+?)">(.*?)</a>.*? 
    230 <a href="([^"]+?)">([^"]+?)</a>.*? 
     230<a href="([^"]+?)" rel="popup">([^"]+?)</a>.*? 
    231231RE 
    232232} 
     
    248248sub top_re { 
    249249    return <<'RE'; 
    250 <a href="http://frepa\.livedoor\.com/.*?/"><img src="(http://img\d+\.ico\.frepa\.livedoor\.com/member_photo/.*?\.(?:jpe?g|JPE?G|gif|GIF|png|PNG))" border="0"></a> 
     250<a href="http://frepa\.livedoor\.com/.*?/" rel="popup"><img src="(http://img\d+\.(?:ico\.frepa\.livedoor\.com/member_photo/|bbs\.frepa\.livedoor\.com/community_board/).*?\.(?:jpe?g|JPE?G|gif|GIF|png|PNG))" border="0"></a> 
    251251</small> 
    252252.*? 
  • trunk/plagger/lib/Plagger/Plugin/SmartFeed.pm

    r309 r346  
    3434    my $feed  = $args->{feed}->clone; 
    3535       $feed->clear_entries; 
    36     $entry->source($feed); # xxx is it only valid for SmartFeed 
     36    $entry->source($feed); # xxx is it only valid for SmartFeed? 
     37    $entry->icon($feed->image) if !$entry->icon && $feed->image; 
    3738 
    3839    $self->{feed}->add_entry($entry); 
  • trunk/plagger/lib/Plagger/Template.pm

    r333 r346  
    2222        ], 
    2323        STASH => Template::Stash::ForceUTF8->new, 
     24        PLUGIN_BASE => [ 'Plagger::TT' ], 
    2425    }); 
    2526} 
  • trunk/plagger/lib/Plagger/Util.pm

    r220 r346  
    22use strict; 
    33our @ISA = qw(Exporter); 
    4 our @EXPORT_OK = qw( strip_html ); 
     4our @EXPORT_OK = qw( strip_html dumbnail ); 
    55 
     6use List::Util qw(min); 
    67use HTML::Entities; 
    78 
     
    1213} 
    1314 
     15sub dumbnail { 
     16    my($img, $p) = @_; 
     17 
     18    if (!$img->{width} && !$img->{height}) { 
     19        return ''; 
     20    } 
     21 
     22    if ($img->{width} <= $p->{width} && $img->{height} <= $p->{height}) { 
     23        return qq(width="$img->{width}" height="$img->{height}"); 
     24    } 
     25 
     26    my $ratio_w = $p->{width}  / $img->{width}; 
     27    my $ratio_h = $p->{height} / $img->{height}; 
     28    my $ratio   = min($ratio_w, $ratio_h); 
     29 
     30    sprintf qq(width="%d" height="%d"), ($img->{width} * $ratio), ($img->{height} * $ratio); 
     31} 
     32 
    14331;