Wiki source code of Blog category RSS Feed Generator
Last modified by Anton Bittner (Admin) on 26.11.2025
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{include reference="Blog.RssCode"/}} | ||
| 2 | |||
| 3 | {{include reference="Blog.CategoriesCode"/}} | ||
| 4 | |||
| 5 | {{velocity filter="none"}} | ||
| 6 | #if("$!{request.xpage}" == 'plain' || "$!{request.xpage}" == 'rdf') | ||
| 7 | $response.setContentType('application/rss+xml') | ||
| 8 | {{html clean="false" wiki="false"}} | ||
| 9 | ## | ||
| 10 | ## | ||
| 11 | ## | ||
| 12 | #macro(getTargetCategory $categoryDoc) | ||
| 13 | #set($category = "$!{request.category}") | ||
| 14 | #if($category == '') | ||
| 15 | #set ($categoryDoc = $doc) | ||
| 16 | ## Since 9.15, category data may exist in Blog or Blog.Categories. Code supports both paths to maintain backward compatibility. | ||
| 17 | ## This code checks whether a category exists in its original location (e.g., Blog.News). | ||
| 18 | ## If the category is not found, it assumes a migration has occurred and automatically sets the category to its new location in the Blog.Categories namespace (e.g., Blog.Categories.News). | ||
| 19 | #if (!$services.blog.hasLegacyCategoryAssignments()) | ||
| 20 | #set ($oldCategoryRef = $categoryDoc.documentReference) | ||
| 21 | ## When accessing "Blog/News?xpage=plain&sheet=Blog.CategoryRss" and the Blog.News document is missing, the current doc is Blog.News.WebHome and that needs to be translated into the migrated category Blog.Categories.News. | ||
| 22 | #if ($oldCategoryRef.name == 'WebHome') | ||
| 23 | #set ($oldCategoryRef = $categoryDoc.documentReference.parent) | ||
| 24 | #end | ||
| 25 | #set ($newCategoriesSpaceRef = $services.model.createSpaceReference('Categories', $oldCategoryRef.parent)) | ||
| 26 | #set ($newCategoryRef = $services.model.createDocumentReference($oldCategoryRef.name, $newCategoriesSpaceRef)) | ||
| 27 | #if ($xwiki.exists($newCategoryRef)) | ||
| 28 | #set ($categoryDoc = $xwiki.getDocument($newCategoryRef)) | ||
| 29 | #end | ||
| 30 | #end | ||
| 31 | #if("$!categoryDoc.getObject($blogCategoryClassname)" != '' || $categoryDoc.getObject('XWiki.DocumentSheetBinding').sheet == 'Blog.CategoriesSheet') | ||
| 32 | #set ($category = $categoryDoc.fullName) | ||
| 33 | #else | ||
| 34 | #set($category = $defaultCategoryParent) | ||
| 35 | #end | ||
| 36 | #end | ||
| 37 | #set ($categoryDoc = $NULL) | ||
| 38 | #setVariable ("$categoryDoc" $xwiki.getDocument($category)) | ||
| 39 | #end | ||
| 40 | #getTargetCategory($categoryDoc) | ||
| 41 | #set($tempCategoryDoc = $categoryDoc) | ||
| 42 | #getEntriesForCategory($tempCategoryDoc.fullName $entries $totalEntries) | ||
| 43 | #set($categoryDoc = $tempCategoryDoc) | ||
| 44 | #set($entries = $xwiki.wrapDocs($entries)) | ||
| 45 | #displayBlogCategoryRss($categoryDoc $categoryDoc $entries) | ||
| 46 | {{/html}} | ||
| 47 | #end | ||
| 48 | {{/velocity}} |