Changeset 753
- Timestamp:
- 04/05/06 02:26:00 (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 modified
-
Build.PL (modified) (1 diff)
-
MANIFEST (modified) (1 diff)
-
PREREQUISITES (modified) (1 diff)
-
lib/OpenGuides.pm (modified) (8 diffs)
-
lib/OpenGuides/Feed.pm (added)
-
lib/OpenGuides/RDF.pm (modified) (5 diffs)
-
t/22_rss_modwiki.t (modified) (2 diffs)
-
wiki.cgi (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Build.PL
r733 r753 221 221 'CGI::Wiki' => '0.62', # fixed delete version 222 222 'CGI::Wiki::Formatter::UseMod' => '0.16', # macros 223 'CGI::Wiki::Plugin::Atom' => 0, 223 224 'CGI::Wiki::Plugin::Categoriser' => 0, 224 225 'CGI::Wiki::Plugin::Diff' => '0.08', # earlier buggy -
trunk/MANIFEST
r742 r753 18 18 lib/OpenGuides/CGI.pm 19 19 lib/OpenGuides/Config.pm 20 lib/OpenGuides/Feed.pm 20 21 lib/OpenGuides/RDF.pm 21 22 lib/OpenGuides/Search.pm -
trunk/PREREQUISITES
r743 r753 9 9 CGI::Wiki (version 0.62 or later) 10 10 CGI::Wiki::Formatter::UseMod (version 0.16 or later) 11 CGI::Wiki::Plugin::Atom 11 12 CGI::Wiki::Plugin::Categoriser 12 13 CGI::Wiki::Plugin::Diff (version 0.08 or later) -
trunk/lib/OpenGuides.pm
r752 r753 7 7 use CGI::Wiki::Plugin::Locator::Grid; 8 8 use OpenGuides::CGI; 9 use OpenGuides::Feed; 9 10 use OpenGuides::Template; 10 11 use OpenGuides::Utils; … … 14 15 use vars qw( $VERSION ); 15 16 16 $VERSION = '0.5 2';17 $VERSION = '0.53'; 17 18 18 19 =head1 NAME … … 155 156 $tt_vars{"rss_".lc($type)."_url"} = 156 157 $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;" 157 161 . lc($type) . "=" . lc(CGI->escape($2)); 158 162 } … … 637 641 } 638 642 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', 643 648 items => 10, 644 649 ignore_minor_edits => 1, … … 646 651 ); 647 652 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", 653 659 ); 660 661 C<feed_type> is a mandatory parameter. Supported values at present are 662 "rss" and "atom". 654 663 655 664 As with other methods, the C<return_output> parameter can be used to … … 658 667 =cut 659 668 660 sub display_ rss{669 sub display_feed { 661 670 my ($self, %args) = @_; 662 671 672 my $feed_type = $args{feed_type}; 673 croak "No feed type given" unless $feed_type; 674 663 675 my $return_output = $args{return_output} ? 1 : 0; 664 676 … … 673 685 days => $days, 674 686 ignore_minor_edits => $ignore_minor_edits, 687 feed_type => $feed_type, 675 688 ); 676 689 my %filter; … … 682 695 } 683 696 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 692 719 return $output if $return_output; 693 720 print $output; -
trunk/lib/OpenGuides/RDF.pm
r741 r753 4 4 5 5 use vars qw( $VERSION ); 6 $VERSION = '0.0 8';6 $VERSION = '0.09'; 7 7 8 8 use CGI::Wiki::Plugin::RSS::ModWiki; … … 200 200 } 201 201 202 sub rss_maker {203 my $self = shift;204 205 # OAOO, please.206 unless ($self->{rss_maker}) {207 $self->{rss_maker} = CGI::Wiki::Plugin::RSS::ModWiki->new(208 wiki => $self->{wiki},209 site_name => $self->{site_name},210 site_url => $self->{config}->script_url,211 site_description => $self->{site_description},212 make_node_url => $self->{make_node_url},213 recent_changes_link => $self->{config}->script_url . '?action=rc',214 software_name => 'OpenGuides',215 software_homepage => 'http://openguides.org/',216 software_version => $self->{og_version},217 );218 }219 220 $self->{rss_maker};221 }222 223 sub make_recentchanges_rss {224 my ($self, %args) = @_;225 226 $self->rss_maker->recent_changes(%args);227 }228 229 sub rss_timestamp {230 my ($self, %args) = @_;231 232 $self->rss_maker->rss_timestamp(%args);233 }234 235 202 =head1 NAME 236 203 … … 258 225 print "Content-Type: application/rdf+xml\n\n"; 259 226 print $rdf_writer->emit_rdfxml( node => "Masala Zone, N1 0NU" ); 260 261 # Ten most recent changes.262 print "Content-Type: application/rdf+xml\n";263 print "Last-Modified: " . $self->rss_timestamp( items => 10 ) . "\n\n";264 print $rdf_writer->make_recentchanges_rss( items => 10 );265 227 266 228 =head1 METHODS … … 315 277 =back 316 278 317 =item B<rss_maker> 318 319 Returns a raw L<CGI::Wiki::Plugin::RSS::ModWiki> object created with the values you 320 invoked this module with. 321 322 =item B<make_recentchanges_rss> 323 324 # Ten most recent changes. 325 print "Content-Type: application/rdf+xml\n"; 326 print "Last-Modified: " . $rdf_writer->rss_timestamp( items => 10 ) . "\n\n"; 327 print $rdf_writer->make_recentchanges_rss( items => 10 ); 328 329 # All the changes made by bob in the past week, ignoring minor edits. 330 331 my %args = ( 332 days => 7, 333 ignore_minor_edits => 1, 334 filter_on_metadata => { username => "bob" }, 335 ); 336 337 print "Content-Type: application/rdf+xml\n"; 338 print "Last-Modified: " . $rdf_writer->rss_timestamp( %args ) . "\n\n"; 339 print $rdf_writer->make_recentchanges_rss( %args ); 340 341 =item B<rss_timestamp> 342 343 print "Last-Modified: " . $rdf_writer->rss_timestamp( %args ) . "\n\n"; 344 345 Returns the timestamp of the RSS feed in POSIX::strftime style ("Tue, 29 Feb 2000 346 12:34:56 GMT"), which is equivalent to the timestamp of the most recent item 347 in the feed. Takes the same arguments as make_recentchanges_rss(). You will most 348 likely need this to print a Last-Modified HTTP header so user-agents can determine 349 whether they need to reload the feed or not. 279 =head1 SEE ALSO 280 281 =over 4 282 283 =item * L<CGI::Wiki> 284 285 =item * L<http://openguides.org/> 286 287 =item * L<http://chefmoz.org/> 350 288 351 289 =back 352 290 353 =head1 SEE ALSO354 355 =over 4356 357 =item * L<CGI::Wiki>358 359 =item * L<http://openguides.org/>360 361 =item * L<http://chefmoz.org/>362 363 =back364 365 291 =head1 AUTHOR 366 292 … … 369 295 =head1 COPYRIGHT 370 296 371 Copyright (C) 2003-200 5The OpenGuides Project. All Rights Reserved.297 Copyright (C) 2003-2006 The OpenGuides Project. All Rights Reserved. 372 298 373 299 This module is free software; you can redistribute it and/or modify it -
trunk/t/22_rss_modwiki.t
r587 r753 43 43 my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 44 44 45 my $ rdf_writer = OpenGuides::RDF->new( wiki => $wiki,46 config => $config );45 my $feed = OpenGuides::Feed->new( wiki => $wiki, 46 config => $config ); 47 47 48 my $rss = eval { $ rdf_writer->make_recentchanges_rss; };49 is( $@, "", "->make_ recentchanges_rss doesn't croak" );48 my $rss = eval { $feed->make_feed(feed_type => 'rss'); }; 49 is( $@, "", "->make_feed for rss doesn't croak" ); 50 50 51 51 # Now write some data, first a minor edit then a non-minor one. … … 98 98 99 99 # Check that the minor edits can be filtered out. 100 $output = $guide->display_rss( 100 $output = $guide->display_feed( 101 feed_type => "rss", 101 102 items => 5, 102 103 username => "bob", -
trunk/wiki.cgi
r748 r753 5 5 6 6 use vars qw( $VERSION ); 7 $VERSION = '0.5 2';7 $VERSION = '0.53'; 8 8 9 9 use CGI qw/:standard/; … … 104 104 qw( feed items days ignore_minor_edits username 105 105 category locale ); 106 $guide->display_rss( %args ); 106 $args{feed_type} = 'rss'; 107 $guide->display_feed( %args ); 107 108 } elsif ( $feed eq "chef_dan" ) { 108 109 display_node_rdf( node => $node ); … … 110 111 croak "Unknown RSS feed type '$feed'"; 111 112 } 113 } elsif ($format && $format eq 'atom') { 114 my %args = map { $_ => ( $q->param($_) || "" ) } 115 qw( feed items days ignore_minor_edits username 116 category locale ); 117 $args{feed_type} = 'atom'; 118 $guide->display_feed( %args ); 112 119 } else { 113 120 $guide->display_node( id => 'RecentChanges' );
