Changeset 61 in bookmarks for trunk


Ignore:
Timestamp:
08/23/13 16:50:59 (11 years ago)
Author:
peter
Message:
  • wrap the creation of the Bookmarks object into the BookmarkController
  • bookmark is a lazy-loaded read-only attribute with a builder in BookmarkController
  • made dbname and request required attributes of BookmarkController
  • updated the api notes
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/BookmarkController.pm

    r59 r61  
    99use Template; 
    1010 
     11has dbname => ( 
     12    is => 'ro', 
     13    required => 1, 
     14); 
    1115has bookmarks => ( 
    12     is => 'rw', 
     16    is => 'ro', 
    1317    handles => [qw{get_bookmark}], 
     18    builder => '_build_bookmarks', 
     19    lazy => 1, 
    1420); 
    1521has base_uri => ( 
     
    2026has request => ( 
    2127    is => 'ro', 
     28    required => 1, 
    2229); 
     30 
     31sub _build_bookmarks { 
     32    my $self = shift; 
     33    return Bookmarks->new({ 
     34        dbname   => $self->dbname, 
     35        base_uri => $self->base_uri, 
     36    }); 
     37} 
    2338 
    2439sub _build_base_uri { 
  • trunk/api

    r48 r61  
    33 
    44  Params: 
    5     format=json|xbel 
     5    format=json|xbel|text|csv|html 
    66    tag={tag} (repeatable) 
    77    limit={limit} 
     
    1616GET /feed 
    1717  Gets an Atom feed of the bookmarks 
     18 
     19  Params: 
     20    tag={tag} (repeatable) 
    1821 
    1922POST / 
  • trunk/app.psgi

    r60 r61  
    88 
    99use BookmarkController; 
    10 use Bookmarks; 
    1110 
    1211#TODO: allow a different config file on the command line, or set options from the command line 
     
    1918    my $req = shift; 
    2019 
    21     my $controller = BookmarkController->new({ 
     20    return BookmarkController->new({ 
    2221        request => $req, 
     22        dbname  => $config->{dbname}, 
    2323    }); 
    24     my $bookmarks = Bookmarks->new({ 
    25         dbname   => $config->{dbname}, 
    26         base_uri => $controller->base_uri, 
    27     }); 
    28     $controller->bookmarks($bookmarks); 
    29     return $controller; 
    3024} 
    3125 
Note: See TracChangeset for help on using the changeset viewer.