#** * Weblog entries, comments, and related links. * @author Lance Lavandowska (conversion to Velocimacros) * @author David M Johnson (comment macros) *# #** * Shows weblog entries from specified category using specified page as a "day * template" for the display of each day. The maxEntries argument is ignored * because now the number of entries to display is controlled by the * entryDisplayCount property on the Preferences:Settings page. *
* This macro allows Roller to support five different types of blog displays: *
* Current day page
* /page/<handle>/
* On the current day page, Roller will show the most recent N blog
* entries (not just those for the day).
* At the end of the page, a previous link points to day page of entries
* before the ones shown (and the link is displayed as the day's date).
* This works exactly as before.
*
* Day page
* /page/<handle>/YYYYMMDD
*
On a day page, Roller will show all of the entries for a specific * day. At the end of the page, a next/previous link allows navigation * to next and previous day of entries (and the links are displayed as * the day's dates). Before, day pages always showed N entries (where * usually N=15), but now they'll show only a day's worth (e.g. 1-3 * entries). *
* Month page
* /page/<handle>/YYYYMM
*
On a month page, Roller will show the most recent N blog entries in * the month. At the end of the page, a previous link points to day page * of entries before the ones shown. This is new; we didn't have month * pages before. *
* Entry page
* /page/<handle>?entry=<anchor>
*
On an entry page, one entry is shown. The next/prev links link to the * next and previous entries (and the links are displayed as the entry * titles, nicely truncated). This one also works exactly as before. *
* Search page If there are search results, then this macro will show them using the
* current weblog's day template.
* $languageError $text.get("macro.weblog.nolanguages")
* /page/
*
*
* @param pageName Page name of page to serve as day template.
* @param maxEntries (ignored)
* @param category Only display weblog entries from this category.
*#
#macro( showWeblogEntriesInCategory $pageName $maxEntries $category)
#set($maxEntries = $website.entryDisplayCount)
#set($dayTemplateId = $pageModel.getPageIdByName($pageName))
#if(!$dayTemplateId ) ## if no page name, try Preview space
#set($dayTemplateId = $pageName)
#end
#if ($pageModel.weblogEntry)
#foreach( $day in $xmap.keySet() )
#set( $recentEntries = $xmap.get($day) )
#foreach ($var in $recentEntries)
#end
#**
* Shows list of links to recent weblog entries in one category.
*
* @param numEntries Maximum number of entries to display
**#
#macro( showRecentEntries $entryCount )
#showRecentEntriesInCategory($entryCount "nil")
#end
## ========================================================================
## Next / previous links macros
## ========================================================================
#**
* Displays next previous links, called by #showWeblogEntries().
* On the today page: show prev link day before earliest entry on page.
* On an entry page: show next/prev entry links.
* On a day page: show next prev day links.
**#
#macro( showNextPreviousControl )
#set( $npcat = 'nil' )
#set( $catLink = "" )
#if ( $catPath && $catPath != "")
#set( $npcat = $catPath )
#set( $catLink = "?catname=$catPath" )
#end
#end
#**
* Display link to chronologically previous entry or day in the
* same category (if specified).
**#
#macro( showPrevWeblogLink $category)
#if( $pageModel.previousEntry )
#set( $prev = $pageModel.previousEntry )
#if( $pageModel.weblogEntry )
#set( $prevURL = "${ctxPath}${prev.permaLink}" )
« $utilities.truncateNicely($prev.title, 25, 25, "...")
#else
#set( $prevURL = "${ctxPath}/page/${website.handle}/#formatDate($plainFormat ${prev.pubTime})" )
« #showEntryDate(${prev.pubTime})
#end
#end
#end
#**
* Display link to chronologically next entry or day in the
* same category (if specified).
**#
#macro( showNextWeblogLink $category)
#if( $pageModel.nextEntry )
#set( $next = $pageModel.nextEntry )
#if( $pageModel.weblogEntry )
#set( $nextURL = "${ctxPath}${next.permaLink}" )
$utilities.truncateNicely($next.title, 25, 25, "...") »
#else
#set( $nextURL = "${ctxPath}/page/${website.handle}/#formatDate($plainFormat ${next.pubTime})" )
#showEntryDate(${next.pubTime}) »
#end
#end
#end
## ========================================================================
## Individual weblog entry display macros
## ========================================================================
#**
* Use this to show entry summary or text as appropriate on your blog pages.
* On single-entry pages, text is prefered. Everywhere else, summary is
* preferred. Also, applies all plugins configured by entry.
*#
#macro( showEntryText $entry )
#if( $entryPage )
#parse($entryPage.id)
#else
#if( $pageModel.weblogEntry)
## on single-entry pages, we prefer text
#if( $utilities.isNotEmpty($entry.text) )
#set( $sourceText = $entry.text )
#else
#set( $sourceText = $entry.summary )
#end
#else
## on multi-entry pages, we prefer summary
#if( $utilities.isNotEmpty($entry.summary) )
#set( $sourceText = $entry.summary )
#if( $utilities.isNotEmpty($entry.text) )
#set( $readMore = " ..." )
#set( $sourceText = "$sourceText$readMore")
#end
#else
#set( $sourceText = $entry.text )
#end
#end
#if( $entry.plugins )
#set( $displayText = $pageHelper.renderPlugins($entry, $sourceText) )
#else
#set( $displayText = $sourceText )
#end
$utilities.textToCDATA($displayText)
#end
#end
#**
* Roller uses this macro to display entry.summary in RSS and Atom feeds.
*#
#macro( showEntrySummary $entry )
#if( $entry.plugins)
#set( $displayText = $pageHelper.renderPlugins($entry, $entry.summary))
#else
#set( $displayText = $entry.summary )
#end
#if( $entryLength == -1 )
$utilities.textToXML($displayText)
#else
#set( $displayText = $stringUtils.left( $displayText, $entryLength ) )
#set( $displayText = $utilities.textToXML($utilities.removeHTML($displayText)) )
$displayText... [$entry.text.length() characters]
#end
#end
#**
* Roller uses this macro to display entry.text in RSS and Atom feeds.
*#
#macro( showEntryContent $entry )
#if( $entry.plugins)
#set( $displayText = $pageHelper.renderPlugins( $entry, $entry.text))
#else
#set( $displayText = $entry.text )
#end
#if( $entryLength == -1 )
$utilities.textToXML($displayText)
#else
#set( $displayText = $stringUtils.left( $displayText, $entryLength ) )
#set( $displayText = $utilities.textToXML($utilities.removeHTML($displayText)) )
$displayText... [$entry.text.length() characters]
#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/${website.handle}/$page.link/$utilities.encode($entry.anchor)
#end
#**
* Method to retrieve a full encoded anchor tag for a WeblogEntry.
**#
#macro( showAnchorTag $entry )
#end
#**
* Display a trackback auto-discovery comment for a WeblogEntry.
**#
#macro( showTrackbackAutodiscovery $entry )
#end
## ========================================================================
## Search form and results macros
## ========================================================================
#**
* 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 )
$min - $max of $searchResults.hits found.
#end
#**
* Display list of search result pages (for pagination).
**#
#macro( showSearchPager )
#set( $numPages = $searchResults.hits / $searchResults.limit )
#set( $remainder = $searchResults.hits % $searchResults.limit )
#if( $remainder > 0 )#set( $numPages = $numPages + 1 )#end
#if( $numPages > 1 )
#foreach( $pageNum in [1..$numPages] )
#set( $i = $pageNum - 1 )
#set( $start = $searchResults.limit * $i )
$pageNum#if( $pageNum != $numPages) | #end
#end
#end
#end
## ========================================================================
## Other 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
#**
* 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)
#end
#else
#foreach( $day in $xmap.keySet() )
#set( $recentEntries = $xmap.get($day) )
#foreach ($var in $recentEntries)
#end
#**
* (DEPRECATED) Shows list of links for recent weblog entries in all categories
* using the link field (which is no longer exposed in the editor UI).
* You should use showRecentEntries() instead.
**#
#macro( showRecentEntryLinks $numEntries )
#showRecentEntryLinksInCategory($numEntries "nil")
#end
#**
* (DEPRECATED) Shows weblog entries by calling showWeblogEntriesInCategory(),
* but passes category of 'nil' to indicate that all categories are to be
* included. You should use displayWeblogEntries() instead.
*
* @param pageName Page name of page to serve as day template.
* @param maxEntries (ignored)
*#
#macro( showWeblogEntries $pageName $maxEntries )
#showWeblogEntriesInCategory($pageName $maxEntries 'nil')
#end
#**
* (DEPRECATED) This macro does nothing because now, next/prev links are
* built-into the showWeblogEntries() macro.
*#
#macro( showNextPreviousLinks )
#end