#**
* Weblog entries, comments, and related links.
* @author Lance Lavandowska (conversion to Velocimacros)
* @author David M Johnson (comment macros)
*#
#**
* Print status/error message if exists.
* Note: "error" and "status" styles should be moved out into
* invididual Themes' theme.css files.
**#
#macro( showStatusMessage )
#if( $errorMessage )
$errorMessage
#end
#if( $statusMessage )
$statusMessage
#end
#end
#**
* Set the META tag for ContentLanguage. We do this rather than
* setting the Response header because the header does not get
* cached. So in order to maintain the ContentType we must present
* it inside the rendered page itself.
**#
#macro( showContentLanguage $lang )
#end
#**
* Use this macro in your day template if you want to override
* entry rendering in both your HTML and RSS weblog output by defining
* a page template named _entry.
*
*
It is no longer necessary to use a page template named _entry
* if you want to override entry rendering in both your
* HTML and RSS weblog output (for support of PagePlugins).
* However, backwards compatibility for such use is still included,
* or if you have some other need to override entry rendering.
* The _entry page is now loaded by ContextLoader as $entryPage.
*#
#macro( showEntryText $entry )
#if( $entryPage )
#parse($entryPage.id)
#else
#if ( $entry.plugins )
#set( $entryText = $pageHelper.renderPlugins( $entry ) )
#else
#set( $entryText = $entry.text )
#end
#if( $entryLength == -1 )
$utilities.textToCDATA($entryText)
#else
#set( $entryText = $utilities.textToCDATA($utilities.removeHTML($entryText)) )
$stringUtils.left( $entryText, $entryLength )... [$entryText.length() characters]
#end
#end
#end
#**
* Use this macro in your day template if you want to override
* entry rendering in both your HTML and RSS weblog output by defining
* a page template named _desc.
*
* It is no longer necessary to use a page template named _desc
* if you want to override entry rendering in both your
* HTML and RSS weblog output (for support of PagePlugins).
* However, backwards compatibility for such use is still included,
* or if you have some other need to override entry rendering.
* The _desc page is now loaded by ContextLoader as $descPage.
*#
#macro( showEntryDescription $entry )
#if( $descPage )
#parse($descPage.id)
#else
#if ( $entry.plugins )
#set( $entryText = $pageHelper.renderPlugins( $entry ) )
#else
#set( $entryText = $entry.text )
#end
#if( $entryLength == -1 )
$utilities.textToXML($entryText)
#else
#set( $entryText = $stringUtils.left( $entryText, $entryLength ) )
#set( $entryText = $utilities.textToXML($utilities.removeHTML($entryText)) )
$entryText... [$entryText.length() characters]
#end
#end
#end
#**
* Display Permalink for Date.
* @param day Date object that specifies day (type java.util.Date).
*#
#macro( showDayPermalink $day )
#end
#**
* Display the default Date.toString for date using the 'macro.weblog.date.toStringFormat'
* format as defined in the resource bundle.
* @param toStringFormat Format string (see java.text.SimpleDateFormat).
* @param day Date object that specifies day (type java.util.Date).
*#
#macro( showEntryDate $day )
#set( $format=$text.get("macro.weblog.date.toStringFormat") )
#formatDate( $format $day )
##formatDate( $toStringFormat $day )
#end
#**
* Display the timestamp for the $day using the 'macro.weblog.date.timestampFormat'
* format as defined in the resource bundle.
*
* @param timestampFormat Format string (see java.text.SimpleDateFormat).
* @param day Date object that specifies day (type java.util.Date).
*#
#macro( showTimestamp $day )
#set( $format = $text.get("macro.weblog.date.timestampFormat") )
#formatDate( $format $day )
##formatDate( $timestampFormat $day )
#end
#**
* Display the Permalink for a weblog entry.
* @param entry WeblogEntry object.
*#
#macro( showEntryPermalink $entry )
Permalink
#if ($pageHelper.isUserAuthorizedToEdit())
[$text.get( "macro.weblog.entrypermalink.edit" )]
#end
#end
#**
* Display the Trackback URL for a weblog entry.
* @param entry WeblogEntry object.
*#
#macro( showTrackbackURL $entry )
$absBaseURL/trackback/$userName/$page.link/$utilities.encode($entry.anchor)#end
#**
* Display search form for searching a weblog. This is only a form, no div
* or anything around it.
*#
#macro( showSearchForm )
#end
#**
* Display search again form
*#
#macro( showSearchAgainForm )
$text.get( "macro.weblog.searchdictionary", [$term, $term, $term] )
$text.get( "macro.weblog.searchhits", [$hits])
$text.get( "macro.weblog.searchgoogle", [$term, $absBaseURL, $ctxPath, $userName] )
#end
#**
* Displays header like "1 - 10 of 20 found.".
**#
#macro( showSearchSummary )
#set( $min = $offset + 1 )
#set( $max = $offset + $limit )
#if( $max > $hits )#set( $max = $hits )#end
$min - $max of $hits found.
#end
#**
* Display list of search result pages (for pagination).
**#
#macro( showSearchPager )
#set( $numPages = $hits / $limit )
#set( $remainder = $hits % $limit )
#if( $remainder > 0 )#set( $numPages = $numPages + 1 )#end
#if( $numPages > 1 )
#foreach( $pageNum in [1..$numPages] )
#set( $i = $pageNum - 1 )
#set( $start = $limit * $i )
$pageNum#if( $pageNum != $numPages) | #end
#end
#end
#end
#**
* Display link to chronologically previous entry in the
* same category (if specified).
**#
#macro( showPreviousEntryLink $category)
#if( $pageModel.previousEntry )
#if ( $category != 'nil' )#set( $catPath = $category )#end ## was a category supplied?
#set( $previousEntry = $pageModel.previousEntry )
« $utilities.truncateNicely($previousEntry.title, 30, 30, "...")
#end
#end
#**
* Display link to chronologically next entry in the
* same category (if specified).
**#
#macro( showNextEntryLink $category)
#if( $pageModel.nextEntry )
#if ( $category != 'nil' )#set( $catPath = $category )#end ## was a category supplied?
#set( $nextEntry = $pageModel.nextEntry )
$utilities.truncateNicely($nextEntry.title, 30, 30, "...") »
#end
#end
#**
* Shows weblog entries from specified category
* using specified page as a "day template" for the display of each day.
* If a specific weblog entry is specified by the current request (using
* the anchor tag), then shows the only the specified entry (using the day
* template) along with the comments associated with that entry.
*
* @param pageName Page name of page to serve as day template.
* @param maxEntries Maximum number of entries to be shown.
* @param category Only display weblog entries from this category.
*#
#macro( showWeblogEntriesInCategory $pageName $maxEntries $category )
#if ( $pageModel.getWeblogEntry() )
#set( $entry = $pageModel.getWeblogEntry() )
#end
#set( $dayTemplateId = $pageModel.getPageIdByName($pageName) )
#if ( !$dayTemplateId ) ## if no page name, try Preview space
#set ( $dayTemplateId = $pageName )
#end
#if( $entry )
#set( $day = $entry.pubTime )
#set( $entries = [ $entry ] )
#parse( $dayTemplateId )
$text.get( "macro.weblog.trackback" ) #showTrackbackURL($entry)
#showComments($entry)
#if($website.allowComments && $entry.commentsStillAllowed)
#showCommentForm($entry)
#else
$text.get("comments.disabled")
#end
#else
#if( $searchResults )
#set( $map = $searchResults )
#showSearchAgainForm()
#showSearchSummary()
#else
#set( $map = $pageModel.getRecentWeblogEntries($maxEntries, $category) )
#end
#foreach( $day in $map.keySet() )
#set( $entries = $map.get($day) )
#parse( $dayTemplateId )
#end
#if( $searchResults )
#showSearchPager()
#end
#showPreviousEntryLink($category)
#showNextEntryLink($category)
#end
#end
#**
* Shows weblog entries using specified page as a "day template" for
* the display of each day. If a specific weblog entry is specified
* by the current request (using the anchor tag), then shows the only
* the specified entry (using the day template) along with the comments
* associated with that entry.
*
* @param pageName Page name of page to serve as day template.
* @param maxEntries Maximum number of entries to be shown.
*#
#macro( showWeblogEntries $pageName $maxEntries )
#showWeblogEntriesInCategory($pageName $maxEntries 'nil')
#end
#**
* Show the last $maxEntries number of weblogentry titles in a category,
* as links to the individual posts. Names of fields
* must be different than in showWeblogEntries (those
* values take precedence for some reason).
**#
#macro( showRecentEntriesInCategory $entryCount $catPath )
#set( $xmap = $pageModel.getRecentWeblogEntries($entryCount,$catPath) )
#foreach( $day in $xmap.keySet() )
#set( $recentEntries = $xmap.get($day) )
#foreach ($var in $recentEntries)
- $var.title
#end
#end
#end
#**
* Show the last $maxEntries number of weblogentry titles,
* as links to the individual posts. Names of fields
* must be different than in showWeblogEntries (those
* values take precedence for some reason).
**#
#macro( showRecentEntries $entryCount )
#showRecentEntriesInCategory($entryCount "nil")
#end
#**
* Show the last $maxEntries number of weblogentry titles, as links to
* entry links. Names of fields must be different than in showWeblogEntries
* (those values take precedence for some reason).
**#
#macro( showRecentEntryLinksInCategory $numEntries $cat)
#set( $xmap = $pageModel.getRecentWeblogEntries($numEntries, $cat) )
#foreach( $day in $xmap.keySet() )
#set( $recentEntries = $xmap.get($day) )
#foreach ($var in $recentEntries)
-
#if ($var.link)
$var.title
#else
$var.title
#end
#if ($pageHelper.isUserAuthorizedToEdit())
[$text.get( "macro.weblog.editentry" )]
#end
#end
#end
#end
#**
* Show the last $maxEntries number of weblogentry titles, as links to
* entry links. Names of fields must be different than in showWeblogEntries
* (those values take precedence for some reason).
**#
#macro( showRecentEntryLinks $numEntries )
#showRecentEntryLinksInCategory($numEntries "nil")
#end
#**
* Display language form for selection a different language. This is only a form, no div
* or anything around it.
*#
#macro( showLanguageForm )
## first check for errors during possible previous langauge change
#if ($languageError)
$languageError
#end
#set( $locales = $pageHelper.getSupportedLanguages() )
#if ($locales)
#foreach($locale in $locales)
#end
#else
$text.get("macro.weblog.nolanguages")
#end
#end
#**
* Display links to Previous and/or Next chronological Entry. Also
* display link to "main" page if either is present.
**#
#macro( showNextPreviousLinks )
#set( $catLink = "" )
#if ( $catPath ) #set( $catLink = "?catname=$catPath" ) #end
#end
#**
* Method to retrieve a full encoded anchor tag for a WeblogEntry.
**#
#macro( showAnchorTag $entry )
#end