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( |
if ( my $user_id = Jifty->web->current_user->id ) { |
8 |
class => 'Result', |
|
9 |
mode => 'Bottom', |
warn "adding subscription for user $user_id on this page\n"; |
|
region => 'results', |
|
|
render_with => '/fragments/result', |
|
|
); |
|
10 |
|
|
11 |
my $fetch = Jifty->web->new_action( |
Jifty->subs->add( |
12 |
class => 'Fetch', |
window_id => "results $user_id", |
13 |
moniker => 'fetch', |
class => 'Result', |
14 |
|
queries => [{ user_id => $user_id }], |
15 |
|
mode => 'Top', |
16 |
|
region => 'results', |
17 |
|
render_with => '/fragments/event/results', |
18 |
|
); |
19 |
|
|
20 |
|
} |
21 |
|
|
22 |
|
my $search = Jifty->web->new_action( |
23 |
|
class => 'Search', |
24 |
|
moniker => 'search', |
25 |
arguments => { %ARGS }, |
arguments => { %ARGS }, |
26 |
sticky_on_success => 1, |
sticky_on_success => 1, |
27 |
); |
); |
28 |
|
|
29 |
|
my $q = $search->argument_value('content_contains'); |
30 |
|
|
31 |
|
my $feeds = Jifty::Web::PageRegion->new( |
32 |
|
name => 'feeds', |
33 |
|
path => '/fragments/feeds', |
34 |
|
force_arguments => { |
35 |
|
q => $q, |
36 |
|
feed => undef, |
37 |
|
}, |
38 |
|
); |
39 |
|
|
40 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
41 |
|
|
42 |
</%init> |
</%init> |
43 |
|
|
44 |
<&| /_elements/wrapper, title => 'Grep - powerful RSS searcher' &> |
<&| '/_elements/wrapper', title => 'Grep - powerful RSS searcher' &> |
45 |
|
|
46 |
<a class="bookmarklet" href="javascript:location.href='<% Jifty->web->url( path => '/add' ) %>?uri='+encodeURIComponent(location.href).replace(new RegExp('%(26|3b)','gi'),'|!|')+'&title='+encodeURIComponent(document.title)+'&cookie='+encodeURIComponent(document.cookie).replace(new RegExp('%(26|3b)','gi'),'|!|')" title="drag and drop to bookmark toolbar to quickly add feed to grep">+grep</a> |
<div class="right"> |
47 |
|
% if ( $q ) { |
48 |
|
<% $feeds->render %> |
49 |
|
<hr/> |
50 |
|
% } |
51 |
|
</div> |
52 |
|
|
53 |
|
<div class="left"> |
54 |
|
<& '/fragments/bookmarklet' &> |
55 |
|
|
56 |
<% Jifty->web->form->start %> |
<% Jifty->web->form->start %> |
57 |
|
|
58 |
<% $fetch->form_field('q') %> |
<% $search->form_field('content_contains', label => 'Search for', q => $q ) %> |
|
<% $fetch->form_field('feed') %> |
|
59 |
|
|
60 |
<% $fetch->button( label => 'Grep' ) %> |
<% $search->button( label => 'Grep' ) %> |
61 |
|
|
62 |
<% Jifty->web->form->end %> |
<% Jifty->web->form->end %> |
63 |
|
|
64 |
% if ( my $result = Jifty->web->response->result('fetch') ) { |
<% $results->render %> |
|
% if ( my $items = $result->content('items') ) { |
|
|
% foreach my $i ( @$items ) { |
|
|
|
|
|
<& /fragments/result, item => $i &> |
|
65 |
|
|
66 |
% } |
% if ( $q ) { |
67 |
% } |
<& '/fragments/results', item_fragment => 'long', q => $q &> |
68 |
% } |
% } |
69 |
|
|
70 |
Results: <% $region->render %> |
</div> |
71 |
|
|
72 |
</&> |
</&> |