1 |
use strict; |
2 |
use warnings; |
3 |
|
4 |
package Grep::Model::Feed; |
5 |
use Jifty::DBI::Schema; |
6 |
|
7 |
use Feed::Find; |
8 |
|
9 |
use Grep::Record schema { |
10 |
|
11 |
column uri => |
12 |
type is 'text', |
13 |
label is 'URI', |
14 |
hints is 'Replace search string in URI with %s (grep will be replaced automatically)', |
15 |
is mandatory, |
16 |
distinct; |
17 |
|
18 |
column title => |
19 |
type is 'text', |
20 |
label is 'Title', |
21 |
hints is 'Use something descriptive to you', |
22 |
since '0.0.2'; |
23 |
|
24 |
column cookie => |
25 |
type is 'text', |
26 |
label is 'Cookie', |
27 |
render as 'textarea', |
28 |
hints are 'If you leave Cookie data Grep will impersonate you to feed provider!', |
29 |
since '0.0.3'; |
30 |
|
31 |
}; |
32 |
|
33 |
sub since { '0.0.1' } |
34 |
|
35 |
# Your model-specific methods go here. |
36 |
|
37 |
=head2 search_uri |
38 |
|
39 |
print $feed->search_uri('search string'); |
40 |
|
41 |
This function will decode field delimiters C<|!|> into normal C<;> |
42 |
(which are protected to make AJAX validation work) |
43 |
|
44 |
=cut |
45 |
|
46 |
sub search_uri { |
47 |
my $self = shift; |
48 |
my $search = shift; |
49 |
|
50 |
my $uri = $self->uri or die "no uri?"; |
51 |
$uri =~ s/\Q|!|\E/;/g; |
52 |
return sprintf( $uri, $search ); |
53 |
} |
54 |
|
55 |
|
56 |
sub current_user_can { |
57 |
my $self = shift; |
58 |
my $what = shift; |
59 |
|
60 |
Jifty->log->debug("current_user_can($what) on feed ", $self->id); |
61 |
|
62 |
return 1 if Jifty->web->current_user->id; |
63 |
} |
64 |
|
65 |
1; |
66 |
|