|
Last change
on this file since 89 was
88,
checked in by peter, 10 years ago
|
|
Better separation of the model for searching and the web app controller/representation layer
- renamed Bookmarks::get_bookmarks() to search()
- Bookmarks::search() now returns a Bookmarks::Search object instead of a Bookmarks::List
- search results now reside in the Bookmarks::Search class
|
-
Property svn:executable set to
*
|
|
File size:
777 bytes
|
| Line | |
|---|
| 1 | #!/usr/bin/perl -w |
|---|
| 2 | use strict; |
|---|
| 3 | |
|---|
| 4 | use Bookmarks; |
|---|
| 5 | use LWP::UserAgent; |
|---|
| 6 | use Text::CSV; |
|---|
| 7 | use Getopt::Long; |
|---|
| 8 | |
|---|
| 9 | GetOptions( |
|---|
| 10 | 'csv' => \my $CSV, |
|---|
| 11 | 'timeout=i' => \my $TIMEOUT, |
|---|
| 12 | ); |
|---|
| 13 | |
|---|
| 14 | my $DBFILE = shift or die "Usage: $0 <dbfile>"; |
|---|
| 15 | |
|---|
| 16 | $TIMEOUT ||= 10; |
|---|
| 17 | |
|---|
| 18 | my $bookmarks = Bookmarks->new({ |
|---|
| 19 | dbname => $DBFILE, |
|---|
| 20 | }); |
|---|
| 21 | |
|---|
| 22 | my $ua = LWP::UserAgent->new; |
|---|
| 23 | $ua->timeout($TIMEOUT); |
|---|
| 24 | |
|---|
| 25 | my $csv = Text::CSV->new; |
|---|
| 26 | |
|---|
| 27 | for my $bookmark (@{ $bookmarks->search->results }) { |
|---|
| 28 | printf "%3d %s\n", $bookmark->id, $bookmark->uri unless $CSV; |
|---|
| 29 | my $response = $ua->head($bookmark->uri); |
|---|
| 30 | printf " -> %s\n", $response->status_line unless $CSV; |
|---|
| 31 | $csv->combine( |
|---|
| 32 | $bookmark->id, |
|---|
| 33 | $bookmark->uri, |
|---|
| 34 | $response->code, |
|---|
| 35 | $response->message, |
|---|
| 36 | ); |
|---|
| 37 | print $csv->string . "\n" if $CSV; |
|---|
| 38 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.