Blog Archive
Log-in
|
Blog
:
Welcome to your wiki
>
Wiki blog
>
Blog Archive
Top Menu
Show
:
Comments
Attachments
History
Information
Stampa
:
Stampa
Anteprima di stampa
Esporta come PDF
Esporta in formato RTF
Esporta come HTML
Esporta in formato XAR
Wiki source code of
Blog Archive
Hide line numbers
1: #includeMacros("Blog.BlogCode") 2: ## 3: ## 4: ## 5: #macro(displayBlogFullArchive $blogDoc) 6: #getBlogEntriesBaseQuery($query) 7: #set($query = "${query} and (doc.space = ’${blogDoc.space}’ or doc.parent = ’${blogDoc.fullName}’)") 8: ## Create a Jodatime date formatter that will be used to format dates 9: #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("MMMM")) 10: #set($tempDate = $xwiki.jodatime.mutableDateTime) 11: #set($currentYear = $xwiki.formatDate($util.date, ’yyyy’)) 12: #set($currentMonth = $xwiki.formatDate($util.date, ’M’)) 13: #set($firstYear = ’’) 14: #set($lastYear = ’’) 15: #foreach($firstEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value)", 1, 0)) 16: #set($discard = $xwiki.getDocument($firstEntry)) 17: #getEntryObject($discard $entryObj) 18: #getEntryDate($discard $entryObj $firstYear) 19: #set($firstYear = $util.parseInt($xwiki.formatDate($firstYear, "yyyy"))) 20: #end 21: #foreach($lastEntry in $xwiki.searchDocuments("${query} order by year(publishDate.value) desc", 1, 0)) 22: #set($discard = $xwiki.getDocument($lastEntry)) 23: #getEntryObject($discard $entryObj) 24: #getEntryDate($discard $entryObj $lastYear) 25: #set($lastYear = $util.parseInt($xwiki.formatDate($lastYear, "yyyy"))) 26: #end 27: #if("$!{firstYear}" != ’’) ## At least one entry exists 28: #foreach($year in [$firstYear..$lastYear]) 29: #set($yearArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year")) 30: #if($yearArticleCount > 0) 31: * <a href="$xwiki.getURL(’Blog.Archive’, ’view’, "space=${blogDoc.space}&year=${year}")">$year ($yearArticleCount)</a> 32: #foreach($month in [1..12]) 33: #set($monthArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year and month(publishDate.value) = $month")) 34: #if($monthArticleCount > 0) 35: $tempDate.setMonthOfYear($month) 36: ** <a href="$xwiki.getURL(’Blog.Archive’, ’view’, "space=${blogDoc.space}&year=${year}&month=${month}")">$monthFormatter.print($tempDate) (${monthArticleCount})</a> 37: #end 38: #end 39: #end 40: #end 41: #else 42: #info($msg.get("xe.blog.archive.noarticle")) 43: #end 44: #end 45: ## 46: ## 47: ## 48: #macro(displayBlogYearArchive $blogDoc $year) 49: 1 $msg.get("xe.blog.archive.postsyear", [$year]) 50: #getBlogEntriesBaseQuery($query) 51: #set($query = "${query} and (doc.space = ’${blogDoc.space}’ or doc.parent = ’${blogDoc.fullName}’)") 52: #set($query = "${query} and year(publishDate.value) = $year") 53: ## Create a Jodatime date formatter that will be used to format dates 54: #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern(’MMMM’)) 55: #set($tempDate = $xwiki.jodatime.mutableDateTime) 56: #set($yearArticleCount = $xwiki.countDocuments("${query}")) 57: #if($yearArticleCount > 0) 58: #foreach($month in [1..12]) 59: #set($monthArticleCount = $xwiki.countDocuments("${query} and month(publishDate.value) = $month")) 60: #if($monthArticleCount > 0) 61: $tempDate.setMonthOfYear($month) 62: 1.1 <a href="$xwiki.getURL(’Blog.Archive’, ’view’, "space=${blogDoc.space}&year=${year}&month=${month}")">$monthFormatter.print($tempDate) (${monthArticleCount})</a> 63: #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} and month(publishDate.value) = $month order by publishDate.value"))) 64: #getEntryObject($entryDoc $entryObj) 65: #isPublished($entryObj $isPublished) 66: #isHidden($entryObj $isHidden) 67: * <a href="$entryDoc.getURL()">$entryDoc.display(’title’, ’view’, $entryObj)</a>#if(!$isPublished) $msg.get("xe.blog.archive.unpublished")#elseif($isHidden) $msg.get("xe.blog.archive.hidden")#end 68: #end 69: #end 70: #end 71: #else 72: #info($msg.get("xe.blog.archive.noarticlesyear")) 73: #end 74: #end 75: ## 76: ## 77: ## 78: #macro(displayBlogMonthArchive $blogDoc $year $month) 79: #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern(’MMMM yyyy’)) 80: #set($tempDate = $xwiki.jodatime.mutableDateTime) 81: $tempDate.setYear($util.parseInt($year))## 82: $tempDate.setMonthOfYear($util.parseInt($month))## 83: 1 $msg.get("xe.blog.archive.postsfor") $dateFormatter.print($tempDate) 84: #getBlogEntriesBaseQuery($query) 85: #set($query = "${query} and (doc.space = ’${blogDoc.space}’ or doc.parent = ’${blogDoc.fullName}’)") 86: #set($query = "${query} and year(publishDate.value) = $year and month(publishDate.value) = $month") 87: #set($monthArticleCount = $xwiki.countDocuments("${query}")) 88: #if($monthArticleCount > 0) 89: #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} order by publishDate.value"))) 90: #getEntryObject($entryDoc $entryObj) 91: #displayEntry($entryDoc $entryObj true) 92: #end 93: #else 94: #info($msg.get("xe.blog.archive.noarticlesmonth")) 95: #end 96: #end 97: ## 98: ## 99: ## 100: #set($space = "$!{request.space}") 101: #if($space == ’’) 102: #set($space = ’Blog’) 103: #end 104: #getBlogDocument($space $blogDoc) 105: #set($month = "$!{request.month}") 106: #set($year = "$!{request.year}") 107: #if($year == "") 108: ## 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. 109: #displayBlogFullArchive($blogDoc) 110: #else 111: #if($month == ’’) 112: ## Show an index of all posts in this year (titles only), with month names as subtitles 113: #displayBlogYearArchive($blogDoc $year) 114: #else 115: ## Show all entries in the month (extract) 116: #displayBlogMonthArchive($blogDoc $year $month) 117: #end 118: #end
Recent Blog Posts
The first post of your wiki's blog
Blog Categories
News
(1)
Other
(0)
Personal
(0)
Blog Archive
2009
(1)
Search
Quick Links
Wiki Dashboard
Document Index
Blog
Sandbox
My Recent Modifications
dany
|
marco