General Actions:
Log-in
Wiki:
L3D's Wiki
▼
:
Document Index
»
Space:
Blog
▼
:
Document Index
»
Page:
Archive
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to your wiki
»
Wiki blog
»
Blog Archive
Wiki source code of
Blog Archive
Last modified by
Administrator
on 2008/12/21 19:59
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
#includeMacros("Blog.BlogCode") ## ## ## #macro(displayBlogFullArchive $blogDoc) #getBlogEntriesBaseQuery($query) #set($query = "${query} and (doc.space = '${blogDoc.space}' or doc.parent = '${blogDoc.fullName}')") ## Create a Jodatime date formatter that will be used to format dates #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("MMMM")) #set($tempDate = $xwiki.jodatime.mutableDateTime) #set($currentYear = $xwiki.formatDate($util.date, 'yyyy')) #set($currentMonth = $xwiki.formatDate($util.date, 'M')) #set($firstYear = '') #set($lastYear = '') #foreach($firstEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value)", 1, 0)) #set($discard = $xwiki.getDocument($firstEntry)) #getEntryObject($discard $entryObj) #getEntryDate($discard $entryObj $firstYear) #set($firstYear = $util.parseInt($xwiki.formatDate($firstYear, "yyyy"))) #end #foreach($lastEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value) desc", 1, 0)) #set($discard = $xwiki.getDocument($lastEntry)) #getEntryObject($discard $entryObj) #getEntryDate($discard $entryObj $lastYear) #set($lastYear = $util.parseInt($xwiki.formatDate($lastYear, "yyyy"))) #end #if("$!{firstYear}" != '') ## At least one entry exists #foreach($year in [$firstYear..$lastYear]) #set($yearArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year")) #if($yearArticleCount > 0) * <a href="$xwiki.getURL('Blog.Archive', 'view', "space=${blogDoc.space}&year=${year}")">$year ($yearArticleCount)</a> #foreach($month in [1..12]) #set($monthArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year and month(publishDate.value) = $month")) #if($monthArticleCount > 0) $tempDate.setMonthOfYear($month) ** <a href="$xwiki.getURL('Blog.Archive', 'view', "space=${blogDoc.space}&year=${year}&month=${month}")">$monthFormatter.print($tempDate) (${monthArticleCount})</a> #end #end #end #end #else #info("No articles yet...") #end #end ## ## ## #macro(displayBlogYearArchive $blogDoc $year) 1 Blog posts for $year #getBlogEntriesBaseQuery($query) #set($query = "${query} and (doc.space = '${blogDoc.space}' or doc.parent = '${blogDoc.fullName}')") #set($query = "${query} and year(publishDate.value) = $year") ## Create a Jodatime date formatter that will be used to format dates #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM')) #set($tempDate = $xwiki.jodatime.mutableDateTime) #set($yearArticleCount = $xwiki.countDocuments("${query}")) #if($yearArticleCount > 0) #foreach($month in [1..12]) #set($monthArticleCount = $xwiki.countDocuments("${query} and month(publishDate.value) = $month")) #if($monthArticleCount > 0) $tempDate.setMonthOfYear($month) 1.1 <a href="$xwiki.getURL('Blog.Archive', 'view', "space=${blogDoc.space}&year=${year}&month=${month}")">$monthFormatter.print($tempDate) (${monthArticleCount})</a> #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} and month(publishDate.value) = $month order by publishDate.value"))) #getEntryObject($entryDoc $entryObj) #isPublished($entryObj $isPublished) #isHidden($entryObj $isHidden) * <a href="$entryDoc.getURL()">$entryDoc.display('title', 'view', $entryObj)</a>#if(!$isPublished) (unpublished)#elseif($isHidden) (hidden)#end #end #end #end #else #info("No articles in this year...") #end #end ## ## ## #macro(displayBlogMonthArchive $blogDoc $year $month) #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM yyyy')) #set($tempDate = $xwiki.jodatime.mutableDateTime) $tempDate.setYear($util.parseInt($year))## $tempDate.setMonthOfYear($util.parseInt($month))## 1 Blog posts for $dateFormatter.print($tempDate) #getBlogEntriesBaseQuery($query) #set($query = "${query} and (doc.space = '${blogDoc.space}' or doc.parent = '${blogDoc.fullName}')") #set($query = "${query} and year(publishDate.value) = $year and month(publishDate.value) = $month") #set($monthArticleCount = $xwiki.countDocuments("${query}")) #if($monthArticleCount > 0) #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} order by publishDate.value"))) #getEntryObject($entryDoc $entryObj) #displayEntry($entryDoc $entryObj true) #end #else #info("No articles in this month...") #end #end ## ## ## #set($space = "$!{request.space}") #if($space == '') #set($space = 'Blog') #end #getBlogDocument($space $blogDoc) #set($month = "$!{request.month}") #set($year = "$!{request.year}") #if($year == "") ## Show a brief history of the blog, a tree with first level = years, second level = months, and the number of entries from that year/month in every node. #displayBlogFullArchive($blogDoc) #else #if($month == '') ## Show an index of all posts in this year (titles only), with month names as subtitles #displayBlogYearArchive($blogDoc $year) #else ## Show all entries in the month (extract) #displayBlogMonthArchive($blogDoc $year $month) #end #end
Quick Links
L3D Calendar
Wiki Dashboard
Document Index
Blog
Sandbox