25 |
|
|
26 |
my $json; |
my $json; |
27 |
|
|
28 |
#warn "config = ", dump($config); |
sub debug { |
29 |
|
my ($text,$var) = @_; |
30 |
|
print "<pre>$text = ", dump($var), "</pre>"; |
31 |
|
} |
32 |
|
|
33 |
|
#debug('config', $config); |
34 |
|
|
35 |
sub json { |
sub json { |
36 |
return |
return |
39 |
'</textarea>'; |
'</textarea>'; |
40 |
} |
} |
41 |
|
|
42 |
|
sub sort_order { |
43 |
|
my $out; |
44 |
|
|
45 |
|
my $sort = $q->param('sort'); |
46 |
|
|
47 |
|
$out .= '<select name="sort" id="sort">'; |
48 |
|
|
49 |
|
foreach my $s (@{ $config->{estraier}->{order} }) { |
50 |
|
my ($text,$value) = %{$s}; |
51 |
|
$out .= qq{<option value="$value"} . |
52 |
|
( $sort eq $value ? ' selected' : '' ) . |
53 |
|
qq{>$text</option>}; |
54 |
|
} |
55 |
|
|
56 |
|
$out .= '</select>'; |
57 |
|
} |
58 |
|
|
59 |
sub get_results { |
sub get_results { |
60 |
my $p = {@_}; |
my $p = {@_}; |
61 |
|
|
62 |
my ($search,$page) = ( $p->{search} || '', $p->{page} || 0); |
my ($search,$page) = ( $p->{search} , $p->{page}); |
|
|
|
|
warn "get_results( $search , $page )\n"; |
|
63 |
|
|
64 |
sub next_page { |
sub next_page { |
65 |
return '<div id="next_page">' . |
return '<div id="next_page">' . |
90 |
$cond->set_phrase( $search ); |
$cond->set_phrase( $search ); |
91 |
$cond->set_max( $on_page ); |
$cond->set_max( $on_page ); |
92 |
$cond->set_skip( $skip ); |
$cond->set_skip( $skip ); |
93 |
|
$cond->set_order( $p->{sort} ) if ($p->{sort}); |
94 |
|
|
95 |
my $nres = $node->search($cond, ( $config->{estraier}->{depth} || 0 ) ); |
my $nres = $node->search($cond, ( $config->{estraier}->{depth} || 0 ) ); |
96 |
|
|
142 |
my $rdoc = $nres->get_doc($i); |
my $rdoc = $nres->get_doc($i); |
143 |
|
|
144 |
$out .= '<div class="item">' . |
$out .= '<div class="item">' . |
145 |
'<h1>' . $rdoc->attr('@title') . '</h1>' . |
'<h1>' . attr_regex( $rdoc, '@title' ) . '</h1>' . |
146 |
'<p>' . html_snippet( $rdoc->snippet ) . '</p>' . |
'<p>' . html_snippet( $rdoc->snippet ) . '</p>' . |
147 |
'<h2>' . attr_regex( $rdoc, 'source' ) . '</h2>'; |
'<strong>' . attr_regex( $rdoc, 'source' ) . '</strong>' . |
148 |
|
' [' . attr_regex( $rdoc, '@size' ) . ' bytes]<br/>'; |
149 |
my $uri = attr_regex( $rdoc, '@uri' ); |
my $uri = attr_regex( $rdoc, '@uri' ); |
150 |
$out .= |
$out .= |
151 |
qq{<a href="$uri"><tt>$uri</tt></a> } . |
qq{<a href="$uri"><tt>$uri</tt></a> } . |
175 |
print get_results( |
print get_results( |
176 |
search => $q->param('search') || '', |
search => $q->param('search') || '', |
177 |
page => $q->param('page') || 0, |
page => $q->param('page') || 0, |
178 |
|
sort => $q->param('sort') || undef, |
179 |
); |
); |
180 |
|
|
181 |
|
|
184 |
my $get_results = get_results( |
my $get_results = get_results( |
185 |
search => $q->param('search') || '', |
search => $q->param('search') || '', |
186 |
page => 1, |
page => 1, |
187 |
|
sort => $q->param('sort') || undef, |
188 |
); |
); |
189 |
|
|
190 |
my $f = $q->path_info; |
my $f = $q->path_info; |