Ignore:
Timestamp:
May 25, 2006, 6:09:10 PM (15 years ago)
Author:
nick
Message:

Explicitly request the feed timestamp at the same time as the feed, to avoid Wiki::Toolkit having to do the node fetch twice. The feed_timestamp method on OpenGuides::Feed should no longer be used, as it requires another fetch, and only makes sense if you only ever deal with recent changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/Feed.pm

    r790 r791  
    6969    my %known_listings = (
    7070                          'recent_changes' => 1,
     71                          'node_all_versions' => 1,
    7172                         );
    7273                     
     
    8182            return $self->rss_maker->recent_changes(%args);
    8283        }
     84        elsif ($feed_listing eq 'node_all_versions') {
     85            return $self->rss_maker->node_all_versions(%args);
     86        }
    8387    }
    8488    elsif ($feed_type eq 'atom') {
    8589        if ($feed_listing eq 'recent_changes') {
    8690            return $self->atom_maker->recent_changes(%args);
     91        }
     92        elsif ($feed_listing eq 'node_all_versions') {
     93            return $self->atom_maker->node_all_versions(%args);
    8794        }
    8895    }
     
    133140    my ($self, %args) = @_;
    134141
    135     # The timestamp methods in our feeds are equivalent, we might as well
    136     # use the RSS one.
     142    # Call the compatability timestamping method on the RSS Feed.
     143    # People should really just pass in also_return_timestamp to the
     144    #  feed method, and get the timestamp at the same time as their data
    137145    $self->rss_maker->rss_timestamp(%args);
    138146}
     
    162170
    163171    # Ten most recent changes in RSS format.
     172    my %args = ( items     => 10,
     173                 feed_type => 'rss',
     174                 also_return_timestamp => 1 );
     175    my ($feed_output,$feed_timestamp) = $feed->make_feed( %args );
     176
    164177    print "Content-Type: application/rdf+xml\n";
    165     print "Last-Modified: " . $self->feed_timestamp( items => 10 ) . "\n\n";
    166     my %args = ( items     => 10,
    167                  feed_type => 'rss', );
    168     print $feed->make_feed( %args );
     178    print "Last-Modified: " . $feed_timestamp . "\n\n";
     179    print $feed_output;
    169180
    170181=head1 METHODS
     
    196207
    197208    # Ten most recent changes in RSS format.
     209    my %args = ( items     => 10,
     210                 feed_type => 'rss',
     211                 also_return_timestamp => 1 );
     212    my ($feed_output,$feed_timestamp) = $rdf_writer->make_feed( %args );
     213
    198214    print "Content-Type: application/rdf+xml\n";
    199     print "Last-Modified: " . $feed->feed_timestamp( items => 10 ) . "\n\n";
    200     my %args = ( items     => 10,
    201                  feed_type => 'rss', );
     215    print "Last-Modified: " . $feed_timestamp . "\n\n";
     216    print $feed_output;
    202217    print $rdf_writer->make_feed( %args );
     218
    203219
    204220    # All the changes made by bob in the past week, ignoring minor edits, in Atom.
     
    206222    $args{ignore_minor_edits  = 1;
    207223    $args{filter_on_metadata} => { username => "bob" };
    208 
     224    $args{also_return_timestamp} => 1;
     225
     226    my ($feed_output,$feed_timestamp) = $rdf_writer->make_feed( %args );
    209227    print "Content-Type: application/atom+xml\n";
     228    print "Last-Modified: " . $feed_timestamp . "\n\n";
     229    print $feed_output;
     230
     231=item B<feed_timestamp>
     232
     233Instead of calling this, you should instead pass in the 'also_return_timestamp'
     234option. You will then get back the feed timestamp, along with the feed output.
     235
     236This method will be removed in future, and currently will only return
     237meaningful values if your arguments relate to recent changes.
     238
    210239    print "Last-Modified: " . $feed->feed_timestamp( %args ) . "\n\n";
    211     print $feed->make_feed( %args );
    212 
    213 =item B<feed_timestamp>
    214 
    215     print "Last-Modified: " . $feed->feed_timestamp( %args ) . "\n\n";
    216 
    217 Returns the timestamp of the data feed in POSIX::strftime style ("Tue, 29 Feb 2000
    218 12:34:56 GMT"), which is equivalent to the timestamp of the most recent item
    219 in the feed. Takes the same arguments as make_recentchanges_rss(). You will most
    220 likely need this to print a Last-Modified HTTP header so user-agents can determine
    221 whether they need to reload the feed or not.
     240
     241Returns the timestamp of something in POSIX::strftime style ("Tue, 29 Feb 2000
     24212:34:56 GMT"). Takes the same arguments as make_recentchanges_rss().
     243You will most likely need this to print a Last-Modified HTTP header so
     244user-agents can determine whether they need to reload the feed or not.
    222245
    223246=back
Note: See TracChangeset for help on using the changeset viewer.