- Timestamp:
- 06/04/13 13:50:54 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BookmarkApp.pm
r48 r49 7 7 8 8 use Encode; 9 use HTTP::Date qw{time2isoz };9 use HTTP::Date qw{time2isoz time2iso}; 10 10 use JSON; 11 11 use Bookmarks; … … 79 79 }, 80 80 { 81 text => 'CSV', 82 type => 'text/csv', 83 query => { 84 tag => $tags, 85 format => 'csv', 86 }, 87 }, 88 { 81 89 text => 'URI List', 82 90 type => 'text/uri-list', … … 85 93 format => 'text', 86 94 }, 87 } 95 }, 88 96 ); 89 97 … … 198 206 $_->uri 199 207 } @resources; 208 } elsif ($format eq 'csv') { 209 require Text::CSV; 210 my $csv = Text::CSV->new; 211 my $text = qq{id,uri,title,tags,ctime,mtime\n}; 212 for my $bookmark (@resources) { 213 my $success = $csv->combine( 214 $bookmark->id, 215 $bookmark->uri, 216 $bookmark->title, 217 join(' ', @{ $bookmark->tags }), 218 $bookmark->ctime, 219 $bookmark->mtime, 220 ); 221 $text .= $csv->string . "\n" if $success; 222 } 223 224 # include the local timestamp in the attchment filename 225 my $dt = time2iso; 226 $dt =~ s/[^\d]//g; 227 228 $self->header_props( 229 -type => 'text/csv', 230 -charset => 'UTF-8', 231 -attachment => 'bookmarks-' . join('_', @tags) . "-$dt.csv", 232 ); 233 return $text; 200 234 } else { 201 235 $self->header_props(
Note: See TracChangeset
for help on using the changeset viewer.