General Actions:
Log-in
Wiki:
Courses
▼
:
Document Index
»
Space:
Blog
▼
:
Document Index
»
Page:
BlogCode
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to L3D's XWiki for Courses
»
The Wiki Blog
»
Macros for the Blog application
Wiki source code of
Macros for the Blog application
Last modified by
Hal Eden
on 2010/08/22 20:09
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: {{include document="Blog.BlogParameters"/}} 2: 3: {{velocity output="false"}} 4: ## 5: ## 6: ## 7: ## Import the blog skin and javascripts. 8: $!xwiki.ssx.use($blogStyleDocumentName)## 9: $!xwiki.jsx.use($blogScriptsDocumentName)## 10: ## 11: ## 12: ## 13: #** 14: * Prints a blog. This is the main macro used in the BlogSheet. 15: * 16: * @param blogDoc the XDocument holding the blog definition object. 17: *### 18: #macro(printBlog $blogDoc) 19: {{include document='Blog.CreatePost'/}} 20: #getBlogEntries($blogDoc $entries) 21: #displayBlog($entries 'index' true true) 22: #displayNavigationLinks($blogDoc) 23: #end 24: ## 25: ## 26: ## 27: #** 28: * Shows blog information. In view mode, the description is printed. In inline edit mode, allows changing 29: * blog settings: title, description, blog type (global or in-space), index display type (fixed size pagination, weekly 30: * index, monthly index, all entries). 31: * 32: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 33: *### 34: #macro(showBlogInfo $blogDoc) 35: #if($blogDoc.getObject($blogClassname)) 36: #if($context.action == 'inline') 37: #macro(displayProperty $blogDoc $propname) 38: <dt>#displayPropName($xwiki.getClass($blogClassname).get($propname)):</dt> 39: <dd>$blogDoc.display($propname)</dd> 40: #end 41: <dl> 42: #displayProperty($blogDoc 'title') 43: #displayProperty($blogDoc 'description') 44: #displayProperty($blogDoc 'blogType') 45: #displayProperty($blogDoc 'displayType') 46: #displayProperty($blogDoc 'itemsPerPage') 47: </dl> 48: #else 49: $blogDoc.display('description') 50: #end 51: #elseif($doc.fullName == $blogSheet) 52: = $msg.get('xe.blog.code.blogsheet') = 53: $msg.get('xe.blog.code.sheetexplanation') 54: #else 55: #warning($msg.get('xe.blog.code.notblog')) 56: #end 57: #end 58: ## 59: ## 60: ## 61: #** 62: * Retrieve the blog document, which usually is either <tt><Space>.WebHome</tt> for whole-spaces blogs, or 63: * <tt><Space>.Blog</tt> for in-space blogs. If none of these documents contains a blog object, then the first 64: * (alphabetically) document in the target space that contains one is returned. Finally, if no document in the current 65: * space contains a blog object, then <tt>Blog.WebHome</tt> is returned as the default blog. 66: * 67: * @param space A <tt>String</tt>, the name of the space where to search. 68: * @param blogDoc The resulting XDocument. 69: *### 70: #macro(getBlogDocument $space $blogDoc) 71: ## First, try the Space.WebHome, for a whole-space blog 72: #set($blogDoc = $xwiki.getDocument("${space}.WebHome")) 73: #if(!$blogDoc.getObject($blogClassname)) 74: ## Second, try the Space.Blog document 75: #set($blogDoc = $xwiki.getDocument("${space}.Blog")) 76: #if(!$blogDoc.getObject($blogClassname)) 77: ## Third, try searching for a blog document in the current space 78: #set($blogDocs = $xwiki.searchDocuments(", BaseObject obj where doc.space = ? and obj.name = doc.fullName and obj.className = '$blogClassname' order by doc.name", 1, 0, [${space}])) 79: #if($blogDocs.size() > 0) 80: #set($blogDoc = $xwiki.getDocument($blogDocs.get(0))) 81: #else 82: ## Last, fallback to Blog.WebHome, the default blog 83: #set($blogDoc = $xwiki.getDocument('Blog.WebHome')) 84: #end 85: #end 86: #end 87: #end 88: ## 89: ## 90: ## 91: #** 92: * Retrieve the blog title. 93: * 94: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass<tt> object with the <tt>title</tt> property set. 95: * @param title The resulting title. 96: *### 97: #macro(getBlogTitle $blogDoc $title) 98: #getBlogProperty($blogDoc 'title' $!blogDoc.displayTitle $title) 99: #end 100: ## 101: ## 102: ## 103: #** 104: * Retrieve the blog description. 105: * 106: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>description</tt> 107: * property set. 108: * @param description The resulting description. 109: *### 110: #macro(getBlogDescription $blogDoc $description) 111: #getBlogProperty($blogDoc 'description' '' $description) 112: #end 113: ## 114: ## 115: ## 116: #** 117: * Retrieves a list of entries to be displayed. The entries are either part of the blog's space, or have the blog 118: * document set as a parent. The number and range of entries returned (from all those belonging to this blog) depends on 119: * the blog display type: paginated (fixed number of entries), weekly (all entries in a week), monthly (all entries in a 120: * month), or all. 121: * 122: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 123: * @param entries The resulting list of entries to display, a list of XDocument names. 124: *### 125: #macro(getBlogEntries $blogDoc $entries) 126: #getBlogEntriesBaseQuery($query) 127: #isBlogGlobal($blogDoc $isGlobal) 128: #if(!$isGlobal) 129: #set($query = "${query} and (doc.space = '${blogDoc.space}' or doc.parent = '${blogDoc.fullName}')") 130: #end 131: #getBlogDisplayType($blogDoc $displayType) 132: #if($displayType == 'weekly') 133: #getWeeklyBlogEntries($blogDoc $query $entries) 134: #elseif($displayType == 'monthly') 135: #getMonthlyBlogEntries($blogDoc $query $entries) 136: #elseif($displayType == 'all') 137: #getAllBlogEntries($blogDoc $query $entries) 138: #else 139: #getPagedBlogEntries($blogDoc $query $entries) 140: #end 141: #end 142: ## 143: ## 144: ## 145: #** 146: * Retrieves a list of entries to be displayed. The entries are taken from a "page" of the blog, a sequence of documents 147: * defined by the request parameters <tt>ipp</tt> (items per page) and <tt>page</tt> (the current page). Initially the 148: * first page is displayed, with the number of entries defined in the blog object in the <tt>itemsPerPage</tt> property 149: * (10 if not defined). 150: * 151: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 152: * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be 153: * refined to restrict to a given space, or to a given search criteria, etc. 154: * @param entries The resulting list of entries to display, a list of XDocument names. 155: *### 156: #macro(getPagedBlogEntries $blogDoc $query $entries) 157: #set($totalEntries = $xwiki.countDocuments(${query})) 158: #getBlogProperty($blogDoc 'itemsPerPage' '10' $defaultItemsPerPage) 159: #set($defaultItemsPerPage = $util.parseInt($defaultItemsPerPage)) 160: ## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. 161: #preparePagedViewParams($totalEntries $defaultItemsPerPage) 162: #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc", $itemsPerPage, $startAt)) 163: #end 164: ## 165: ## 166: ## 167: #** 168: * Retrieves a list of entries to be displayed. The entries are taken from a week of the blog. The target week is 169: * defined by the request parameters <tt>week</tt> (the week number in the year, from 1 to 52) and <tt>year</tt> (4 170: * digit year). Initially the current week is displayed. 171: * 172: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 173: * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be 174: * refined to restrict to a given space, or to a given search criteria, etc. 175: * @param entries The resulting list of entries to display, a list of XDocument names. 176: *### 177: #macro(getWeeklyBlogEntries $blogDoc $query $entries) 178: #getRequestedWeek($weekDate) 179: #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('yyyy-MM-dd')) 180: #set($minDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundFloor())) 181: #set($maxDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundCeiling())) 182: #set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'") 183: #set($totalEntries = $xwiki.countDocuments(${query})) 184: #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) 185: #end 186: ## 187: ## 188: ## 189: #** 190: * Retrieves a list of entries to be displayed. The entries are taken from a month of the blog. The target month is 191: * defined by the request parameters <tt>month</tt> (the month number, from 1 to 12) and <tt>year</tt> (4 192: * digit year). Initially the current month is displayed. 193: * 194: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 195: * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be 196: * refined to restrict to a given space, or to a given search criteria, etc. 197: * @param entries The resulting list of entries to display, a list of XDocument names. 198: *### 199: #macro(getMonthlyBlogEntries $blogDoc $query $entries) 200: #getRequestedMonth($monthDate) 201: #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('yyyy-MM-dd')) 202: #set($minDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundFloor())) 203: #set($maxDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundCeiling())) 204: #set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'") 205: #set($totalEntries = $xwiki.countDocuments(${query})) 206: #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) 207: #end 208: ## 209: ## 210: ## 211: #** 212: * Retrieves a list of entries to be displayed. All entries belonging to the current blog are returned. 213: * 214: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 215: * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be 216: * refined to restrict to a given space, or to a given search criteria, etc. 217: * @param entries The resulting list of entries to display, a list of XDocument names. 218: *### 219: #macro(getAllBlogEntries $blogDoc $query $entries) 220: #set($totalEntries = $xwiki.countDocuments(${query})) 221: #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) 222: #end 223: ## 224: ## 225: ## 226: #** 227: * Retrieves a list of entries to be displayed. Only (and all) unpublished entries are returned. 228: * 229: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 230: * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be 231: * refined to restrict to a given space, or to a given search criteria, etc. 232: * @param entries The resulting list of entries to display, a list of XDocument names. 233: *### 234: #macro(getUnpublishedBlogEntries $blogDoc $query $entries) 235: #set($query = "${query} and isPublished.value = 0") 236: #set($totalEntries = $xwiki.countDocuments(${query})) 237: #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) 238: #end 239: ## 240: ## 241: ## 242: #** 243: * Retrieves a list of entries to be displayed. The entries are taken from all the wiki, and not from a specific blog. 244: * 245: * @param entries The resulting list of entries to display, a list of XDocument names. 246: *### 247: #macro(getGlobalBlogEntries $entries) 248: #getBlogEntriesBaseQuery($query) 249: #set($totalEntries = $xwiki.countDocuments(${query})) 250: #set($defaultItemsPerPage = 20) 251: ## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. 252: #preparePagedViewParams($totalEntries $defaultItemsPerPage) 253: #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc", $itemsPerPage, $startAt)) 254: #end 255: ## 256: ## 257: ## 258: #** 259: * Return the base query for selecting blog entries. It filters only visible entries, but does not bind to a specific 260: * blog, nor specify a range or an ordering criteria. 261: * 262: * @param query The basic query for selecting blog entries. 263: *### 264: #macro(getBlogEntriesBaseQuery $query) 265: #set ($query = ", BaseObject obj, IntegerProperty isPublished, IntegerProperty hidden, DateProperty publishDate 266: where doc.fullName <> '${blogPostTemplate}' and 267: obj.name = doc.fullName and obj.className = '${blogPostClassname}' and 268: publishDate.id.id = obj.id and publishDate.id.name = 'publishDate' and 269: isPublished.id.id = obj.id and isPublished.id.name = 'published' and 270: hidden.id.id = obj.id and hidden.id.name = 'hidden' and 271: (doc.creator = '$context.user' or (isPublished.value = 1 and hidden.value = 0))") 272: #end 273: ## 274: ## 275: ## 276: #** 277: * Checks if the provided blog is global or in-space. 278: * 279: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>blogType</tt> property set. 280: * @param isGlobal The resulting boolean. If the blog object does not define anything, it is considered in-space. 281: *### 282: #macro(isBlogGlobal $blogDoc $isGlobal) 283: #set($isGlobal = false) 284: #getBlogProperty($blogDoc 'blogType' '' $discard) 285: #if($discard == 'global') 286: #set($isGlobal = true) 287: #end 288: #end 289: ## 290: ## 291: ## 292: #** 293: * Determines how is the blog index split into pages: paginated (fixed number of entries), weekly (all entries in a 294: * week), monthly (all entries in a month), or all. 295: * 296: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>displayType</tt> 297: * property set. 298: * @param displayType The resulting string. If the blog object does not define anything, it is considered paginated. 299: *### 300: #macro(getBlogDisplayType $blogDoc $displayType) 301: #getBlogProperty($blogDoc 'displayType' 'paginated' $displayType) 302: #end 303: ## 304: ## 305: ## 306: #** 307: * Displays a list of entries. 308: * 309: * @param entries The entries to display, a list of XDocument names. 310: * @param displaying What exactly is displayed: blog index, a single blog entry, a blog category, search results, 311: * unpublished entries, etc. This will be used as the classname(s) for the container div (hfeed). Currently 312: * used values: index, single, category, search, unpublished, hidden. 313: * @param onlyExtract If <tt>true</tt>, only display the extract of articles where available, otherwise display the full content. 314: * @param shouldDisplayTitles If <tt>true</tt>, display the blog title (blog posts shouldn't display the title when they're 315: * displayed alone on their page since it's the page title which is used in this case) 316: *### 317: #macro(displayBlog $entries $displaying $onlyExtract $shouldDisplayTitles) 318: #set($blogDay = '') 319: <div class="hfeed $!{displaying}"> 320: <div class="blogDay"> 321: #foreach ($entryDoc in $xwiki.wrapDocs($entries)) 322: #getEntryObject($entryDoc $entryObj) 323: ## Although all entries should have one of the two objects, better check to be sure. 324: #if("$!{entryObj}" != '') 325: #getEntryDate($entryDoc $entryObj $entryDate) 326: ## Display a "calendar sheet" for each day. All entries posted on the same day share one such sheet. 327: #set($entryDateStr = $xwiki.formatDate($entryDate, 'yyyyMMMMdd')) 328: #if($blogDay != $entryDateStr) 329: #if($blogDay != '') 330: </div> 331: <div class="blogDay"> 332: #end 333: #displayBlogDate($entryDate) 334: #set ($blogDay = $entryDateStr) 335: #end 336: ## Finally, display the entry. 337: #displayEntry($entryDoc $entryObj $onlyExtract $shouldDisplayTitles) 338: #end 339: #end 340: </div> ## blogDay 341: </div> ## hfeed 342: #end 343: ## 344: ## 345: ## 346: #** 347: * Get the entry object, either a new BlogPost or an old Article. 348: * 349: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 350: * @param entryObj The resulting xobject of the blog post. 351: *### 352: #macro(getEntryObject $entryDoc $entryObj) 353: #set($entryObj = '') 354: #set($entryObj = $entryDoc.getObject("${blogPostClassname}")) 355: #if("$!{entryObj}" == '') 356: #set($entryObj = $entryDoc.getObject("${oldArticleClassname}")) 357: #end 358: #end 359: ## 360: ## 361: ## 362: #** 363: * Gets the date associated with a blog entry. This is the publication date. For unpublished entries, initially this is 364: * the document creation date, but can be edited by the user. 365: * 366: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 367: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 368: * @param result The resulting date, an instance of <tt>java.util.Date</tt>. 369: *### 370: #macro(getEntryDate $entryDoc $entryObj $result) 371: #set($result = $entryObj.getProperty('publishDate').value) 372: #end 373: ## 374: ## 375: ## 376: #** 377: * Displays a date, nicely formatted as a calendar page. 378: * 379: * @param date The date to display, an instance of <tt>java.util.Date</tt>. 380: *### 381: #macro(displayBlogDate $date) 382: #set($year = $xwiki.formatDate($date, 'yyyy')) 383: ## 3 letter month name, like Jan, Dec. 384: #set($month = $xwiki.formatDate($date, 'MMM')) 385: ## Uncomment to get a full length month name, like January, December. 386: ## TODO: this could be defined somewhere in the blog style. 387: ## #set($month = $xwiki.formatDate($date, 'MMMM')) 388: #set($day = $xwiki.formatDate($date, 'dd')) 389: <h2 class="blogdate">## title="#formatdateISO($date)"> 390: <span class="month">$month</span> 391: <span class="day">$day</span> 392: <span class="year">$year</span> 393: </h2> 394: #end 395: ## 396: ## 397: ## 398: #** 399: * Displays a blog article: management tools, header, content, footer. 400: * 401: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 402: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 403: * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content. 404: * @param shouldDisplayTitle If <tt>true</tt>, display the blog title (blog posts shouldn't display the title 405: * when they're displayed alone on their page since it's the page title which is used in this case) 406: *### 407: #macro(displayEntry $entryDoc $entryObj $onlyExtract $shouldDisplayTitle) 408: ## Only articles with an explicit hidden setting or an explicit unpublished setting are hidden 409: #isPublished($entryObj $isPublished) 410: #isHidden($entryObj $isHidden) 411: #if($doc.fullName == $entryDoc.fullName) 412: <div class="hentry single-article"> 413: #else 414: <div class="hentry#if(!$isPublished) unpublished-article#elseif($isHidden) hidden-article#end"> 415: #end 416: #displayEntryTools($entryDoc $entryObj) 417: #if($shouldDisplayTitle) 418: #displayEntryTitle($entryDoc $entryObj) 419: #end 420: #if($doc.fullName == $entryDoc.fullName) 421: #if(!$isPublished) 422: #warning($msg.get('xe.blog.code.published')) 423: #elseif($isHidden) 424: #warning($msg.get('xe.blog.code.hidden')) 425: #end 426: #end 427: #displayEntryContent($entryDoc $entryObj $onlyExtract) 428: #displayEntryFooter($entryDoc $entryObj) 429: </div> ## hentry 430: #end 431: ## 432: ## 433: ## 434: #** 435: * Checks if the provided blog is published or not. 436: * 437: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 438: * @param isPublished The resulting boolean, true if the entry is considered published. 439: *### 440: #macro(isPublished $entryObj $isPublished) 441: ## This should work for both old articles, which don't have the 'published' property at all, and 442: ## are considered published by default, and new entries, that should have 1 if published. 443: #set($isPublished = ("$!{entryObj.getProperty('published').value}" != '0')) 444: #end 445: ## 446: ## 447: ## 448: #** 449: * Checks if the provided blog is hidden or not. 450: * 451: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass<tt> xclass. 452: * @param isHiddel The resulting boolean, true if the entry is considered hidden. 453: *### 454: #macro(isHidden $entryObj $isHidden) 455: ## This should work for both old articles, which don't have the 'hidden' property at all, and 456: ## are considered visible by default, and new entries, that should have 1 if hidden. 457: #set($isHidden = ("$!{entryObj.getProperty('hidden').value}" == '1')) 458: #end 459: ## 460: ## 461: ## 462: #** 463: * Displays several "tools" for manipulating blog posts: hide/show, publish, edit. 464: * 465: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 466: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 467: *### 468: #macro(displayEntryTools $entryDoc $entryObj) 469: #if($context.action == 'view') 470: {{html wiki="false"}} 471: <div class="blog-entry-toolbox"> 472: #displayPublishButton($entryDoc $entryObj) 473: #displayHideShowButton($entryDoc $entryObj) 474: #displayEditButton($entryDoc $entryObj) 475: #displayDeleteButton($entryDoc $entryObj) 476: </div> 477: {{/html}} 478: #end 479: #end 480: ## 481: ## 482: ## 483: #** 484: * Displays the publish button to the entry <strong>creator</strong>, if the article is not published yet. 485: * 486: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 487: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 488: * @todo AJAX calls. 489: *### 490: #macro(displayPublishButton $entryDoc $entryObj) 491: #isPublished($entryObj $isPublished) 492: #if(!$isPublished && $entryDoc.creator == $context.user && $xwiki.hasAccessLevel('edit', $context.user, $entryDoc.fullName)) 493: <a href="$blogPublisher.getURL('view', "entryName=${escapetool.url($entryDoc.fullName)}&xredirect=${escapetool.url($thisURL)}")" title="${escapetool.xml($msg.get('xe.blog.code.notpublished'))}">#toolImage('page_white_world' 'publish ')</a>## 494: #end 495: #end 496: ## 497: ## 498: ## 499: #** 500: * Displays the hide or show button to the entry <strong>creator</strong>, if the article is already published. 501: * 502: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 503: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 504: *### 505: #macro(displayHideShowButton $entryDoc $entryObj) 506: #isPublished($entryObj $isPublished) 507: #isHidden($entryObj $isHidden) 508: ## Only published articles can be hidden. Unpublished articles are considered already hidden. 509: #if($isPublished && $entryDoc.creator == $context.user && $xwiki.hasAccessLevel('edit', $context.user, $entryDoc.fullName)) 510: #if ($isHidden) 511: <a class="blog-tool-show" href="$entryDoc.getURL('save', "${entryObj.getxWikiClass().getName()}_${entryObj.number}_hidden=0&comment=${escapetool.url($msg.get('xe.blog.code.madevisible'))}&xredirect=${escapetool.url($thisURL)}")" title="${escapetool.xml($msg.get('xe.blog.code.makevisible'))}">#toolImage('lock_open', 'show ')</a>## 512: #else 513: <a class="blog-tool-hide" href="$entryDoc.getURL('save', "${entryObj.getxWikiClass().getName()}_${entryObj.number}_hidden=1&comment=${escapetool.url($msg.get('xe.blog.code.hid'))}&xredirect=${escapetool.url($thisURL)}")" title="${escapetool.xml($msg.get('xe.blog.code.hide'))}">#toolImage('lock' 'hide ')</a>## 514: #end 515: #end 516: #end 517: ## 518: ## 519: ## 520: #** 521: * Displays the edit button to those that can edit the article. 522: * 523: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 524: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 525: *### 526: #macro(displayEditButton $entryDoc $entryObj) 527: #if($xwiki.hasAccessLevel('edit', $context.user, $entryDoc.fullName)) 528: <a href="$entryDoc.getURL('inline')" title="${escapetool.xml($msg.get('xe.blog.code.editpost'))}">#toolImage('pencil' 'edit ')</a>## 529: #end 530: #end 531: ## 532: ## 533: ## 534: #** 535: * Displays the delete button to those that can edit the article. 536: * 537: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 538: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 539: * @todo AJAX calls. 540: *### 541: #macro(displayDeleteButton $entryDoc $entryObj) 542: #if($xwiki.hasAccessLevel('delete', $context.user, $entryDoc.fullName)) 543: <a href="$entryDoc.getURL('delete')" title="${escapetool.xml($msg.get('xe.blog.code.deletepost'))}">#toolImage('cross' 'delete ')</a>## 544: #end 545: #end 546: ## 547: ## 548: ## 549: #** 550: * Displays the title of the entry. 551: * 552: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 553: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 554: *### 555: #macro(displayEntryTitle $entryDoc $entryObj) 556: {{html wiki="false"}} 557: #if($doc.fullName == $entryDoc.fullName) 558: <h1 class="entry-title">$entryDoc.display('title', 'view', $entryObj)</h1> 559: #else 560: <h3 class="entry-title"><a href="$entryDoc.getURL()">$entryDoc.display('title', 'view', $entryObj)</a></h3> 561: #end 562: {{/html}} 563: #end 564: ## 565: ## 566: ## 567: #** 568: * Displays the body of the entry. 569: * 570: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 571: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 572: * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content. 573: *### 574: #macro(displayEntryContent $entryDoc $entryObj $onlyExtract) 575: #set($entryContent = '') 576: <div class="#if($onlyExtract)entry-summary#{else}entry-content#end"> 577: #getEntryContent($entryDoc $entryObj $onlyExtract $entryContent) 578: {{html wiki="false"}}$entryDoc.getRenderedContent($entryContent, $entryDoc.getSyntax().toIdString()){{/html}} 579: </div> ## entry-content 580: #end 581: ## 582: ## 583: ## 584: #** 585: * Extracts the body of the entry that should be displayed. If <tt>onlyExtract</tt> is <tt>true</tt>, display the content 586: * of the <tt>extract</tt> field (if not empty). 587: * 588: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 589: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 590: * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content. 591: * @param entryContent The resulting content. 592: *### 593: #macro(getEntryContent $entryDoc $entryObj $onlyExtract $entryContent) 594: #if($onlyExtract) 595: #set($entryContent = $entryObj.getProperty('extract').value) 596: #end 597: #if("$!entryContent" == '') 598: #set($entryContent = $entryObj.getProperty('content').value) 599: #* Disabled until the content can be cleanly cut. 600: * #if($onlyExtract && $content.length()>$maxchars) 601: * #set($i = $content.lastIndexOf(" ", $maxchars)) 602: * #set($i = $i + 1) 603: * #set($content = "${content.substring(0,$i)} *[...>${entryDoc.fullName}]*") 604: * #end 605: ## *### 606: #else 607: #if($entryDoc.syntax == 'xwiki/1.0') 608: #set($entryContent = "${entryContent} <a href='${entryDoc.getURL()}' title='$msg.get('xe.blog.code.readpost')'>...</a>") 609: #else 610: #set($entryContent = "${entryContent} [[...>>${entryDoc}||title='$msg.get('xe.blog.code.readpost')']]") 611: #end 612: #end 613: #end 614: ## 615: ## 616: ## 617: #** 618: * Displays the footer of the entry. 619: * 620: * @param entryDoc The xdocument of the blog post. Each post resides in its own document. 621: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 622: *### 623: #macro(displayEntryFooter $entryDoc $entryObj) 624: {{html wiki="false"}} 625: <div class="entry-footer"> 626: #isPublished($entryObj $isPublished) 627: #if($isPublished) 628: $msg.get('xe.blog.code.postedby') ## 629: #else 630: $msg.get('xe.blog.code.createdby') ## 631: #end 632: <address class="author vcard">#userfn($entryDoc.creator)</address> ## 633: #getEntryDate($entryDoc $entryObj $entryDate) 634: #listCategories($entryObj) ## 635: ## Since the publish date and update date are not set at the exact same time, there could be a small difference that 636: ## we assume cannot be more than 3 seconds. 637: | <a href="$entryDoc.getURL('view')" rel="bookmark">$msg.get('xe.blog.code.permalink')</a> ## 638: | <a href="$entryDoc.getURL('view', '#Comments')">$entryDoc.comments.size() $msg.get('xe.blog.code.comments')</a> ## 639: </div> ## entry-footer 640: {{/html}} 641: #end 642: ## 643: ## 644: ## 645: #** 646: * List the categories an entry belongs to. Used in the footer. The categories are instances of <tt>Blog.CategoryClass</tt>. 647: * 648: * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. 649: *### 650: #macro(listCategories $entryObj) 651: #if($entryObj.getxWikiClass().getName() == $blogPostClassname) 652: #set($categories = $entryObj.getProperty('category').value) 653: #set($first = true) 654: #if($categories.size() > 0) 655: #foreach($category in $categories) 656: ## Do not indent 657: #set($categoryDoc = $!xwiki.getDocument($category)) 658: #if(!$categoryDoc.isNew() && $categoryDoc.getObject(${blogCategoryClassname})) 659: #if($first) 660: | $msg.get('xe.blog.code.categories') 661: #set($first = false) 662: #else, #end## if first 663: <a rel="tag" href="$xwiki.getURL(${category})">$!{escapetool.xml($!xwiki.getDocument($category).getObject($blogCategoryClassname).getProperty('name').value)}</a>## 664: #end## if isNew 665: #end## foreach 666: #end 667: #end 668: #end 669: ## 670: ## 671: ## 672: #** 673: * Displays blog pagination links (older and newer entries). 674: * 675: * @param blogDoc the XDocument holding the blog definition object. 676: *### 677: #macro(displayNavigationLinks $blogDoc) 678: <div class="clearfloats"></div> 679: #getBlogDisplayType($blogDoc $displayType) 680: #if($displayType == 'weekly') 681: <div class="pagingLinks"> 682: #getRequestedWeek($weekDate) 683: $weekDate.addWeeks(-1)## 684: (% class="prevPage" %)**[[« $msg.get('xe.blog.code.previousweek')>>$doc.name?year=$weekDate.weekyear&week=$weekDate.weekOfWeekyear]]**(%%) 685: #sep() 686: $weekDate.addWeeks(2)## 2 because we already subtracted 1 above 687: (% class="nextPage" %)**[[$msg.get('xe.blog.code.nextweek') »>>$doc.name?year=$weekDate.weekyear&week=$weekDate.weekOfWeekyear]]**(%%) 688: </div> 689: #elseif($displayType == 'monthly') 690: <div class="pagingLinks"> 691: #getRequestedMonth($monthDate) 692: $monthDate.addMonths(-1)## 693: (% class="prevPage" %)**[[« $msg.get('xe.blog.code.previousmonth')>>$doc.name?year=$monthDate.year&month=$monthDate.monthOfYear]]**(%%) 694: #sep() 695: $monthDate.addMonths(2)## 2 because we already subtracted 1 above 696: (% class="nextPage" %)**[[$msg.get('xe.blog.code.nextmonth') »>>$doc.name?year=$monthDate.year&month=$monthDate.monthOfYear]]**(%%) 697: </div> 698: #elseif($displayType == 'all') 699: #else 700: ## Paginated 701: #if(($totalPages > 1)) 702: #set($queryString = "") 703: #foreach($p in $request.getParameterNames()) 704: #if($p != 'page' && $p != 'ipp') 705: #foreach($v in $request.getParameterValues($p)) 706: #set($queryString = "${queryString}&${p}=${v}") 707: #end 708: #end 709: #end 710: <div class="pagingLinks"> 711: #if ($currentPageNumber < $totalPages) 712: #set($currentPageNumber = $currentPageNumber + 1) 713: (% class="prevPage" %)**[[« $msg.get('xe.blog.code.olderposts')>>$doc.name?page=${currentPageNumber}&ipp=${itemsPerPage}$queryString]]**(%%) 714: #set($currentPageNumber = $currentPageNumber - 1) 715: #end 716: #if ($currentPageNumber > 1) 717: #if ($currentPageNumber < $totalPages) 718: #sep() 719: #end 720: #set($currentPageNumber = $currentPageNumber - 1) 721: (% class="nextPage" %)**[[$msg.get('xe.blog.code.newerposts') »>>$doc.name?page=${currentPageNumber}&ipp=${itemsPerPage}$queryString]]**(%%) 722: #set($currentPageNumber = $currentPageNumber + 1) 723: #end 724: <span class="clear"></span> 725: </div> ## pagingLinks 726: #end 727: #end 728: #end 729: ## 730: ## 731: ## 732: #** 733: * Displays a message box with "publish" icon. 734: * 735: * @param message A text message concerning blog article publishing 736: *### 737: #macro(publishMessageBox $message) 738: <div class="plainmessage publish-message">$message</div> 739: #end 740: #** 741: * Displays a message box with "show/hide" icon. 742: * 743: * @param message A text message concerning blog article hiding 744: *### 745: #macro(hideMessageBox $message) 746: <div class="plainmessage hide-message">$message</div> 747: #end 748: ## 749: ## 750: ## 751: #** 752: * Determine the requested week, for using in a weekly-indexed blog. The relevant request parameters are 753: * <tt>year</tt> and <tt>week</tt>. By default, the current week is used. 754: * 755: * @param monthDate The resulting week, a JODATime MutableDateTime. 756: *### 757: #macro(getRequestedWeek $weekDate) 758: #set($weekDate = $xwiki.jodatime.mutableDateTime) 759: #if("$!{request.year}" != '') 760: $weekDate.setYear($util.parseInt($request.year)) 761: #end 762: #if("$!{request.week}" != '') 763: $weekDate.setWeekOfWeekyear($util.parseInt($request.week)) 764: #end 765: #end 766: ## 767: ## 768: ## 769: #** 770: * Determine the requested month, for using in a monthly-indexed blog. The relevant request parameters are 771: * <tt>year</tt> and <tt>month</tt>. By default, the current month is used. 772: * 773: * @param monthDate The resulting month, a JODATime MutableDateTime. 774: *### 775: #macro(getRequestedMonth $monthDate) 776: #set($monthDate = $xwiki.jodatime.mutableDateTime) 777: #if("$!{request.year}" != '') 778: $monthDate.setYear($util.parseInt($request.year)) 779: #end 780: #if("$!{request.month}" != '') 781: $monthDate.setMonthOfYear($util.parseInt($request.month)) 782: #end 783: #end 784: ## 785: ## 786: ## 787: #** 788: * Retrieve a blog property (title, display type, etc). 789: * 790: * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. 791: * @param propertyName The name of the property to be retrieved. One of the <tt>Blog.BlogClass</tt>'s properties. 792: * @param defaultValue The default value to use in case the blog object does not define one. 793: * @param propertyValue The resulting value. 794: *### 795: #macro(getBlogProperty $blogDoc $propertyName $defaultValue $propertyValue) 796: #set($propertyValue = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") 797: #if($propertyValue == '') 798: #set($propertyValue = $defaultValue) 799: #end 800: #end 801: {{/velocity}} 802: 803: \\
Recent Blog Posts
Storm Drain Survey
Computer Science Department Wikipedia Article
Delicious Cookies!!!
Assignment 13 posted
Makeshift Crew Project Survey for Cookies!!!
Assignments 11 & 12 Posted
Assignment 10 Posted
Assignment 9 (Project Progress Report) Posted
Organize Your Projects
A8 Posted
Blog Categories
News
(10)
Other
(2)
Personal
(1)
Survey
(1)
Blog Archive
2009
(1)
Quick Links
DSSF 2008
DCNM 2009
HCCF 2010
Document Index
Sandbox
My Recent Modifications
ASSIGNMENTNAME