Changeset 107 in bookmarks
- Timestamp:
- 11/09/15 20:21:41 (9 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Bookmarks/Controller.pm
r106 r107 222 222 } 223 223 224 sub tag_tree { 225 my $self = shift; 226 my $tags = shift || []; 227 228 my $list = Bookmarks::List->new({ 229 bookmarks => $self->bookmarks, 230 search => $self->bookmarks->search({ 231 tags => $tags, 232 }), 233 }); 234 235 my @tags = map { 236 { 237 path => join('/', @$tags[0 .. $_ - 1]), 238 tag => $tags->[$_ - 1], 239 } 240 } 1 .. scalar(@{ $tags }); 241 242 require Template; 243 require File::Basename; 244 my @cotags = $self->bookmarks->get_cotags({ search => $list->search }); 245 246 #TODO: get the actual request URI and makre sure it ends with a / 247 my $base_url = join '/', ($self->base_uri . 'tags'), @$tags; 248 $base_url .= '/'; 249 my $template = Template->new({ INCLUDE_PATH => File::Basename::dirname($INC{'Bookmarks/Controller.pm'}) }); 250 251 $template->process( 252 'tagtree.html', 253 { 254 base_url => $self->base_uri, 255 request_url => $base_url, 256 tags => \@tags, 257 cotags => \@cotags, 258 bookmarks => $list->results, 259 }, 260 \my $output, 261 ); 262 263 264 return [200, ['Content-Type' => 'text/html; charset=UTF-8'], [$output]]; 265 } 266 224 267 1; -
trunk/lib/BookmarksApp.pm
r101 r107 82 82 }; 83 83 84 resource '/tags' => sub { 85 GET { 86 my ($env, $params) = @_; 87 return $self->_controller->tag_tree; 88 }; 89 }; 90 resource '/tags/*' => sub { 91 GET { 92 my ($env, $params) = @_; 93 my $tag_path = (@{ $params->{splat} })[0]; 94 return $self->_controller->tag_tree([ split m{/}, $tag_path ]); 95 }; 96 }; 97 84 98 resource '/{id}' => sub { 85 99 GET { … … 99 113 }; 100 114 }; 115 101 116 }; 102 117
Note: See TracChangeset
for help on using the changeset viewer.