/[Grep]/lib/Grep/Model/Feed.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /lib/Grep/Model/Feed.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 58 - (hide annotations)
Wed Feb 21 19:10:20 2007 UTC (17 years, 3 months ago) by dpavlin
File size: 1737 byte(s)
Another mish-mash of different changes rolled into one commit: added feed owners,
better support for bootstraping without data (actaully, fixes to be able to do so...)
1 dpavlin 2 use strict;
2     use warnings;
3    
4     package Grep::Model::Feed;
5     use Jifty::DBI::Schema;
6    
7 dpavlin 19 use Feed::Find;
8 dpavlin 58 use Scalar::Defer;
9     use Grep::Model::User;
10 dpavlin 19
11 dpavlin 2 use Grep::Record schema {
12    
13     column uri =>
14     type is 'text',
15     label is 'URI',
16 dpavlin 19 hints is 'Replace search string in URI with %s (grep will be replaced automatically)',
17 dpavlin 2 is mandatory,
18     distinct;
19    
20 dpavlin 3 column title =>
21     type is 'text',
22 dpavlin 19 label is 'Title',
23 dpavlin 12 hints is 'Use something descriptive to you',
24 dpavlin 3 since '0.0.2';
25    
26 dpavlin 19 column cookie =>
27     type is 'text',
28     label is 'Cookie',
29     render as 'textarea',
30     hints are 'If you leave Cookie data Grep will impersonate you to feed provider!',
31     since '0.0.3';
32    
33 dpavlin 58 column owner =>
34     refers_to Grep::Model::User by 'id',
35     label is 'Feed owner',
36     default is defer { Jifty->web->current_user->id },
37     since '0.0.5';
38    
39     column created_on =>
40     type is 'timestamp',
41     label is 'Created On',
42     default is defer { DateTime->now },
43     filters are 'Jifty::DBI::Filter::DateTime',
44     since '0.0.5';
45    
46 dpavlin 2 };
47    
48 dpavlin 3 sub since { '0.0.1' }
49    
50 dpavlin 2 # Your model-specific methods go here.
51    
52 dpavlin 19 =head2 search_uri
53    
54     print $feed->search_uri('search string');
55    
56     This function will decode field delimiters C<|!|> into normal C<;>
57     (which are protected to make AJAX validation work)
58    
59     =cut
60    
61     sub search_uri {
62     my $self = shift;
63     my $search = shift;
64    
65     my $uri = $self->uri or die "no uri?";
66     $uri =~ s/\Q|!|\E/;/g;
67     return sprintf( $uri, $search );
68     }
69    
70    
71 dpavlin 37 sub current_user_can {
72     my $self = shift;
73     my $what = shift;
74    
75 dpavlin 58 my $uid = Jifty->web->current_user->id;
76 dpavlin 37
77 dpavlin 58 return 1 if ( $uid && $what eq 'create' );
78    
79     return 1 if ( $uid && ! $self->id );
80    
81     Jifty->log->debug("current_user[$uid]_can($what) on feed ", $self->id || '???', " owner ", $self->owner->id || '???');
82    
83     return 1 if ( $uid == $self->owner->id );
84    
85 dpavlin 37 }
86    
87 dpavlin 2 1;
88    

  ViewVC Help
Powered by ViewVC 1.1.26