Changeset 312

Show
Ignore:
Timestamp:
03/05/06 10:28:33
Author:
cwest
Message:

Default Planet Plugin now has support for members listing, optional

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/assets/plugins/publish-planet/default/template/index.tt

    r311 r312  
    77    <link rel="alternate" type="application/rss+xml" title="RSS: [% feed.title %]" href="smartfeed_all.rss" /> 
    88    <link rel="stylesheet" type="text/css" href="css/screen.css" /> 
     9    [% IF members_list %] 
     10      <link rel="stylesheet" type="text/css" href="css/screen-members-list.css" /> 
     11    [% END %] 
    912    <title>[% feed.title %]</title> 
    1013  </head> 
    1114  <body> 
    1215    <div id="feed-title">[% feed.title %]</div> 
     16 
     17    [% IF members_list %] 
     18      <ul id="members-list"> 
     19        [% FOREACH member IN members %] 
     20          <li class="member"> 
     21            <a class="member-link" href="[% member.link | html %]">[% member.title | html %]</a> 
     22          </li> 
     23        [% END %] 
     24      </ul> 
     25    [% END %] 
    1326 
    1427    [% FOREACH entry IN feed.entries %] 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Planet.pm

    r311 r312  
    2424    } 
    2525 
    26     $self->_sanitize_entries($context, $feed); 
     26    $self->_sanitize_entries( 
     27        $context, 
     28        $feed, 
     29        HTML::Tidy->new, 
     30        HTML::Scrubber->new( 
     31            rules => [ 
     32                style => 0, 
     33                script => 0, 
     34            ], 
     35            default => [ 1, { '*' => 1, style => 0 } ], 
     36        ), 
     37    ); 
    2738 
    2839    $self->_write_index( 
     
    4657 
    4758    $tt->process("$skin/template/index.tt", { 
     59        %{ $self->conf->{template} }, 
    4860        feed  => $feed, 
     61        members => $self->_get_members($context, $feed), 
    4962    }, \my $out) or $context->error($tt->error); 
    5063    $out; 
     
    5265 
    5366sub _sanitize_entries { 
    54     my ($self, $context, $feed) = shift
     67    my ($self, $context, $feed, $tidy, $scrubber) = @_
    5568     
    56     foreach my $entry (@{$feed->{entries}}) { 
    57         $entry->{body} = HTML::Tidy->new->clean($entry->{body}); 
    58         $entry->{body} = HTML::Scrubber->new->scrub($entry->{body}); 
     69    foreach my $entry ($feed->entries) { 
     70        $entry->{body} = $tidy->clean($entry->{body}); 
     71        $entry->{body} = $scrubber->scrub($entry->{body}); 
    5972    } 
    6073} 
     
    7992} 
    8093 
     94sub _get_members { 
     95    my ($self, $context, $feed) = @_; 
     96     
     97    my %members; 
     98    foreach my $entry ($feed->entries) { 
     99        unless ($members{$entry->source->id}) { 
     100            $members{$entry->source->id} = { 
     101                title => $entry->source->title, 
     102                link  => $entry->source->link, 
     103            }; 
     104        } 
     105    } 
     106     
     107    return [ sort { $a->{title} cmp $b->{title} } values %members ]; 
     108} 
     109 
    811101; 
    82111