Changeset 36 in bookmarks for trunk


Ignore:
Timestamp:
05/25/13 02:56:47 (11 years ago)
Author:
peter
Message:
  • the XBEL creation uses the accessors insead of direct hash access of Bookmark
  • added a ?format=text option that returns a text/uri-list representation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BookmarkApp.pm

    r35 r36  
    104104 
    105105        for my $bookmark (@resources) { 
    106             my $cdatetime = time2isoz $bookmark->{ctime}; 
    107             my $mdatetime = time2isoz $bookmark->{mtime}; 
     106            my $cdatetime = time2isoz $bookmark->ctime; 
     107            my $mdatetime = time2isoz $bookmark->mtime; 
    108108            # make the timestamps W3C-correct 
    109109            s/ /T/ foreach ($cdatetime, $mdatetime); 
    110110 
    111111            $xbel->add_bookmark({ 
    112                 href     => $bookmark->{uri}, 
    113                 title    => $bookmark->{title}, 
    114                 desc     => 'Tags: ' . join(', ', @{ $bookmark->{tags} }), 
     112                href     => $bookmark->uri, 
     113                title    => $bookmark->title, 
     114                desc     => 'Tags: ' . join(', ', @{ $bookmark->tags }), 
    115115                added    => $cdatetime, 
    116116                #XXX: are we sure that modified is the mtime of the bookmark or the resource? 
     
    125125 
    126126        return $xbel->toString; 
     127    } elsif ($format eq 'text') { 
     128        $self->header_props( 
     129            -type    => 'text/uri-list', 
     130            -charset => 'UTF-8', 
     131        ); 
     132        return join '',  
     133            map { 
     134                sprintf "# %s\n# Tags: %s\n%s\n", 
     135                $_->title, 
     136                join(', ', @{ $_->tags }),  
     137                $_->uri 
     138            } @resources; 
    127139    } else { 
    128140        $self->header_props( 
Note: See TracChangeset for help on using the changeset viewer.