1 |
<%init> |
<%init> |
2 |
|
|
3 |
my $region = Jifty::Web::PageRegion->new( |
my $results = Jifty::Web::PageRegion->new( |
4 |
name => 'results', |
name => 'results', |
5 |
); |
); |
6 |
|
|
7 |
Jifty->subs->add( |
my $search = Jifty->web->new_action( |
8 |
class => 'Result', |
class => 'Search', |
9 |
mode => 'Bottom', |
moniker => 'search', |
|
region => 'results', |
|
|
render_with => '/fragments/result', |
|
|
); |
|
|
|
|
|
my $fetch = Jifty->web->new_action( |
|
|
class => 'Fetch', |
|
|
moniker => 'fetch', |
|
10 |
arguments => { %ARGS }, |
arguments => { %ARGS }, |
11 |
sticky_on_success => 1, |
sticky_on_success => 1, |
12 |
); |
); |
13 |
|
|
14 |
|
my $q = $search->argument_value('q'); |
15 |
|
|
16 |
|
my $feeds = Jifty::Web::PageRegion->new( |
17 |
|
name => 'feeds', |
18 |
|
path => '/fragments/feeds', |
19 |
|
force_arguments => { |
20 |
|
q => $q, |
21 |
|
feed => undef, |
22 |
|
}, |
23 |
|
); |
24 |
|
|
25 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
26 |
|
|
27 |
</%init> |
</%init> |
28 |
|
|
29 |
<&| /_elements/wrapper, title => 'Grep - powerfull RSS searcher' &> |
<&| '/_elements/wrapper', title => 'Grep - powerful RSS searcher' &> |
30 |
|
|
31 |
<a class="bookmarklet" href="javascript:location.href='<% Jifty->web->url( path => '/add' ) %>?uri='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)" title="drag and drop to bookmark toolbar to quickly add feed to grep">+grep</a> |
<div class="right"> |
32 |
|
% if ( $q ) { |
33 |
|
<% $feeds->render %> |
34 |
|
<hr/> |
35 |
|
% } |
36 |
|
</div> |
37 |
|
|
38 |
|
<div class="left"> |
39 |
|
<& '/fragments/bookmarklet' &> |
40 |
|
|
41 |
<% Jifty->web->form->start %> |
<% Jifty->web->form->start %> |
42 |
|
|
43 |
<% $fetch->form_field('q') %> |
<% $search->form_field('q') %> |
44 |
<% $fetch->form_field('feed') %> |
<% $search->form_field('item_fragment') %> |
45 |
|
<% $search->form_field('max') %> |
46 |
|
|
47 |
<% $fetch->button( label => 'Grep' ) %> |
<% $search->button( label => 'Grep' ) %> |
48 |
|
|
49 |
<% Jifty->web->form->end %> |
<% Jifty->web->form->end %> |
50 |
|
|
51 |
% if ( my $result = Jifty->web->response->result('fetch') ) { |
<% $results->render %> |
|
% if ( my $items = $result->content('items') ) { |
|
|
% foreach my $i ( @$items ) { |
|
|
|
|
|
<& /fragments/result, item => $i &> |
|
52 |
|
|
53 |
% } |
% if ( $q ) { |
54 |
% } |
<& '/fragments/results', |
55 |
|
q => $q, |
56 |
|
item_fragment => $search->argument_value('item_fragment'), |
57 |
|
max => $search->argument_value('max'), |
58 |
|
&> |
59 |
% } |
% } |
60 |
|
|
61 |
Results: <% $region->render %> |
</div> |
62 |
|
|
63 |
</&> |
</&> |