Show
Ignore:
Timestamp:
02/15/08 23:12:51 (7 years ago)
Author:
takemaru
Message:

lang/perl/Catalyst-Controller-Atompub: 0.3.3 released. fix many bugs, see Changes in details

Location:
lang/perl/Catalyst-Controller-Atompub
Files:
16 modified
1 copied

Legend:

Unmodified
Added
Removed
  • lang/perl/Catalyst-Controller-Atompub/tags/0.3.3/Changes

    r4823 r6742  
     12008-02-15  Takeru INOUE  <takeru.inoue _ gmail.com> 
     2 
     3        * release 0.3.3: 
     4        * lib/Catalyst/Helper/Controller/Atompub/Base.pm 
     5        - fix a bug in parsing arguments 
     6        * lib/Catalyst/Helper/Controller/Atompub/Collection.pm 
     7        - throw an error if HTTP body doesn't exist 
     8        - set //entry/summary in Media Link Entries 
     9        - add checks for some undef variables 
     10        * samples/MyBlog/lib/MyBlog/Controller/Html.pm 
     11        - add checks for some undef variables 
     12        * samples/MyBlog/lib/MyBlog/Controller/MediaCollection.pm 
     13        - overwrite //entry/content/@src and @type in Media Link 
     14          Entries 
     15        * samples/MyBlog/t/01.t 
     16        - add tests for //entry/content/@src and @type in Media Link 
     17          Entries 
     18 
    1192008-01-18  Takeru INOUE  <takeru.inoue _ gmail.com> 
    220 
  • lang/perl/Catalyst-Controller-Atompub/tags/0.3.3/lib/Catalyst/Controller/Atompub.pm

    r4823 r6742  
    55use Carp; 
    66 
    7 use version; our $VERSION = qv('0.3.2'); 
     7use version; our $VERSION = qv('0.3.3'); 
    88 
    99use Atompub 0.1.6; 
  • lang/perl/Catalyst-Controller-Atompub/tags/0.3.3/lib/Catalyst/Controller/Atompub/Base.pm

    r3073 r6742  
    2727 
    2828    my ( $status, $message ) 
    29         = @args  > 1                                           ?  @args 
    30         : @args == 1 && $args[0] =~ /^(?:([1-5]\d\d)\s+)?(.+)/ ? ( $1, $2 ) 
    31         :                                                        (); 
     29        = @args  > 1                                      ?  @args 
     30        : @args == 1 && $args[0] =~ /^([1-5]\d\d)\s*(.*)/ ? ( $1, $2 ) 
     31        : @args == 1 && $args[0] =~ /^(.*)/               ? ( $2 ) 
     32        :                                                   (); 
    3233 
    3334    $status ||= RC_INTERNAL_SERVER_ERROR; 
  • lang/perl/Catalyst-Controller-Atompub/tags/0.3.3/lib/Catalyst/Controller/Atompub/Collection.pm

    r2901 r6742  
    215215        my ( $entry_uri, $media_uri ) = $self->make_edit_uri( $c, $media_type ); 
    216216 
     217        return $self->error( $c, RC_BAD_REQUEST, 'No body' ) 
     218            unless $c->req->body; 
     219 
    217220        my $media 
    218221            = read_file( $c->req->body, binmode => ':raw', err_mode => 'carp' ) 
     
    235238        $content->type( $c->req->content_type ); 
    236239        $entry->content( $content ); 
     240 
     241        $entry->summary(' '); 
    237242 
    238243        my $rc = Catalyst::Controller::Atompub::Collection::Resource->new; 
     
    450455 
    451456    my $match = $method eq 'GET' ? $c->req->if_none_match : $c->req->if_match; 
    452     $match =~ s/^['"](.+)['"]$/$1/; #" unquote 
     457    $match =~ s/^['"](.+)['"]$/$1/ if $match; #" unquote 
    453458 
    454459    return 1 if defined $etag && ( ! defined $match || $etag ne $match ); 
  • lang/perl/Catalyst-Controller-Atompub/tags/0.3.3/samples/MyBlog/lib/MyBlog/Controller/Html.pm

    r2805 r6742  
    3939        my $uri     = $entry->edit_link; 
    4040        my $title   = qq{<a href="$uri">} . $entry->title . '</a>'; 
    41         my $content = $entry->content->body; 
     41        my $content = $entry->content ? $entry->content->body : ''; 
    4242 
    4343        push @entries, { updated => datetime( $entry->updated )->str, 
     
    5454        my $entry = XML::Atom::Entry->new( \$resource->entry_body ); 
    5555 
    56         my $uri     = $entry->content->src; 
     56        my $uri     = $entry->content ? $entry->content->src : next; 
    5757        my $title   = qq{<a href="$uri">} . $entry->title . '</a>'; 
    5858        my $content = qq{<a href="$uri"><img src="$uri"/></a>}; 
  • lang/perl/Catalyst-Controller-Atompub/tags/0.3.3/samples/MyBlog/lib/MyBlog/Controller/MediaCollection.pm

    r2805 r6742  
    116116    my $vals = { edited => $self->edited->epoch }; 
    117117 
     118    my ( $media_link_entry, $media_type ); 
    118119    if ( $rs->entry_uri eq $uri ) { 
    119         $vals->{entry_etag} = $self->calculate_new_etag( $c, $uri ); 
    120         $vals->{entry_body} = $self->media_link_entry->body->as_xml; 
    121  
    122         # Don't update the Last-Modified value of the corresponding Media Resource if you use it 
     120        $media_link_entry = $self->media_link_entry->body; 
     121        $media_type = $rs->media_type; 
     122 
     123        # Don't update the Last-Modified value of the corresponding 
     124        # Media Resource if you use it 
    123125    } 
    124126    else { 
    125         # app:edited and atom:updated MUST be updated even when the cooresponding Media Resource is updated 
    126         my $entry = XML::Atom::Entry->new( \$rs->entry_body ) 
     127        $media_link_entry = XML::Atom::Entry->new( \$rs->entry_body ) 
    127128            || return $self->error( $c ); 
    128         $entry->edited( $self->edited->w3c ); 
    129  
    130         $vals->{entry_etag} = $self->calculate_new_etag( $c, $rs->entry_uri ); 
    131         $vals->{entry_body} = $entry->as_xml; 
    132129 
    133130        $vals->{media_etag} = $self->calculate_new_etag( $c, $rs->media_uri ); 
    134131        $vals->{media_body} = MIME::Base64::encode( $self->media_resource->body ); 
    135         $vals->{media_type} = $self->media_resource->type; 
     132        $vals->{media_type} = $media_type = $self->media_resource->type; 
    136133 
    137134        # Do update the Last-Modified value of the Media Resource if you use it 
    138135    } 
     136 
     137    # app:edited and atom:content in Media Link Entry MUST be updated 
     138    $media_link_entry->edited( $self->edited->w3c ); 
     139    my $content = XML::Atom::Content->new; 
     140       $content->src( $rs->media_uri ); 
     141       $content->type( $media_type ); 
     142    $media_link_entry->content( $content ); 
     143 
     144    $vals->{entry_body} = $media_link_entry->as_xml; 
     145    $vals->{entry_etag} = $self->calculate_new_etag( $c, $rs->entry_uri ); 
    139146 
    140147    $rs->update( $vals ) 
  • lang/perl/Catalyst-Controller-Atompub/tags/0.3.3/samples/MyBlog/t/01.t

    r3073 r6742  
    22use warnings; 
    33use Data::Dumper; $Data::Dumper::Indent = 1; 
    4 use Test::More tests => 93; 
     4use Test::More tests => 98; 
    55 
    66use Atompub::Client; 
     
    152152 
    153153is $entry->content->src, 'http://localhost:3000/mediacollection/media_1.gif'; 
     154is $entry->content->type, 'image/gif'; 
    154155 
    155156ok $client->createMedia( $coll[1]->href, 't/samples/media1.gif', 'image/gif', 
     
    187188 
    188189$entry->title('Media 1, ver.2'); 
     190$entry->content->src('http://wrong.uri'); 
     191$entry->content->type('wrong/type'); 
    189192 
    190193ok $client->updateEntry( $uri, $entry ); 
     
    197200$entry = $client->rc; 
    198201is $entry->title, 'Media 1, ver.2'; 
     202is $entry->content->src, 'http://localhost:3000/mediacollection/media_1.gif'; 
     203is $entry->content->type, 'image/gif'; 
    199204 
    200205 
     
    215220# Update Media Resource 
    216221 
    217 # XXX Entry can not have app:edited, you SHOULD get it from Feed generally 
    218222my $prev_edited = $entry->edited; 
    219223sleep 1; 
     
    227231is $client->rc, read_file( 't/samples/media2.png', binmode => ':raw' ); 
    228232 
    229 # XXX Entry can not have app:edited, you SHOULD get it from Feed generally 
    230 ok datetime( $client->getEntry( $uri )->edited ) > datetime( $prev_edited ); 
     233$entry = $client->getEntry($uri); 
     234ok datetime( $entry->edited ) > datetime( $prev_edited ); 
     235is $entry->content->src, 'http://localhost:3000/mediacollection/media_1.gif'; 
     236is $entry->content->type, 'image/png'; 
    231237 
    232238 
  • lang/perl/Catalyst-Controller-Atompub/trunk/Changes

    r4823 r6742  
     12008-02-15  Takeru INOUE  <takeru.inoue _ gmail.com> 
     2 
     3        * release 0.3.3: 
     4        * lib/Catalyst/Helper/Controller/Atompub/Base.pm 
     5        - fix a bug in parsing arguments 
     6        * lib/Catalyst/Helper/Controller/Atompub/Collection.pm 
     7        - throw an error if HTTP body doesn't exist 
     8        - set //entry/summary in Media Link Entries 
     9        - add checks for some undef variables 
     10        * samples/MyBlog/lib/MyBlog/Controller/Html.pm 
     11        - add checks for some undef variables 
     12        * samples/MyBlog/lib/MyBlog/Controller/MediaCollection.pm 
     13        - overwrite //entry/content/@src and @type in Media Link 
     14          Entries 
     15        * samples/MyBlog/t/01.t 
     16        - add tests for //entry/content/@src and @type in Media Link 
     17          Entries 
     18 
    1192008-01-18  Takeru INOUE  <takeru.inoue _ gmail.com> 
    220 
  • lang/perl/Catalyst-Controller-Atompub/trunk/lib/Catalyst/Controller/Atompub.pm

    r4823 r6742  
    55use Carp; 
    66 
    7 use version; our $VERSION = qv('0.3.2'); 
     7use version; our $VERSION = qv('0.3.3'); 
    88 
    99use Atompub 0.1.6; 
  • lang/perl/Catalyst-Controller-Atompub/trunk/lib/Catalyst/Controller/Atompub/Base.pm

    r3073 r6742  
    2727 
    2828    my ( $status, $message ) 
    29         = @args  > 1                                           ?  @args 
    30         : @args == 1 && $args[0] =~ /^(?:([1-5]\d\d)\s+)?(.+)/ ? ( $1, $2 ) 
    31         :                                                        (); 
     29        = @args  > 1                                      ?  @args 
     30        : @args == 1 && $args[0] =~ /^([1-5]\d\d)\s*(.*)/ ? ( $1, $2 ) 
     31        : @args == 1 && $args[0] =~ /^(.*)/               ? ( $2 ) 
     32        :                                                   (); 
    3233 
    3334    $status ||= RC_INTERNAL_SERVER_ERROR; 
  • lang/perl/Catalyst-Controller-Atompub/trunk/lib/Catalyst/Controller/Atompub/Collection.pm

    r2901 r6742  
    215215        my ( $entry_uri, $media_uri ) = $self->make_edit_uri( $c, $media_type ); 
    216216 
     217        return $self->error( $c, RC_BAD_REQUEST, 'No body' ) 
     218            unless $c->req->body; 
     219 
    217220        my $media 
    218221            = read_file( $c->req->body, binmode => ':raw', err_mode => 'carp' ) 
     
    235238        $content->type( $c->req->content_type ); 
    236239        $entry->content( $content ); 
     240 
     241        $entry->summary(' '); 
    237242 
    238243        my $rc = Catalyst::Controller::Atompub::Collection::Resource->new; 
     
    450455 
    451456    my $match = $method eq 'GET' ? $c->req->if_none_match : $c->req->if_match; 
    452     $match =~ s/^['"](.+)['"]$/$1/; #" unquote 
     457    $match =~ s/^['"](.+)['"]$/$1/ if $match; #" unquote 
    453458 
    454459    return 1 if defined $etag && ( ! defined $match || $etag ne $match ); 
  • lang/perl/Catalyst-Controller-Atompub/trunk/samples/MyBlog/lib/MyBlog/Controller/Html.pm

    r2805 r6742  
    3939        my $uri     = $entry->edit_link; 
    4040        my $title   = qq{<a href="$uri">} . $entry->title . '</a>'; 
    41         my $content = $entry->content->body; 
     41        my $content = $entry->content ? $entry->content->body : ''; 
    4242 
    4343        push @entries, { updated => datetime( $entry->updated )->str, 
     
    5454        my $entry = XML::Atom::Entry->new( \$resource->entry_body ); 
    5555 
    56         my $uri     = $entry->content->src; 
     56        my $uri     = $entry->content ? $entry->content->src : next; 
    5757        my $title   = qq{<a href="$uri">} . $entry->title . '</a>'; 
    5858        my $content = qq{<a href="$uri"><img src="$uri"/></a>}; 
  • lang/perl/Catalyst-Controller-Atompub/trunk/samples/MyBlog/lib/MyBlog/Controller/MediaCollection.pm

    r2805 r6742  
    116116    my $vals = { edited => $self->edited->epoch }; 
    117117 
     118    my ( $media_link_entry, $media_type ); 
    118119    if ( $rs->entry_uri eq $uri ) { 
    119         $vals->{entry_etag} = $self->calculate_new_etag( $c, $uri ); 
    120         $vals->{entry_body} = $self->media_link_entry->body->as_xml; 
    121  
    122         # Don't update the Last-Modified value of the corresponding Media Resource if you use it 
     120        $media_link_entry = $self->media_link_entry->body; 
     121        $media_type = $rs->media_type; 
     122 
     123        # Don't update the Last-Modified value of the corresponding 
     124        # Media Resource if you use it 
    123125    } 
    124126    else { 
    125         # app:edited and atom:updated MUST be updated even when the cooresponding Media Resource is updated 
    126         my $entry = XML::Atom::Entry->new( \$rs->entry_body ) 
     127        $media_link_entry = XML::Atom::Entry->new( \$rs->entry_body ) 
    127128            || return $self->error( $c ); 
    128         $entry->edited( $self->edited->w3c ); 
    129  
    130         $vals->{entry_etag} = $self->calculate_new_etag( $c, $rs->entry_uri ); 
    131         $vals->{entry_body} = $entry->as_xml; 
    132129 
    133130        $vals->{media_etag} = $self->calculate_new_etag( $c, $rs->media_uri ); 
    134131        $vals->{media_body} = MIME::Base64::encode( $self->media_resource->body ); 
    135         $vals->{media_type} = $self->media_resource->type; 
     132        $vals->{media_type} = $media_type = $self->media_resource->type; 
    136133 
    137134        # Do update the Last-Modified value of the Media Resource if you use it 
    138135    } 
     136 
     137    # app:edited and atom:content in Media Link Entry MUST be updated 
     138    $media_link_entry->edited( $self->edited->w3c ); 
     139    my $content = XML::Atom::Content->new; 
     140       $content->src( $rs->media_uri ); 
     141       $content->type( $media_type ); 
     142    $media_link_entry->content( $content ); 
     143 
     144    $vals->{entry_body} = $media_link_entry->as_xml; 
     145    $vals->{entry_etag} = $self->calculate_new_etag( $c, $rs->entry_uri ); 
    139146 
    140147    $rs->update( $vals ) 
  • lang/perl/Catalyst-Controller-Atompub/trunk/samples/MyBlog/t/01.t

    r3073 r6742  
    22use warnings; 
    33use Data::Dumper; $Data::Dumper::Indent = 1; 
    4 use Test::More tests => 93; 
     4use Test::More tests => 98; 
    55 
    66use Atompub::Client; 
     
    152152 
    153153is $entry->content->src, 'http://localhost:3000/mediacollection/media_1.gif'; 
     154is $entry->content->type, 'image/gif'; 
    154155 
    155156ok $client->createMedia( $coll[1]->href, 't/samples/media1.gif', 'image/gif', 
     
    187188 
    188189$entry->title('Media 1, ver.2'); 
     190$entry->content->src('http://wrong.uri'); 
     191$entry->content->type('wrong/type'); 
    189192 
    190193ok $client->updateEntry( $uri, $entry ); 
     
    197200$entry = $client->rc; 
    198201is $entry->title, 'Media 1, ver.2'; 
     202is $entry->content->src, 'http://localhost:3000/mediacollection/media_1.gif'; 
     203is $entry->content->type, 'image/gif'; 
    199204 
    200205 
     
    215220# Update Media Resource 
    216221 
    217 # XXX Entry can not have app:edited, you SHOULD get it from Feed generally 
    218222my $prev_edited = $entry->edited; 
    219223sleep 1; 
     
    227231is $client->rc, read_file( 't/samples/media2.png', binmode => ':raw' ); 
    228232 
    229 # XXX Entry can not have app:edited, you SHOULD get it from Feed generally 
    230 ok datetime( $client->getEntry( $uri )->edited ) > datetime( $prev_edited ); 
     233$entry = $client->getEntry($uri); 
     234ok datetime( $entry->edited ) > datetime( $prev_edited ); 
     235is $entry->content->src, 'http://localhost:3000/mediacollection/media_1.gif'; 
     236is $entry->content->type, 'image/png'; 
    231237 
    232238