- Timestamp:
- 08/15/13 15:58:10 (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BookmarkApp.pm
r51 r52 45 45 sub _get_list_links { 46 46 my $self = shift; 47 my ($self_type, $ tags) = @_;47 my ($self_type, $query) = @_; 48 48 my @links = ( 49 49 { … … 51 51 type => 'application/json', 52 52 query => { 53 tag => $tags,53 %$query, 54 54 format => 'json', 55 55 }, … … 59 59 type => 'application/xml', 60 60 query => { 61 tag => $tags,61 %$query, 62 62 format => 'xbel', 63 63 }, … … 68 68 path => 'feed', 69 69 query => { 70 tag => $tags,70 %$query, 71 71 }, 72 72 }, … … 75 75 type => 'text/csv', 76 76 query => { 77 tag => $tags,77 %$query, 78 78 format => 'csv', 79 79 }, … … 83 83 type => 'text/uri-list', 84 84 query => { 85 tag => $tags,85 %$query, 86 86 format => 'text', 87 87 }, … … 91 91 type => 'text/html', 92 92 query => { 93 tag => $tags,93 %$query, 94 94 }, 95 95 }, … … 140 140 141 141 my @tags = grep { $_ ne '' } $q->param('tag'); 142 my $query = $q->param('q'); 142 143 my $limit = $q->param('limit'); 143 144 my $offset = $q->param('offset'); 144 145 my @resources = $self->_bookmarks->get_bookmarks({ 146 query => $query, 145 147 tag => \@tags, 146 148 limit => $limit, … … 148 150 }); 149 151 my @all_tags = $self->_bookmarks->get_tags({ selected => $tags[0] }); 150 my @cotags = $self->_bookmarks->get_cotags({ tag => \@tags }); 152 my @cotags = $self->_bookmarks->get_cotags({ 153 query => $query, 154 tag => \@tags, 155 }); 151 156 152 my $title = 'Bookmarks' . (@tags ? " tagged as " . join(' & ', @tags) : '') ;157 my $title = 'Bookmarks' . (@tags ? " tagged as " . join(' & ', @tags) : '') . ($query ? " matching '$query'" : ''); 153 158 154 159 if ($format eq 'json') { … … 247 252 base_url => $base_url, 248 253 title => $title, 254 query => $query, 249 255 selected_tag => $tags[0], 250 256 search_tags => \@tags, 251 links => [ $self->_get_list_links('text/html', \@tags) ],257 links => [ $self->_get_list_links('text/html', { q => $query, tag => \@tags }) ], 252 258 all_tags => \@all_tags, 253 259 cotags => \@cotags, … … 262 268 my $q = $self->query; 263 269 270 my $query = $q->param('q'); 264 271 my @tags = grep { $_ ne '' } $q->param('tag'); 265 272 my $title = 'Bookmarks' . (@tags ? " tagged as " . join(' & ', @tags) : ''); … … 280 287 $feed->id($feed_uri->canonical); 281 288 282 for my $link ($self->_get_list_links('application/atom+xml', \@tags)) {289 for my $link ($self->_get_list_links('application/atom+xml', { q => $query, tag => \@tags })) { 283 290 my $atom_link = XML::Atom::Link->new; 284 291 $atom_link->type($link->{type}); … … 289 296 290 297 # construct a feed from the most recent 12 bookmarks 291 for my $bookmark ($self->_bookmarks->get_bookmarks({ tag => \@tags, limit => 12 })) {298 for my $bookmark ($self->_bookmarks->get_bookmarks({ query => $query, tag => \@tags, limit => 12 })) { 292 299 my $entry = XML::Atom::Entry->new; 293 300 $entry->id($bookmark->bookmark_uri->canonical); -
trunk/Bookmarks.pm
r47 r52 71 71 my $self = shift; 72 72 my $params = shift; 73 my $query = $params->{query}; 73 74 my $tags = $params->{tag} || []; 74 75 my $limit = $params->{limit}; … … 92 93 push @sql, 'select * from resources join bookmarks on resources.uri = bookmarks.uri'; 93 94 } 95 if ($query) { 96 push @sql, (@$tags ? 'and' : 'where'), 'title like', \"%$query%"; 97 } 94 98 push @sql, 'order by ctime desc'; 95 99 push @sql, ('limit', \$limit) if $limit; … … 98 102 99 103 my ($sql, @bind) = sql_interp(@sql); 104 #die $sql; 100 105 101 106 my $sth_resource = $self->dbh->prepare($sql); … … 133 138 my $self = shift; 134 139 my $params = shift; 140 my $query = $params->{query}; 135 141 my $tags = $params->{tag} || []; 136 142 if (!ref $tags) { … … 140 146 141 147 push @sql, 'select tag, count(tag) as count from tags'; 148 push @sql, 'join resources on tags.uri = resources.uri' if $query; 149 150 # build the where clause 142 151 if (@$tags) { 143 push @sql, 'where uri in (';152 push @sql, 'where tags.uri in ('; 144 153 my $intersect = 0; 145 154 for my $tag (@{ $tags }) { … … 150 159 push @sql, ') and tag not in ', $tags, ''; 151 160 } 161 if ($query) { 162 push @sql, (@$tags ? 'and' : 'where'), 'title like', \"%$query%"; 163 } 164 152 165 push @sql, 'group by tag order by tag'; 153 166 -
trunk/list.tt
r40 r52 120 120 <div class="refine"> 121 121 <form method="get" action=""> 122 <label>Search: <input type="text" name="q" value="[% query | html %]" size="30"/></label> 122 123 <div class="taglists"> 123 124 <ul class="searchtags">
Note: See TracChangeset
for help on using the changeset viewer.