--- no_pager/index.cgi 2006/08/16 23:37:51 18
+++ no_pager/index.cgi 2006/08/17 19:18:26 23
@@ -25,7 +25,12 @@
my $json;
-#warn "config = ", dump($config);
+sub debug {
+ my ($text,$var) = @_;
+ print "
' .
@@ -70,6 +90,7 @@
$cond->set_phrase( $search );
$cond->set_max( $on_page );
$cond->set_skip( $skip );
+ $cond->set_order( $p->{sort} ) if ($p->{sort});
my $nres = $node->search($cond, ( $config->{estraier}->{depth} || 0 ) );
@@ -115,20 +136,26 @@
return $text;
}
+ my @template;
+ open(my $t, 'result.html') || die "result.html: $!";
+ while(<$t>) {
+ push @template, $_;
+ }
+ close($t);
+
# for each document in results
for my $i ( 0 ... $nres->doc_num - 1 ) {
my $rdoc = $nres->get_doc($i);
-
- $out .= '
' .
- '
' . $rdoc->attr('@title') . '
' .
- '
' . html_snippet( $rdoc->snippet ) . '
' .
- '
' . attr_regex( $rdoc, 'source' ) . '
';
my $uri = attr_regex( $rdoc, '@uri' );
- $out .=
- qq{
$uri } .
- attr_regex( $rdoc, '@mdate' ) .
- ' [' . ( $skip + $i + 1 ) . ']';
+ my $nr = $skip + $i + 1;
+
+ map {
+ my $l = $_;
+ $l =~ s/<%(.+?)%>/eval "$1"/ge;
+ $out .= $l;
+ } @template;
+
}
} else {
@@ -136,10 +163,10 @@
}
if ($v->{page} == $v->{max_page}) {
- $out .= next_page('
All results shown');
+ $out .= next_page('
All results shown');
} else {
$out .= next_page(
- '
Loading results...',
+ '
Loading results...',
'If you are using the scroll bar, release the mouse to see more results.'
);
}
@@ -151,16 +178,18 @@
if ($q->path_info() eq '/snippet') {
print get_results(
- search => $q->param('search'),
- page => $q->param('page'),
+ search => $q->param('search') || '',
+ page => $q->param('page') || 0,
+ sort => $q->param('sort') || undef,
);
} else {
my $get_results = get_results(
- search => $q->param('search'),
+ search => $q->param('search') || '',
page => 1,
+ sort => $q->param('sort') || undef,
);
my $f = $q->path_info;
@@ -172,6 +201,6 @@
s/<%(.+?)%>/eval "$1"/ge;
print;
}
- close($f);
+ close($s);
}