Changeset 85 in bookmarks for trunk/bkmk
- Timestamp:
- 06/04/15 00:54:06 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bkmk
r83 r85 31 31 get => sub { 32 32 my $identifier = shift; 33 my $query = $identifier =~ /^\d+$/ ? { id => $identifier } : { uri => $identifier }; 34 my $bookmark = $bookmarks->get_bookmark($query); 35 36 print $bookmark ? Dump($bookmark) : "Not Found\n"; 33 my $bookmark = find_bookmark($identifier); 34 print $bookmark ? Dump($bookmark->TO_JSON) : "Not Found\n"; 37 35 }, 38 36 … … 41 39 my $title = defined $TITLE ? $TITLE : fetch_title($uri); 42 40 my $bookmark = $bookmarks->add({ uri => $uri, title => $title, tags => \@tags }); 43 print Dump($bookmark );41 print Dump($bookmark->TO_JSON); 44 42 }, 45 43 46 44 list => sub { 47 45 my @tags = @_; 48 my @resources = $bookmarks->get_bookmarks({49 tag => \@tags46 my $resources = $bookmarks->get_bookmarks({ 47 tags => \@tags 50 48 }); 51 49 # TODO: list by tags, date, etc. 52 50 # TODO: coordinate this commandline script with the CGI app 53 print Dump( \@resources);51 print Dump([ map { $_->TO_JSON } @{ $resources->results } ]); 54 52 }, 53 54 tag => sub { 55 my ($identifier, @tags) = @_; 56 my $bookmark = find_bookmark($identifier); 57 if ($bookmark) { 58 $bookmark->tags(\@tags); 59 $bookmarks->update($bookmark); 60 print Dump($bookmark->TO_JSON); 61 } else { 62 die "Not found\n"; 63 } 64 }, 65 66 #TODO: interactive editing of a bookmark 55 67 56 68 # bulk loading … … 66 78 $action_for{$command}->(@ARGV); 67 79 80 sub find_bookmark { 81 my $identifier = shift; 82 my $query = $identifier =~ /^\d+$/ ? { id => $identifier } : { uri => $identifier }; 83 return $bookmarks->get_bookmark($query); 84 } 85 68 86 sub fetch_title { 69 87 my $uri = shift;
Note: See TracChangeset
for help on using the changeset viewer.