Ignore:
Timestamp:
Jul 6, 2006, 6:57:51 PM (16 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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/',
Note: See TracChangeset for help on using the changeset viewer.