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
Hide line numbers
1: {{include document="Blog.BlogCode"/}} 2: 3: {{velocity filter="none"}} 4: {{html clean="false" wiki="true"}} 5: ## 6: ## 7: ## 8: #macro(displayBlogFullArchive $blogDoc) 9: #getBlogEntriesBaseQuery($query) 10: #set($query = "${query} and (doc.space = ? or doc.parent = ?)") 11: #set ($queryParams = [$blogDoc.space, $blogDoc.fullName]) 12: ## Create a Jodatime date formatter that will be used to format dates 13: #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM')) 14: #set($tempDate = $xwiki.jodatime.mutableDateTime) 15: #set($currentYear = $xwiki.formatDate($util.date, 'yyyy')) 16: #set($currentMonth = $xwiki.formatDate($util.date, 'M')) 17: #set($firstYear = '') 18: #set($lastYear = '') 19: #foreach($firstEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value)", 1, 0, $queryParams)) 20: #set($discard = $xwiki.getDocument($firstEntry)) 21: #getEntryObject($discard $entryObj) 22: #getEntryDate($discard $entryObj $firstYear) 23: #set($firstYear = $util.parseInt($xwiki.formatDate($firstYear, 'yyyy'))) 24: #end 25: #foreach($lastEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value) desc", 1, 0, $queryParams)) 26: #set($discard = $xwiki.getDocument($lastEntry)) 27: #getEntryObject($discard $entryObj) 28: #getEntryDate($discard $entryObj $lastYear) 29: #set($lastYear = $util.parseInt($xwiki.formatDate($lastYear, 'yyyy'))) 30: #end 31: #if("$!{firstYear}" != '') ## At least one entry exists 32: #foreach($year in [$firstYear..$lastYear]) 33: #set($yearArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year", $queryParams)) 34: #if($yearArticleCount > 0) 35: * [[$year ($yearArticleCount)>>Blog.Archive?space=${blogDoc.space}&year=${year}]] 36: #foreach($month in [1..12]) 37: #set($monthArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year and month(publishDate.value) = $month", $queryParams)) 38: #if($monthArticleCount > 0) 39: $tempDate.setMonthOfYear($month) 40: ** [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive?space=${blogDoc.space}&year=${year}&month=${month}]] 41: #end 42: #end 43: #end 44: #end 45: #else 46: #info($msg.get('xe.blog.archive.noarticle')) 47: #end 48: #end 49: ## 50: ## 51: ## 52: #macro(displayBlogYearArchive $blogDoc $year) 53: = $msg.get('xe.blog.archive.postsyear', [$year]) = 54: #getBlogEntriesBaseQuery($query) 55: #set($query = "${query} and (doc.space = ? or doc.parent = ?)") 56: #set ($queryParams = [$blogDoc.space, $blogDoc.fullName]) 57: #set($query = "${query} and year(publishDate.value) = $year") 58: ## Create a Jodatime date formatter that will be used to format dates 59: #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM')) 60: #set($tempDate = $xwiki.jodatime.mutableDateTime) 61: #set($yearArticleCount = $xwiki.countDocuments(${query}, $queryParams)) 62: #if($yearArticleCount > 0) 63: #foreach($month in [1..12]) 64: #set($monthArticleCount = $xwiki.countDocuments("${query} and month(publishDate.value) = $month", $queryParams)) 65: #if($monthArticleCount > 0) 66: $tempDate.setMonthOfYear($month) 67: == [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive?space=${blogDoc.space}&year=${year}&month=${month}]] == 68: #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} and month(publishDate.value) = $month order by publishDate.value", $queryParams))) 69: #getEntryObject($entryDoc $entryObj) 70: #isPublished($entryObj $isPublished) 71: #isHidden($entryObj $isHidden) 72: * [[$entryDoc.display('title', 'view', $entryObj)>>$entryDoc]]#if(!$isPublished) $msg.get('xe.blog.archive.unpublished')#elseif($isHidden) $msg.get('xe.blog.archive.hidden')#end 73: 74: #end 75: #end 76: #end 77: #else 78: #info($msg.get('xe.blog.archive.noarticlesyear')) 79: #end 80: #end 81: ## 82: ## 83: ## 84: #macro(displayBlogMonthArchive $blogDoc $year $month) 85: #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM yyyy')) 86: #set($tempDate = $xwiki.jodatime.mutableDateTime) 87: $tempDate.setYear($util.parseInt($year))## 88: $tempDate.setMonthOfYear($util.parseInt($month))## 89: = $msg.get('xe.blog.archive.postsfor') $dateFormatter.print($tempDate) = 90: #getBlogEntriesBaseQuery($query) 91: #set($query = "${query} and (doc.space = ? or doc.parent = ?)") 92: #set ($queryParams = [$blogDoc.space, $blogDoc.fullName]) 93: #set($query = "${query} and year(publishDate.value) = $year and month(publishDate.value) = $month") 94: #set($monthArticleCount = $xwiki.countDocuments(${query}, $queryParams)) 95: #if($monthArticleCount > 0) 96: #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} order by publishDate.value", $queryParams))) 97: #getEntryObject($entryDoc $entryObj) 98: #displayEntry($entryDoc $entryObj true true) 99: #end 100: #else 101: #info($msg.get('xe.blog.archive.noarticlesmonth')) 102: #end 103: #end 104: ## 105: ## 106: ## 107: #set($space = "$!{request.space}") 108: #if($space == '') 109: #set($space = 'Blog') 110: #end 111: #getBlogDocument($space $blogDoc) 112: #set ($month = "$!{util.parseInt($request.month)}") 113: #set ($year = "$!{util.parseInt($request.year)}") 114: #if ($year == '0') 115: ## 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. 116: #displayBlogFullArchive($blogDoc) 117: #else 118: #if ($month == '0') 119: ## Show an index of all posts in this year (titles only), with month names as subtitles 120: #displayBlogYearArchive($blogDoc $year) 121: #else 122: ## Show all entries in the month (extract) 123: #displayBlogMonthArchive($blogDoc $year $month) 124: #end 125: #end 126: {{/html}} 127: {{/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)