Changeset 315


Ignore:
Timestamp:
May 25, 2006, 5:53:56 PM (14 years ago)
Author:
nick
Message:

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

Location:
wiki-toolkit/trunk/lib/Wiki/Toolkit/Feed
Files:
3 edited

Legend:

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

    r314 r315  
    4949  $self;
    5050}
    51 
    52 =item B<recent_changes>
    53 
    54 Build an Atom Feed of the recent changes to the Wiki::Toolkit instance,
    55 using any supplied parameters to narrow the results.
    56 
    57 If the argument "also_return_timestamp" is supplied, it will return an
    58 array of the feed, and the feed timestamp. Otherwise it just returns the feed.
    59 
    60 =cut
    61 sub recent_changes
    62 {
    63     my ($self, %args) = @_;
    64 
    65     my @changes = $self->fetch_recently_changed_nodes(%args);
    66     my $atom_timestamp = $self->feed_timestamp(
    67                               $self->fetch_newest_for_recently_changed(%args)
    68     );
    69 
    70     my $feed = $self->generate_node_list_feed($atom_timestamp, @changes);
    71 
    72     if($args{'also_return_timestamp'}) {
    73         return ($feed,$feed_timestamp);
    74     } else {
    75         return $feed;
    76     }
    77 }
    78 
    79 
    80 =item B<node_all_versions>
    81 
    82 Build an Atom Feed of all the different versions of a given node.
    83 
    84 If the argument "also_return_timestamp" is supplied, it will return an
    85 array of the feed, and the feed timestamp. Otherwise it just returns the feed.
    86 
    87 =cut
    88 sub node_all_versions
    89 {
    90     my ($self, %args) = @_;
    91 
    92     my @all_versions = $self->fetch_node_all_versions(%args);
    93     my $feed_timestamp = $self->feed_timestamp( $all_versions[0] );
    94 
    95     my $feed = $self->generate_node_list_feed($feed_timestamp, @all_versions);
    96 
    97     if($args{'also_return_timestamp'}) {
    98         return ($feed,$feed_timestamp);
    99     } else {
    100         return $feed;
    101     }
    102 }
    103 
    10451
    10552=item <generate_node_list_feed>
  • 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;
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Feed/RSS.pm

    r314 r315  
    4949
    5050    $self;
    51 }
    52 
    53 =item B<recent_changes>
    54 
    55 Build an RSS Feed of the recent changes to the Wiki::Toolkit instance,
    56 using any supplied parameters to narrow the results.
    57 
    58 If the argument "also_return_timestamp" is supplied, it will return an
    59 array of the feed, and the feed timestamp. Otherwise it just returns the feed.
    60 
    61 =cut
    62 sub recent_changes
    63 {
    64     my ($self, %args) = @_;
    65 
    66     my @changes = $self->fetch_recently_changed_nodes(%args);
    67     my $feed_timestamp = $self->feed_timestamp(
    68                               $self->fetch_newest_for_recently_changed(%args)
    69     );
    70 
    71     my $feed = $self->generate_node_list_feed($feed_timestamp, @changes);
    72 
    73     if($args{'also_return_timestamp'}) {
    74         return ($feed,$feed_timestamp);
    75     } else {
    76         return $feed;
    77     }
    78 }
    79 
    80 
    81 =item B<node_all_versions>
    82 
    83 Build an RSS Feed of all the different versions of a given node.
    84 
    85 If the argument "also_return_timestamp" is supplied, it will return an
    86 array of the feed, and the feed timestamp. Otherwise it just returns the feed.
    87 
    88 =cut
    89 sub node_all_versions
    90 {
    91     my ($self, %args) = @_;
    92 
    93     my @all_versions = $self->fetch_node_all_versions(%args);
    94     my $feed_timestamp = $self->feed_timestamp( $all_versions[0] );
    95 
    96     my $feed = $self->generate_node_list_feed($feed_timestamp, @all_versions);
    97 
    98     if($args{'also_return_timestamp'}) {
    99         return ($feed,$feed_timestamp);
    100     } else {
    101         return $feed;
    102     }
    10351}
    10452
Note: See TracChangeset for help on using the changeset viewer.