Monday 22 September 2008

Atoms Moved

I've now successfully imported a 700 post blog into draft.blogger.com

There were a few more quirks of blogger.com along the way. Having next and previous links in the Atom feed causes blogger to reject the entire import file, so I ended up putting them in as comments. There were also some old posts that didn't have an author (perhaps from some beta version of Roller, and blogger rejected those due to the empty name field.
Finally, I had an old comment from the blog's early days that was not UTF-8 encoded in the database (it doesn't appear correctly in Roller either), so I had to reencode that before blogger.com would accept it for import.



Here is the final export template for Apache Roller 4.0.

#set($pager = $model.getWeblogEntriesPager())
#set($map = $pager.getEntries())
<?xml version="1.0" encoding='utf-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0">
    <id>$model.weblog.id</id>
    <title>$utils.escapeXML($model.weblog.name)</title>
    <subtitle>$utils.escapeXML($model.weblog.description)</subtitle>
    <updated>$utils.formatIso8601Date($model.weblog.lastModified)</updated>
#if ($pager.nextLink)
    <!-- link rel="next" type="application/atom+xml" href="$pager.nextLink"/ -->
#end
#if ($pager.prevLink)
    <!-- link rel="previous" type="application/atom+xml" href="$pager.prevLink"/ -->
#end
    #foreach( $day in $map.keySet())
    #set($entries = $map.get($day))
    #foreach( $entry in $entries )
    <entry>
        <id>$entry.id</id>
        <title>$utils.escapeXML($entry.title)</title>

        <author>
#if ("$entry.creator.fullName" != "")
          <name>$entry.creator.fullName</name>
#end
        </author>

        <published>$utils.formatIso8601Date($entry.pubTime)</published>
        <updated>$utils.formatIso8601Date($entry.updateTime)</updated>

        <content type="html"><![CDATA[$entry.text]]></content>
        <category scheme="http://schemas.google.com/g/2005#kind" 
              term="http://schemas.google.com/blogger/2008/kind#post"/>
 <link rel="self" type="application/atom+xml" href="http://example.com/$entry.id" />
    </entry>
        ## use Atom threading extensions for comment annotation
        #foreach( $comment in $entry.comments )
        <entry>
            <id>$comment.id</id>
            <title>$utils.escapeXML($utils.truncate($utils.removeHTML($comment.content), 40, 50, "..."))</title>

            <author>
#if ("$comment.name" != "")
                <name>$utils.escapeXML($comment.name)</name>
#end
#if ("$comment.url" != "")
                <uri>$utils.escapeXML($comment.url)</uri>
#end
#if ("$comment.email" != "")
                <email>$comment.email</email>
#end
            </author>
            <published>$utils.formatIso8601Date($comment.postTime)</published>
            <updated>$utils.formatIso8601Date($comment.postTime)</updated>
            <content>$utils.escapeXML($utils.removeHTML($comment.content))></content>
            <thr:in-reply-to ref="$entry.id" type="application/atom+xml" href="$entry.permalink"/>
            <category scheme="http://schemas.google.com/g/2005#kind" 
              term="http://schemas.google.com/blogger/2008/kind#comment"/>
     <link rel="self" type="application/atom+xml" href="http://example.com/$entry.id" />
        </entry>
        #end
    #end
    #end
</feed>

No comments: