Changeset 31 in bookmarks


Ignore:
Timestamp:
05/24/13 00:51:05 (11 years ago)
Author:
peter
Message:
  • the Atom feed understands multiple tag query parameters
  • the Atom feed includes an alternate link to the HTML list
  • use the Bookmark methods instead of hash accessors when generating the Atom feed
  • use the canonical form of the bookmark URI (to exclude the :80)
  • calculate a common title that includes all of the tag query parameters; this title is used for the Atom feed, the XBEL, and the HTML list
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BookmarkApp.pm

    r30 r31  
    8484    my @all_tags = $bookmarks->get_tags({ selected => $tag }); 
    8585    my @cotags = $bookmarks->get_cotags({ tag => \@tags }); 
     86     
     87    my $title = 'Bookmarks' . (@tags ? " tagged as " . join(' & ', @tags) : ''); 
    8688 
    8789    if ($format eq 'json') { 
     
    102104 
    103105        $xbel->new_document({ 
    104             title => 'Bookmarks' . ($tag ? " tagged as $tag" : ''), 
     106            title => $title, 
    105107        }); 
    106108 
     
    178180            $link->{href}->query_form($link->{query}); 
    179181        } 
    180          
     182 
    181183        return $self->tt_process( 
    182184            'list.tt', 
    183185            { 
    184186                base_url     => $base_url, 
     187                title        => $title, 
    185188                selected_tag => $tag, 
    186189                search_tags  => \@tags, 
     
    199202 
    200203    my $tag = $q->param('tag'); 
     204    my @tags = $q->param('tag'); 
     205    # special case: handle the empty tag 
     206    if (@tags == 1 && $tags[0] eq '') { 
     207        @tags = (); 
     208    } 
     209 
     210    my $title = 'Bookmarks' . (@tags ? " tagged as " . join(' & ', @tags) : ''); 
    201211 
    202212    require XML::Atom::Feed; 
     
    205215 
    206216    my $feed = XML::Atom::Feed->new; 
    207     $feed->title('Bookmarks' . ($tag ? " tagged as $tag" : '')); 
     217    $feed->title($title); 
    208218    $feed->id($base_uri->canonical . 'feed'); 
     219    my $html_link = XML::Atom::Link->new; 
     220    $html_link->type('text/html'); 
     221    $html_link->rel('alternate'); 
     222    $html_link->href($base_uri->canonical); 
     223    $feed->add_link($html_link); 
    209224 
    210225    # construct a feed from the most recent 12 bookmarks 
    211     for my $bookmark ($bookmarks->get_bookmarks({ tag => $tag, limit => 12 })) { 
     226    for my $bookmark ($bookmarks->get_bookmarks({ tag => \@tags, limit => 12 })) { 
    212227        my $entry = XML::Atom::Entry->new; 
    213         $entry->id($bookmark->{bookmark_uri}); 
    214         $entry->title($bookmark->{title}); 
     228        $entry->id($bookmark->bookmark_uri->canonical); 
     229        $entry->title($bookmark->title); 
    215230        my $link = XML::Atom::Link->new; 
    216         $link->href($bookmark->{uri}); 
     231        $link->href($bookmark->uri); 
    217232        $entry->add_link($link); 
    218         $entry->summary('Tags: ' . join(', ', @{ $bookmark->{tags} })); 
     233        $entry->summary('Tags: ' . join(', ', @{ $bookmark->tags })); 
    219234        $feed->add_entry($entry); 
    220235    } 
  • trunk/list.tt

    r29 r31  
    11<html> 
    22  <head> 
    3     <title>Bookmarks</title> 
     3    <title>[% title %]</title> 
    44    <base href="[% base_url %]"/> 
    55    <style type="text/css"> 
Note: See TracChangeset for help on using the changeset viewer.