Author: dom
Date: 2009-02-21 18:19:00 +0000 (Sat, 21 Feb 2009)
New Revision: 1255
Modified:
trunk/Changes
trunk/t/34_search_paging.t
trunk/templates/search.tt
Log:
Correctly paginate search when geodata is supplied (fixes #267) - thanks bob
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2008-12-21 18:30:45 UTC (rev 1254)
+++ trunk/Changes 2009-02-21 18:19:00 UTC (rev 1255)
@@ -24,6 +24,7 @@
generating the page content (#228)
Work around Wiki::Toolkit bug #41 by displaying minor edits by
default
+ Correctly paginate search when geodata is supplied (#267)
0.63 16 August 2008
Major overhaul of RDF output.
Modified: trunk/t/34_search_paging.t
===================================================================
--- trunk/t/34_search_paging.t 2008-12-21 18:30:45 UTC (rev 1254)
+++ trunk/t/34_search_paging.t 2009-02-21 18:19:00 UTC (rev 1255)
@@ -16,7 +16,7 @@
plan skip_all => "Plucene not installed";
}
-plan tests => 9;
+plan tests => 18;
# Clear out the database from any previous runs.
unlink "t/node.db";
@@ -34,7 +34,7 @@
skip "Geography::NationalGrid::GB not installed", 3 if $@;
$config->geo_handler( 1 );
- foreach my $i ( 1 .. 30 ) {
+ foreach my $i ( 1 .. 50 ) {
OpenGuides::Test->write_data(
guide => $guide,
node => "Crabtree Tavern $i",
@@ -50,6 +50,7 @@
os_dist => 1500,
os_x => 523500,
os_y => 177500,
+ next => 21,
},
);
like( $output, qr/search.cgi\?.*os_x=523500.*Next.*results/s,
@@ -58,6 +59,12 @@
"os_y retained in next page link" );
like( $output, qr/search.cgi\?.*os_dist=1500.*Next.*results/s,
"os_dist retained in next page link" );
+ like( $output, qr/search.cgi\?.*os_x=523500.*Previous.*results/s,
+ "os_x retained in previous page link" );
+ like( $output, qr/search.cgi\?.*os_y=177500.*Previous.*results/s,
+ "os_y retained in previous page link" );
+ like( $output, qr/search.cgi\?.*os_dist=1500.*Previous.*results/s,
+ "os_dist retained in previous page link" );
}
# Test with OSIE co-ords.
@@ -70,7 +77,7 @@
$config->geo_handler( 2 );
my $search = OpenGuides::Search->new( config => $config );
- foreach my $i ( 1 .. 30 ) {
+ foreach my $i ( 1 .. 50 ) {
OpenGuides::Test->write_data(
guide => $guide,
node => "I Made This Place Up $i",
@@ -85,6 +92,7 @@
osie_dist => 1500,
osie_x => 100000,
osie_y => 200000,
+ next => 21,
},
);
like( $output, qr/search.cgi\?.*osie_x=100000.*Next.*results/s,
@@ -93,6 +101,12 @@
"osie_y retained in next page link" );
like( $output, qr/search.cgi\?.*osie_dist=1500.*Next.*results/s,
"osie_dist retained in next page link" );
+ like( $output, qr/search.cgi\?.*osie_x=100000.*Previous.*results/s,
+ "osie_x retained in previous page link" );
+ like( $output, qr/search.cgi\?.*osie_y=200000.*Previous.*results/s,
+ "osie_y retained in previous page link" );
+ like( $output, qr/search.cgi\?.*osie_dist=1500.*Previous.*results/s,
+ "osie_dist retained in previous page link" );
}
# Test with UTM.
@@ -105,7 +119,7 @@
$config->geo_handler( 3 );
my $search = OpenGuides::Search->new( config => $config );
- foreach my $i ( 1 .. 30 ) {
+ foreach my $i ( 1 .. 50 ) {
OpenGuides::Test->write_data(
guide => $guide,
node => "London Aquarium $i",
@@ -120,6 +134,7 @@
latlong_dist => 1500,
latitude => 51.5,
longitude => -0.12,
+ next => 21,
},
);
like( $output, qr/search.cgi\?.*latitude=51.5.*Next.*results/s,
@@ -128,4 +143,10 @@
"longitude retained in next page link" );
like( $output, qr/search.cgi\?.*latlong_dist=1500.*Next.*results/s,
"latlong_dist retained in next page link" );
+ like( $output, qr/search.cgi\?.*latitude=51.5.*Previous.*results/s,
+ "latitude retained in previous page link" );
+ like( $output, qr/search.cgi\?.*longitude=-0.12.*Previous.*results/s,
+ "longitude retained in previous page link" );
+ like( $output, qr/search.cgi\?.*latlong_dist=1500.*Previous.*results/s,
+ "latlong_dist retained in previous page link" );
}
Modified: trunk/templates/search.tt
===================================================================
--- trunk/templates/search.tt 2008-12-21 18:30:45 UTC (rev 1254)
+++ trunk/templates/search.tt 2009-02-21 18:19:00 UTC (rev 1255)
@@ -80,7 +80,7 @@
<p>
Matches [% first_num %] - [% last_num %] of [% total_num %].
[% IF (first_num > 20) %]
- <a href="search.cgi?search=[% search_terms %];next=[% first_num - 21 %]">Previous 20 results</a>
+ <a href="search.cgi?search=[% search_terms %];[% dist_field %]=[% dist %];[% coord_field_1 %]=[% coord_field_1_value %];[% coord_field_2 %]=[% coord_field_2_value %];next=[% first_num - 21 %]">Previous 20 results</a>
[% END %]
[% IF ((first_num > 20) and next_page_startpos) %]
/