Author: nick Date: 2006-07-06 18:57:51 +0100 (Thu, 06 Jul 2006) New Revision: 820
Modified: trunk/lib/OpenGuides.pm trunk/lib/OpenGuides/Feed.pm trunk/lib/OpenGuides/Search.pm trunk/t/53_show_index.t Log: Make it possible for a feed to override the default feed title and self url, and have the feeds do so
Modified: trunk/lib/OpenGuides/Feed.pm =================================================================== --- trunk/lib/OpenGuides/Feed.pm 2006-07-06 17:16:53 UTC (rev 819) +++ trunk/lib/OpenGuides/Feed.pm 2006-07-06 17:57:51 UTC (rev 820) @@ -47,15 +47,37 @@
$node_url; }; - $self->{site_name} = $config->site_name; - $self->{default_city} = $config->default_city || ""; - $self->{default_country} = $config->default_country || ""; - $self->{site_description} = $config->site_desc || ""; + $self->{site_name} = $config->site_name . " - Recent Changes"; + $self->{default_city} = $config->default_city || ""; + $self->{default_country} = $config->default_country || ""; + $self->{site_description} = $config->site_desc || ""; $self->{og_version} = $args{og_version}; + $self->{html_equiv_link} = $self->{config}->script_url . '?action=rc';
$self; }
+=item B<set_feed_name_and_url_params> +Overrides the default feed name and default feed http equivalent url. +Useful on custom feeds, where the defaults are incorrect. + + $feed->set_feed_name_and_url("Search Results", "search=pub"); + $feed->build_mini_feed_for_nodes("rss", @search_results); +=cut +sub set_feed_name_and_url_params { + my ($self, $name, $url) = @_; + + unless($url =~ /^http/) { + my $b_url = $self->{config}->script_url; + unless($url =~ /.cgi?/) { $b_url .= "?"; } + $b_url .= $url; + $url = $b_url; + } + + $self->{site_name} = $self->{config}->{site_name} . " - " . $name; + $self->{html_equiv_link} = $url; +} + =item B<make_feed> Produce one of the standard feeds, in the requested format.
@@ -81,9 +103,20 @@ croak "No feed listing specified" unless $feed_listing; croak "Unknown feed listing: $feed_listing" unless $known_listings{$feed_listing};
+ + # Tweak any settings, as required by our feed listing + if ($feed_listing eq 'node_all_versions') { + $self->set_feed_name_and_url_params( + "All versions of ".$args{'name'}, + "action=list_all_versions;id=".$args{'name'} + ); + } + + # Fetch the right Wiki::Toolkit::Feeds::Listing instance to use my $maker = $self->fetch_maker($feed_type);
+ # Call the appropriate feed listing from it if ($feed_listing eq 'recent_changes') { return $maker->recent_changes(%args); @@ -210,8 +243,8 @@ site_url => $self->{config}->script_url, site_description => $self->{site_description}, make_node_url => $self->{make_node_url}, - html_equiv_link => $self->{config}->script_url . '?action=rc', - atom_link => $self->{config}->script_url . '?action=rc&format=atom', + html_equiv_link => $self->{html_equiv_link}, + atom_link => $self->{html_equiv_link} . ";format=atom", software_name => 'OpenGuides', software_homepage => 'http://openguides.org/', software_version => $self->{og_version}, @@ -231,7 +264,7 @@ site_url => $self->{config}->script_url, site_description => $self->{site_description}, make_node_url => $self->{make_node_url}, - html_equiv_link => $self->{config}->script_url . '?action=rc', + html_equiv_link => $self->{html_equiv_link}, software_name => 'OpenGuides', software_homepage => 'http://openguides.org/', software_version => $self->{og_version},
Modified: trunk/lib/OpenGuides/Search.pm =================================================================== --- trunk/lib/OpenGuides/Search.pm 2006-07-06 17:16:53 UTC (rev 819) +++ trunk/lib/OpenGuides/Search.pm 2006-07-06 17:57:51 UTC (rev 820) @@ -714,6 +714,11 @@ config => $self->config, og_version => $VERSION, ); + $feed->set_feed_name_and_url_params( + "Search Results for ".$tt_vars->{search_terms}, + "search.cgi?search=".$tt_vars->{search_terms} + ); + $output = "Content-Type: ".$feed->default_content_type($format)."\n"; $output .= $feed->build_mini_feed_for_nodes($format,@nodes); } else {
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2006-07-06 17:16:53 UTC (rev 819) +++ trunk/lib/OpenGuides.pm 2006-07-06 17:57:51 UTC (rev 820) @@ -578,6 +578,10 @@ # They really wanted a recent changes style rss/atom feed my $feed_type = $args{format}; my ($feed,$content_type) = $self->get_feed_and_content_type($feed_type); + $feed->set_feed_name_and_url_params( + "Index of $args{type} $args{value}", + "action=index;index_type=$args{type};index_value=$args{value}" + );
# Grab the actual node data out of @nodes my @node_data;
Modified: trunk/t/53_show_index.t =================================================================== --- trunk/t/53_show_index.t 2006-07-06 17:16:53 UTC (rev 819) +++ trunk/t/53_show_index.t 2006-07-06 17:57:51 UTC (rev 820) @@ -76,7 +76,6 @@ #like( $output, qr|<title>Category Alpha</title>|, "Right rss title" ); my @entries = ($output =~ /(</item>)/g); is( 2, scalar @entries, "Right number of nodes included in rss" ); -warn($output);
# Test the Atom version $output = eval {
openguides-commits@lists.openguides.org