General Actions:
Log-in
Register
Wiki:
games
▼
:
Document Index
»
Space:
Blog
▼
:
Document Index
»
Page:
Archive
Search
default
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Wiki Home
»
The Wiki Blog
»
Blog Archive
Wiki source code of
Blog Archive
Last modified by
Administrator
on 2011/11/06 20:09
Content
·
Comments
(0)
·
Annotations
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
{{include document="Blog.BlogCode"/}} {{velocity filter="none"}} {{html clean="false" wiki="true"}} ## ## ## #macro(displayBlogFullArchive $blogDoc) #getBlogEntriesBaseQuery($query) #set($query = "${query} and (doc.space = ? or doc.parent = ?)") #set ($queryParams = [$blogDoc.space, $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, $queryParams)) #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, $queryParams)) #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", $queryParams)) #if($yearArticleCount > 0) * [[$year ($yearArticleCount)>>Blog.Archive?space=${blogDoc.space}&year=${year}]] #foreach($month in [1..12]) #set($monthArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year and month(publishDate.value) = $month", $queryParams)) #if($monthArticleCount > 0) $tempDate.setMonthOfYear($month) ** [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive?space=${blogDoc.space}&year=${year}&month=${month}]] #end #end #end #end #else #info($msg.get('xe.blog.archive.noarticle')) #end #end ## ## ## #macro(displayBlogYearArchive $blogDoc $year) = $msg.get('xe.blog.archive.postsyear', [$year]) = #getBlogEntriesBaseQuery($query) #set($query = "${query} and (doc.space = ? or doc.parent = ?)") #set ($queryParams = [$blogDoc.space, $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}, $queryParams)) #if($yearArticleCount > 0) #foreach($month in [1..12]) #set($monthArticleCount = $xwiki.countDocuments("${query} and month(publishDate.value) = $month", $queryParams)) #if($monthArticleCount > 0) $tempDate.setMonthOfYear($month) == [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive?space=${blogDoc.space}&year=${year}&month=${month}]] == #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} and month(publishDate.value) = $month order by publishDate.value", $queryParams))) #getEntryObject($entryDoc $entryObj) #isPublished($entryObj $isPublished) #isHidden($entryObj $isHidden) * [[$entryDoc.display('title', 'view', $entryObj)>>$entryDoc]]#if(!$isPublished) $msg.get('xe.blog.archive.unpublished')#elseif($isHidden) $msg.get('xe.blog.archive.hidden')#end #end #end #end #else #info($msg.get('xe.blog.archive.noarticlesyear')) #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))## = $msg.get('xe.blog.archive.postsfor') $dateFormatter.print($tempDate) = #getBlogEntriesBaseQuery($query) #set($query = "${query} and (doc.space = ? or doc.parent = ?)") #set ($queryParams = [$blogDoc.space, $blogDoc.fullName]) #set($query = "${query} and year(publishDate.value) = $year and month(publishDate.value) = $month") #set($monthArticleCount = $xwiki.countDocuments(${query}, $queryParams)) #if($monthArticleCount > 0) #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} order by publishDate.value", $queryParams))) #getEntryObject($entryDoc $entryObj) #displayEntry($entryDoc $entryObj true true) #end #else #info($msg.get('xe.blog.archive.noarticlesmonth')) #end #end ## ## ## #set($space = "$!{request.space}") #if($space == '') #set($space = 'Blog') #end #getBlogDocument($space $blogDoc) #set ($month = "$!{util.parseInt($request.month)}") #set ($year = "$!{util.parseInt($request.year)}") #if ($year == '0') ## 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 == '0') ## 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 {{/html}} {{/velocity}}
Recent Blog Posts
Wedding Crashers
A New Slipknot
Getting to know you
A Falling Star
The Grand Reveal
Plans for First Flight
Akuma Crushed Beneath the Heel
Caelan Defeats the Snake Form
How Not to Win Friends and Influence People
Ancient Lunars and Frozen Fair Folk
Blog Categories
Games
(60)
Diaspora
(3)
Imperium
(7)
Selene's Flurry
(20)
News
(1)
Other
(0)
Personal
(0)
Blog Archive
2009
(1)
2011
(1)
2012
(1)