Changeset 295


Ignore:
Timestamp:
May 18, 2006, 4:58:46 PM (14 years ago)
Author:
nick
Message:

Move some common change fetching code into the parent

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

Legend:

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

    r294 r295  
    5252sub recent_changes
    5353{
    54   my ($self, %args) = @_;
    55 
    56   my $wiki = $self->{wiki};
    57 
    58   my %criteria = (
    59                    ignore_case => 1,
    60                  );
    61 
    62   # If we're not passed any parameters to limit the items returned, default to 15.
    63   $args{days} ? $criteria{days}           = $args{days}
    64               : $criteria{last_n_changes} = $args{items} || 15;
    65  
    66   $criteria{metadata_wasnt} = { major_change => 0 }     if $args{ignore_minor_edits};
    67   $criteria{metadata_was}   = $args{filter_on_metadata} if $args{filter_on_metadata};
    68 
    69   my @changes = $wiki->list_recent_changes(%criteria);
    70   my $atom_timestamp = $self->feed_timestamp(%args);
    71 
    72   return $self->generate_node_list_feed($atom_timestamp, @changes);
     54    my ($self, %args) = @_;
     55
     56    my @changes = $self->fetch_recently_changed_nodes(%args);
     57    my $atom_timestamp = $self->feed_timestamp(%args);
     58
     59    return $self->generate_node_list_feed($atom_timestamp, @changes);
    7360}
    7461
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Feed/Listing.pm

    r292 r295  
    1212=cut
    1313
     14
     15=item B<fetch_recently_changed_nodes>
     16
     17Based on the supplied criteria, fetch a list of the recently changed nodes
     18
     19=cut
     20sub fetch_recently_changed_nodes {
     21    my ($self, %args) = @_;
     22
     23    my $wiki = $self->{wiki};
     24
     25    my %criteria = (
     26                   ignore_case => 1,
     27                   );
     28
     29    # If we're not passed any parameters to limit the items returned,
     30    #  default to 15.
     31    $args{days} ? $criteria{days}           = $args{days}
     32                : $criteria{last_n_changes} = $args{items} || 15;
     33 
     34    $criteria{metadata_wasnt} = { major_change => 0 }     if $args{ignore_minor_edits};
     35    $criteria{metadata_was}   = $args{filter_on_metadata} if $args{filter_on_metadata};
     36
     37    my @changes = $wiki->list_recent_changes(%criteria);
     38
     39    return @changes;
     40}
     41
     42=item B<fetch_oldest_for_recently_changed>
     43
     44Based on the supplied criteria (but not using all of those used by
     45B<fetch_recently_changed_nodes>), find the oldest node from the recently
     46changed nodes set. Normally used for dating the whole of a Feed.
     47
     48=cut
     49
    14501;
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Feed/RSS.pm

    r294 r295  
    6161  my ($self, %args) = @_;
    6262
    63   my $wiki = $self->{wiki};
    64 
    65   # If we're not passed any parameters to limit the items returned, default to 15.
    66 
    67   my %criteria = (
    68                    ignore_case => 1,
    69                  );
    70 
    71   if ($args{days})
    72   {
    73     $criteria{days} = $args{days};
    74   }
    75   else
    76   {
    77     $criteria{last_n_changes} = $args{items} || 15;
    78   }
    79  
    80   if ($args{ignore_minor_edits})
    81   {
    82     $criteria{metadata_wasnt} = { major_change => 0 };
    83   }
    84  
    85   if ($args{filter_on_metadata})
    86   {
    87     $criteria{metadata_was} = $args{filter_on_metadata};
    88   }
    89 
    90   my @changes = $wiki->list_recent_changes(%criteria);
     63  my @changes = $self->fetch_recently_changed_nodes(%args);
    9164  my $rss_timestamp = $self->rss_timestamp(%args);
    9265
Note: See TracChangeset for help on using the changeset viewer.