--- lib/Grep/Model/Feed.pm 2007/02/18 12:49:38 18 +++ lib/Grep/Model/Feed.pm 2007/02/18 12:51:26 19 @@ -4,25 +4,68 @@ package Grep::Model::Feed; use Jifty::DBI::Schema; +use Feed::Find; + use Grep::Record schema { column uri => type is 'text', label is 'URI', - hints is 'Replace search string in URI with %s', + hints is 'Replace search string in URI with %s (grep will be replaced automatically)', is mandatory, distinct; column title => type is 'text', + label is 'Title', hints is 'Use something descriptive to you', since '0.0.2'; + column cookie => + type is 'text', + label is 'Cookie', + render as 'textarea', + hints are 'If you leave Cookie data Grep will impersonate you to feed provider!', + since '0.0.3'; + }; sub since { '0.0.1' } # Your model-specific methods go here. +=head2 canonicalize_uri + +Replace C' with C<%s> in URI arguments + +=cut + +sub canonicalize_uri { + my $self = shift; + my $value = shift; + warn "uri: $value"; + $value =~ s/=grep/=%s/; + return $value; +} + +=head2 search_uri + + print $feed->search_uri('search string'); + +This function will decode field delimiters C<|!|> into normal C<;> +(which are protected to make AJAX validation work) + +=cut + +sub search_uri { + my $self = shift; + my $search = shift; + + my $uri = $self->uri or die "no uri?"; + $uri =~ s/\Q|!|\E/;/g; + return sprintf( $uri, $search ); +} + + 1;