Changeset 7 in bookmarks for trunk/Bookmarks.pm


Ignore:
Timestamp:
03/23/12 23:50:49 (13 years ago)
Author:
peter
Message:
  • added a base_uri property to the Bookmarks class; if present, it adds a bookmark_uri key to bookmarks returned by get_bookmark() and get_resources()
  • an individual bookmark can be returned as JSON by passing a "?format=json" parameter to the individual bookmark GET request
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Bookmarks.pm

    r2 r7  
    44use Bookmark; 
    55 
    6 has dbh => ( is => 'ro'); 
     6has dbh      => ( is => 'ro' ); 
     7has base_uri => ( is => 'ro' ); 
    78 
    89sub get_bookmark { 
     
    2425        $sth_tag->execute($bookmark->{uri}); 
    2526        $bookmark->{tags} = [ map { $$_[0] } @{ $sth_tag->fetchall_arrayref } ]; 
     27        if ($self->base_uri) { 
     28            $bookmark->{bookmark_uri} = $self->base_uri . $bookmark->{id}; 
     29        } 
    2630    } 
    2731    return $bookmark; 
     
    4650        $sth_tag->execute($resource->{uri}); 
    4751        $resource->{tags} = [ map { $$_[0] } @{ $sth_tag->fetchall_arrayref } ]; 
     52        if ($self->base_uri) { 
     53            $resource->{bookmark_uri} = $self->base_uri . $resource->{id}; 
     54        } 
    4855        push @resources, $resource; 
    4956    } 
Note: See TracChangeset for help on using the changeset viewer.