Changeset 820


Ignore:
Timestamp:
Jul 6, 2006, 6:57:51 PM (15 years ago)
Author:
nick
Message:

Make it possible for a feed to override the default feed title and self url, and have the feeds do so

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides.pm

    r817 r820  
    579579            my $feed_type = $args{format};
    580580            my ($feed,$content_type) = $self->get_feed_and_content_type($feed_type);
     581            $feed->set_feed_name_and_url_params(
     582                        "Index of $args{type} $args{value}",
     583                        "action=index;index_type=$args{type};index_value=$args{value}"
     584            );
    581585
    582586            # Grab the actual node data out of @nodes
  • trunk/lib/OpenGuides/Feed.pm

    r817 r820  
    4848        $node_url;
    4949      }; 
    50     $self->{site_name}        = $config->site_name;
    51     $self->{default_city}     = $config->default_city     || "";
    52     $self->{default_country}  = $config->default_country  || "";
    53     $self->{site_description} = $config->site_desc        || "";
     50    $self->{site_name}        = $config->site_name . " - Recent Changes";
     51    $self->{default_city}     = $config->default_city      || "";
     52    $self->{default_country}  = $config->default_country   || "";
     53    $self->{site_description} = $config->site_desc         || "";
    5454    $self->{og_version}       = $args{og_version};
     55    $self->{html_equiv_link}  = $self->{config}->script_url . '?action=rc';
    5556
    5657    $self;
     58}
     59
     60=item B<set_feed_name_and_url_params>
     61Overrides the default feed name and default feed http equivalent url.
     62Useful on custom feeds, where the defaults are incorrect.
     63
     64   $feed->set_feed_name_and_url("Search Results", "search=pub");
     65   $feed->build_mini_feed_for_nodes("rss", @search_results);
     66=cut
     67sub set_feed_name_and_url_params {
     68    my ($self, $name, $url) = @_;
     69
     70    unless($url =~ /^http/) {
     71        my $b_url = $self->{config}->script_url;
     72        unless($url =~ /\.cgi\?/) { $b_url .= "?"; }
     73        $b_url .= $url;
     74        $url = $b_url;
     75    }
     76
     77    $self->{site_name} = $self->{config}->{site_name} . " - " . $name;
     78    $self->{html_equiv_link} = $url;
    5779}
    5880
     
    82104    croak "Unknown feed listing: $feed_listing" unless $known_listings{$feed_listing};
    83105
     106
     107    # Tweak any settings, as required by our feed listing
     108    if ($feed_listing eq 'node_all_versions') {
     109        $self->set_feed_name_and_url_params(
     110                    "All versions of ".$args{'name'},
     111                    "action=list_all_versions;id=".$args{'name'}
     112        );
     113    }
     114
     115
    84116    # Fetch the right Wiki::Toolkit::Feeds::Listing instance to use
    85117    my $maker = $self->fetch_maker($feed_type);
     118
    86119
    87120    # Call the appropriate feed listing from it
     
    211244            site_description    => $self->{site_description},
    212245            make_node_url       => $self->{make_node_url},
    213             html_equiv_link     => $self->{config}->script_url . '?action=rc',
    214             atom_link           => $self->{config}->script_url . '?action=rc&format=atom',
     246            html_equiv_link     => $self->{html_equiv_link},
     247            atom_link           => $self->{html_equiv_link} . ";format=atom",
    215248            software_name       => 'OpenGuides',
    216249            software_homepage   => 'http://openguides.org/',
     
    232265            site_description    => $self->{site_description},
    233266            make_node_url       => $self->{make_node_url},
    234             html_equiv_link     => $self->{config}->script_url . '?action=rc',
     267            html_equiv_link     => $self->{html_equiv_link},
    235268            software_name       => 'OpenGuides',
    236269            software_homepage   => 'http://openguides.org/',
  • trunk/lib/OpenGuides/Search.pm

    r818 r820  
    715715                                               og_version => $VERSION,
    716716                                        );
     717        $feed->set_feed_name_and_url_params(
     718                    "Search Results for ".$tt_vars->{search_terms},
     719                    "search.cgi?search=".$tt_vars->{search_terms}
     720        );
     721
    717722        $output  = "Content-Type: ".$feed->default_content_type($format)."\n";
    718723        $output .= $feed->build_mini_feed_for_nodes($format,@nodes);
  • trunk/t/53_show_index.t

    r814 r820  
    7777    my @entries = ($output =~ /(\<\/item\>)/g);
    7878    is( 2, scalar @entries, "Right number of nodes included in rss" );
    79 warn($output);
    8079
    8180    # Test the Atom version
Note: See TracChangeset for help on using the changeset viewer.