Ignore:
Timestamp:
Apr 5, 2006, 2:26:00 AM (16 years ago)
Author:
Earle Martin
Message:

New module, OpenGuides::Feed: this extracts the stuff formerly in OpenGuides::RDF (as sub make_recentchanges_rss) that was invoking CGI::Wiki::Plugin::RSS::ModWiki, and replaces it with a single make_feed method that can be used for any feed format, including Atom (using the new CGI::Wiki::Plugin::Atom). Changes to OpenGuides.pm and wiki.cgi are to use this new module appropriately.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides.pm

    r752 r753  
    77use CGI::Wiki::Plugin::Locator::Grid;
    88use OpenGuides::CGI;
     9use OpenGuides::Feed;
    910use OpenGuides::Template;
    1011use OpenGuides::Utils;
     
    1415use vars qw( $VERSION );
    1516
    16 $VERSION = '0.52';
     17$VERSION = '0.53';
    1718
    1819=head1 NAME
     
    155156        $tt_vars{"rss_".lc($type)."_url"} =
    156157                           $config->script_name . "?action=rc;format=rss;"
     158                           . lc($type) . "=" . lc(CGI->escape($2));
     159        $tt_vars{"atom_".lc($type)."_url"} =
     160                           $config->script_name . "?action=rc;format=atom;"
    157161                           . lc($type) . "=" . lc(CGI->escape($2));
    158162    }
     
    637641}
    638642
    639 =item B<display_rss>
    640 
    641   # Last ten non-minor edits to Hammersmith pages.
    642   $guide->display_rss(
     643=item B<display_feed>
     644
     645  # Last ten non-minor edits to Hammersmith pages in RSS 1.0 format
     646  $guide->display_feed(
     647                         feed_type          => 'rss',
    643648                         items              => 10,
    644649                         ignore_minor_edits => 1,
     
    646651                     );
    647652
    648   # All edits bob has made to pub pages in the last week.
    649   $guide->display_rss(
    650                          days     => 7,
    651                          username => "bob",
    652                          category => "Pubs",
     653  # All edits bob has made to pub pages in the last week in Atom format
     654  $guide->display_feed(
     655                         feed_type => 'atom',
     656                         days      => 7,
     657                         username  => "bob",
     658                         category  => "Pubs",
    653659                     );
     660
     661C<feed_type> is a mandatory parameter. Supported values at present are
     662"rss" and "atom".
    654663
    655664As with other methods, the C<return_output> parameter can be used to
     
    658667=cut
    659668
    660 sub display_rss {
     669sub display_feed {
    661670    my ($self, %args) = @_;
    662671
     672    my $feed_type = $args{feed_type};
     673    croak "No feed type given" unless $feed_type;
     674   
    663675    my $return_output = $args{return_output} ? 1 : 0;
    664676
     
    673685                       days               => $days,
    674686                       ignore_minor_edits => $ignore_minor_edits,
     687                       feed_type          => $feed_type,
    675688                   );
    676689    my %filter;
     
    682695    }
    683696
    684     my $rdf_writer = OpenGuides::RDF->new(
    685                                              wiki       => $self->wiki,
    686                                              config     => $self->config,
    687                                              og_version => $VERSION,
    688                                          );
    689     my $output = "Content-Type: application/rdf+xml\n";
    690     $output .= "Last-Modified: " . $rdf_writer->rss_timestamp( %criteria ) . "\n\n";
    691     $output .= $rdf_writer->make_recentchanges_rss( %criteria );
     697    my $feed = OpenGuides::Feed->new(
     698                                        wiki       => $self->wiki,
     699                                        config     => $self->config,
     700                                        og_version => $VERSION,
     701                                    );
     702
     703    my $output;
     704   
     705    if ($feed_type eq 'rss') {
     706        $output = "Content-Type: application/rdf+xml\n";
     707    }
     708    elsif ($feed_type eq 'atom') {
     709        $output = "Content-Type: application/atom+xml\n";
     710    }
     711    else {
     712        croak "Unknown feed type given: $feed_type";
     713    }
     714   
     715    $output .= "Last-Modified: " . $feed->feed_timestamp( %criteria ) . "\n\n";
     716
     717    $output .= $feed->make_feed( %criteria );
     718
    692719    return $output if $return_output;
    693720    print $output;
Note: See TracChangeset for help on using the changeset viewer.