Changeset 1820

Show
Ignore:
Timestamp:
04/09/08 07:50:46 (8 months ago)
Author:
fumiakiy
Message:

Atom 1.0 feed generated from AtomServer is now valid according to FeedValidator.org. BugId:79242

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-34/lib/MT/Atom.pm

    r1174 r1820  
    3737    # do we say it's that when all we're guaranteed is it's an opaque blob 
    3838    # of text? So use 'html' for new RFC compatible output. 
    39     $atom->content->type($rfc_compat ? 'html' : 'application/xhtml+xml'); 
     39    # XML::Atom::Content intelligently determines content-type for rfc compat. 
     40    unless ( $rfc_compat ) { 
     41        $atom->content->type('application/xhtml+xml'); 
     42    } 
    4043 
    4144    my $mt_author = MT::Author->load($entry->author_id); 
     
    5659    my $co = _create_issued($entry->authored_on, $blog); 
    5760    $atom->issued($co); 
     61    my $upd = $entry->modified_on; 
     62    if ( $upd ) { 
     63        $atom->updated( _create_issued( $upd, $blog ) ); 
     64    } 
     65    else { 
     66        $atom->updated( $co ); 
     67    } 
    5868    $atom->add_link({ rel => 'alternate', type => 'text/html', 
    5969                      href => $entry->permalink }); 
  • branches/release-34/lib/MT/AtomServer.pm

    r1818 r1820  
    710710        $feed->id($id); 
    711711    } 
     712    my $latest_date = 0; 
    712713    $uri .= '/entry_id='; 
     714    my @entries; 
    713715    while (my $entry = $iter->()) { 
    714716        my $e = $app->new_with_entry($entry); 
    715717        $e->add_link({ rel => $app->edit_link_rel, type => $app->atom_x_content_type, 
    716718                       href => ($uri . $entry->id), title => encode_text($entry->title, undef,'utf-8') }); 
    717         $feed->add_entry($e); 
    718     } 
     719        # feed/updated should be added before entries 
     720        # so we postpone adding them until later 
     721        push @entries, $e; 
     722        my $date = $entry->modified_on || $entry->authored_on; 
     723        if ( $latest_date < $date ) { 
     724            $latest_date = $date; 
     725            $feed->updated( $e->updated ); 
     726        } 
     727    } 
     728    $feed->add_entry($_) foreach @entries; 
    719729    ## xxx add next/prev links 
    720730    $app->response_content_type($app->atom_content_type);