Wiki source code of Blog migration

Last modified by Administrator on 2008/12/13 17:30

Show last authors
1 #if($request.migrate)
2 #set($newContent = '#includeForm("Blog.BlogPostSheet")')
3 #set($query = ", BaseObject obj where obj.name = doc.fullName and obj.className = 'XWiki.ArticleClass'")
4 #foreach($article in $xwiki.searchDocuments($query))
5 #if($xwiki.hasAccessLevel('edit', $context.user, $article))
6 #set($articleDoc = $xwiki.getDocument($article))
7 #set($articleObj = $articleDoc.getObject('XWiki.ArticleClass'))
8 #set($entryObj = $articleDoc.newObject('Blog.BlogPostClass'))
9 #foreach($property in ['title', 'content', 'extract', 'category'])
10 $!entryObj.set($property, $articleObj.getProperty($property).value)
11 #end
12 $!entryObj.set('published', 1)
13 $!entryObj.set('publishDate', $articleDoc.creationDate)
14 $!entryObj.set('hidden', 0)
15 #set($discard = $articleDoc.removeObjects('XWiki.ArticleClass'))
16 $articleDoc.setContent($newContent)
17 $!articleDoc.save("Migrated old blog article to the new blog application", true)
18 * Updated [$entryObj.title>$article] (in space [$articleDoc.space>${articleDoc.space}.WebHome])
19 #else
20 * Skipping protected document [$article]
21 #end
22 #end
23 Done. [Back to the blog>Blog.WebHome]
24 #else
25 Please confirm that you want to migrate old articles to the new blog application:
26 <form action="$doc.getURL()" method="post">
27 <div><input type="submit" name="migrate" value="Confirm"/></div>
28 </form>
29 [Back to the blog>Blog.WebHome]
30 #end

#includeMacros("Blog.BlogCode")
#getBlogEntriesBaseQuery($query)
#set($query = "$!{query} and isPublished.value = 1")
#set($recentEntries = $xwiki.searchDocuments("${query} order by publishDate.value desc", 10, 0))
#if($recentEntries.size() > 0 || $showEmptyPanels)
  #panelheader('Recent Blog Posts')
  #foreach($entryDoc in $xwiki.wrapDocs($recentEntries))
    #getEntryObject($entryDoc $entryObj)

  • [$!{entryDoc.display('title', 'view', $entryObj)}>$!{entryDoc.fullName}]
      #end
      #panelfooter()
    #end

#includeMacros("Blog.BlogCode")
#getBlogEntriesBaseQuery($query)
#set($query = "$!{query} and isPublished.value = 0")
#set($unpublishedEntries = $xwiki.searchDocuments("${query} order by publishDate.value desc", 5, 0))
#if($unpublishedEntries.size() > 0 || $showEmptyPanels)
  #panelheader("Unpublished Posts")
  #foreach($entryDoc in $xwiki.wrapDocs($unpublishedEntries))
    #getEntryObject($entryDoc $entryObj)

  • [$!{entryDoc.display('title', 'view', $entryObj)}>$!{entryDoc.fullName}]
      #end
      [View all ($xwiki.countDocuments($query))>Blog.Unpublished]
      #panelfooter()
    #end

#includeMacros("Blog.CategoriesCode")
#panelheader('Blog Categories')
#getCategoriesHierarchy('Blog' $tree)
#displayCategoriesHierarchy($tree 'simple')
#if($xwiki.hasAdminRights())
  <div style="font-size:75%;">(<a href="$xwiki.getURL('Blog.ManageCategories')">Edit Categories</a>)</div>
#end
#panelfooter()

{{include reference="Blog.BlogCode"/}}

{{velocity}} #getAllBlogPostsQueryBasedOnDisplayContext($doc $query $queryParams) #bindQueryParameters($queryObj $queryParams) {{/velocity}}