Last change
on this file since 23 was
20,
checked in by peter, 12 years ago
|
- Bookmarks::get_resources() and Bookmarks::get_cotags() both accept arrayrefs as their tag parameters
- can now use multiple ?tag query parameters in the request and it will search for the intersection of those tags
- bkmk list takes 0 or more --tag command line options
- display a checkbox-based form listing the search tags and available cotags at the below the list of bookmarks
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/usr/bin/perl -w |
---|
2 | use strict; |
---|
3 | |
---|
4 | use YAML; |
---|
5 | use Bookmarks; |
---|
6 | use Getopt::Long; |
---|
7 | |
---|
8 | GetOptions( |
---|
9 | 'file|f=s' => \my $DBNAME, |
---|
10 | 'tag=s' => \my @TAGS, |
---|
11 | ); |
---|
12 | |
---|
13 | die "Usage: $0 --file <dbname> <command>\n" unless $DBNAME; |
---|
14 | |
---|
15 | my $bookmarks = Bookmarks->new({ |
---|
16 | dbname => $DBNAME, |
---|
17 | }); |
---|
18 | |
---|
19 | my $command = shift; |
---|
20 | |
---|
21 | my %action_for = ( |
---|
22 | get => sub { |
---|
23 | my $identifier = shift; |
---|
24 | my $query = $identifier =~ /^\d+$/ ? { id => $identifier } : { uri => $identifier }; |
---|
25 | my $bookmark = $bookmarks->get_bookmark($query); |
---|
26 | |
---|
27 | print $bookmark ? Dump($bookmark) : "Not Found\n"; |
---|
28 | }, |
---|
29 | add => sub { |
---|
30 | my ($uri, $title, @tags) = @_; |
---|
31 | my $bookmark = $bookmarks->add({ uri => $uri, title => $title, tags => \@tags }); |
---|
32 | print Dump($bookmark); |
---|
33 | }, |
---|
34 | list => sub { |
---|
35 | my @resources = $bookmarks->get_resources({ |
---|
36 | tag => \@TAGS |
---|
37 | }); |
---|
38 | # TODO: list by tags, date, etc. |
---|
39 | # TODO: coordinate this commandline script with the CGI app |
---|
40 | print Dump(\@resources); |
---|
41 | }, |
---|
42 | load => sub { |
---|
43 | my ($src_file) = @_; |
---|
44 | my $src_bookmarks = YAML::LoadFile($src_file); |
---|
45 | for my $bookmark (@{ $src_bookmarks }) { |
---|
46 | $bookmarks->add($bookmark); |
---|
47 | } |
---|
48 | }, |
---|
49 | ); |
---|
50 | |
---|
51 | $action_for{$command}->(@ARGV); |
---|
52 | |
---|
53 | =begin |
---|
54 | |
---|
55 | use YAML; |
---|
56 | |
---|
Note: See
TracBrowser
for help on using the repository browser.