Author: kake Date: 2012-04-18 12:23:28 +0100 (Wed, 18 Apr 2012) New Revision: 1351
Modified: trunk/lib/OpenGuides.pm trunk/t/53_show_index.t trunk/templates/site_index.tt Log: Move feed_base construction from site_index.tt into OpenGuides.pm so map_index_leaflet.tt can take advantage of it too.
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2012-04-18 11:05:13 UTC (rev 1350) +++ trunk/lib/OpenGuides.pm 2012-04-18 11:23:28 UTC (rev 1351) @@ -974,6 +974,16 @@ $tt_vars{criteria} = @criteria; $tt_vars{not_editable} = 1; } + my $feed_base = $self->config->script_url + . $self->config->script_name . "?action=index"; + foreach my $criterion ( @criteria ) { + if ( $criterion->{type} eq "category" ) { + $feed_base .= ";cat=" . lc( $criterion->{value} ); + } elsif ( $criterion->{type} eq "locale" ) { + $feed_base .= ";loc=" . lc( $criterion->{value} ); + } + } + $tt_vars{feed_base} = $feed_base; }
my @nodes = map {
Modified: trunk/t/53_show_index.t =================================================================== --- trunk/t/53_show_index.t 2012-04-18 11:05:13 UTC (rev 1350) +++ trunk/t/53_show_index.t 2012-04-18 11:23:28 UTC (rev 1351) @@ -11,7 +11,7 @@ plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; }
-plan tests => 40; +plan tests => 42;
# Clear out the database from any previous runs. OpenGuides::Test::refresh_db(); @@ -172,6 +172,7 @@ $output = eval { $guide->show_index( return_output => 1, + loc => "assam", format => "map", ); }; @@ -181,4 +182,12 @@ "...map output gets content-type of text/html" ); unlike( $output, qr|new GMap|, "...no invocation of GMap constructor" ); unlike ( $output, qr|new GPoint|, "...nor GPoint" ); + + # Test links in the header (only implemented for Leaflet). + like( $output, + qr|<link rel="alternate[^>]*action=index;loc=assam;format=rss|, + "RSS link correct in header" ); + like( $output, + qr|<link rel="alternate[^>]*action=index;loc=assam;format=atom|, + "Atom link correct in header" ); }
Modified: trunk/templates/site_index.tt =================================================================== --- trunk/templates/site_index.tt 2012-04-18 11:05:13 UTC (rev 1350) +++ trunk/templates/site_index.tt 2012-04-18 11:23:28 UTC (rev 1351) @@ -1,17 +1,6 @@ -[% my_feed_base = cgi_url _ '?action=index' %] - -[% FOREACH criterion = criteria %] - [% IF criterion.type == 'category' %] - [% my_feed_base = my_feed_base _ ';cat=' _ criterion.value.lower %] - [% ELSIF criterion.type == 'locale' %] - [% my_feed_base = my_feed_base _ ';loc=' _ criterion.value.lower %] - [% END %] -[% END %] - [% IF criteria %] [% INCLUDE header.tt page_title = "Index of $criteria_title - $site_name" - feed_base = my_feed_base %] [% ELSE %] [% INCLUDE header.tt page_title = "Things within $limit of $origin - $site_name" %] @@ -43,14 +32,13 @@ </div>
<div id="site_index_feeds"> - [%# my_feed_base is set at the top of this file %] <p> This list is available as - <a href="[% my_feed_base %];format=rdf">rdf</a>, + <a href="[% feed_base %];format=rdf">rdf</a>, or as a - <a href="[% my_feed_base %];format=rss">rss feed</a>, + <a href="[% feed_base %];format=rss">rss feed</a>, or as an - <a href="[% my_feed_base %];format=atom">atom feed</a>. + <a href="[% feed_base %];format=atom">atom feed</a>. </p> </div>
openguides-commits@lists.openguides.org