1 |
<%args> |
2 |
$q |
3 |
$max => 10 |
4 |
$item_fragment => 'long' |
5 |
$coll => undef |
6 |
$result_moniker => 'search' |
7 |
$result => undef |
8 |
</%args> |
9 |
<%init> |
10 |
|
11 |
use Data::Dump qw/dump/; |
12 |
|
13 |
$result ||= Jifty->web->response->result( $result_moniker ); |
14 |
if ( $result and $result->content('search') ) { |
15 |
$coll = $result->content('search'); |
16 |
} elsif (! defined($coll)) { |
17 |
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> |
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) { |
36 |
<div class="results"> |
37 |
% while ( my $i = $coll->next and $i++ <= $max ) { |
38 |
<& "/fragments/item/$item_fragment", item => $i &> |
39 |
% } |
40 |
</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 |
% } |