1 |
<%args> |
<%args> |
2 |
$item_fragment => 'result' |
$q |
3 |
|
$max => 10 |
4 |
|
$item_fragment => 'long' |
5 |
$coll => undef |
$coll => undef |
6 |
$moniker => 'search' |
$result_moniker => 'search' |
7 |
|
$result => undef |
8 |
</%args> |
</%args> |
9 |
<%init> |
<%init> |
10 |
|
|
11 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
12 |
|
|
13 |
my $results = Jifty->web->response->result( $moniker ); |
$result ||= Jifty->web->response->result( $result_moniker ); |
14 |
if ( $results and $results->content('search') ) { |
if ( $result and $result->content('search') ) { |
15 |
$coll = $results->content('search'); |
$coll = $result->content('search'); |
16 |
} elsif (! $coll) { |
} elsif (! defined($coll)) { |
17 |
warn "called without results for $moniker"; |
warn "called without result for $result_moniker"; |
18 |
} |
} |
19 |
|
|
20 |
|
warn "notes: ",dump($result->message, $result->error) if ($result); |
21 |
|
|
22 |
|
my $i = 1; |
23 |
|
|
24 |
</%init> |
</%init> |
25 |
|
% if ($result and $result->message) { |
26 |
|
<div class="grep-note"> |
27 |
|
<div class="message"><% $result->message %></div> |
28 |
|
</div> |
29 |
|
% } |
30 |
|
% if ($result and $result->error) { |
31 |
|
<div class="grep-note"> |
32 |
|
<div class="error"><% $result->error %></div> |
33 |
|
</div> |
34 |
|
% } |
35 |
% if ($coll) { |
% if ($coll) { |
36 |
<div class="results"> |
<div class="results"> |
37 |
% while ( my $i = $coll->next ) { |
% while ( my $i = $coll->next and $i++ <= $max ) { |
38 |
<& "/fragments/$item_fragment", item => $i &> |
<& "/fragments/item/$item_fragment", item => $i &> |
39 |
% } |
% } |
40 |
</div> |
</div> |
41 |
|
% if ($i > $max) { |
42 |
|
<div class="grep-note"> |
43 |
|
<div class="message"> |
44 |
|
Found more than <% $max %> results for '<% $q %>', refine search query.... |
45 |
|
</div> |
46 |
|
</div> |
47 |
|
% } |
48 |
% } |
% } |