Show
Ignore:
Timestamp:
05/25/06 17:53:56 (6 years ago)
Author:
nick
Message:

Refactoring - shift fetch methods into Listing.pm, to avoid yet more duplication

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Feed/Listing.pm

    r308 r315  
    101101 
    102102 
     103=item B<recent_changes> 
     104 
     105Build an Atom Feed of the recent changes to the Wiki::Toolkit instance, 
     106using any supplied parameters to narrow the results. 
     107 
     108If the argument "also_return_timestamp" is supplied, it will return an 
     109array of the feed, and the feed timestamp. Otherwise it just returns the feed. 
     110 
     111=cut 
     112sub recent_changes 
     113{ 
     114    my ($self, %args) = @_; 
     115 
     116    my @changes = $self->fetch_recently_changed_nodes(%args); 
     117    my $feed_timestamp = $self->feed_timestamp( 
     118                              $self->fetch_newest_for_recently_changed(%args) 
     119    ); 
     120 
     121    my $feed = $self->generate_node_list_feed($feed_timestamp, @changes); 
     122 
     123    if($args{'also_return_timestamp'}) { 
     124        return ($feed,$feed_timestamp); 
     125    } else { 
     126        return $feed; 
     127    } 
     128} 
     129 
     130 
     131=item B<node_all_versions> 
     132 
     133Build an Atom Feed of all the different versions of a given node. 
     134 
     135If the argument "also_return_timestamp" is supplied, it will return an 
     136array of the feed, and the feed timestamp. Otherwise it just returns the feed. 
     137 
     138=cut 
     139sub node_all_versions 
     140{ 
     141    my ($self, %args) = @_; 
     142 
     143    my @all_versions = $self->fetch_node_all_versions(%args); 
     144    my $feed_timestamp = $self->feed_timestamp( $all_versions[0] ); 
     145 
     146    my $feed = $self->generate_node_list_feed($feed_timestamp, @all_versions); 
     147 
     148    if($args{'also_return_timestamp'}) { 
     149        return ($feed,$feed_timestamp); 
     150    } else { 
     151        return $feed; 
     152    } 
     153}  
     154 
     155 
     156 
    103157# The following are methods that any feed renderer must provide 
    104158 
    105 =item B<recent_changes> 
    106 All implementing feed renderers must implement a method to fetch a list 
    107 of recent changes, and render them 
    108 =cut 
    109 sub recent_changes    { die("Not implemented by feed renderer!"); } 
    110 =item B<node_all_versions> 
    111 All implementing feed renderers must implement a method to fetch a list 
    112 of the different versions of a node, and render them 
    113 =cut 
    114 sub node_all_versions { die("Not implemented by feed renderer!"); } 
    115159=item B<feed_timestamp> 
    116160All implementing feed renderers must implement a method to produce a 
    117161feed specific timestamp, based on the supplied node 
    118162=cut 
    119 sub feed_timestamp    { die("Not implemented by feed renderer!"); } 
     163sub feed_timestamp          { die("Not implemented by feed renderer!"); } 
     164=item B<generate_node_list_feed> 
     165All implementing feed renderers must implement a method to produce a 
     166feed from the supplied list of nodes 
     167=cut 
     168sub generate_node_list_feed { die("Not implemented by feed renderer!"); } 
    120169 
    1211701;