#** * 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
* /page/?q=
*

If there are search results, then this macro will show them using the * current weblog's day template. *
* * @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)

#showNextPreviousControl()
#set($day = $entry.pubTime) #set($entries = [$pageModel.weblogEntry]) #parse($dayTemplateId ) #if($trackbacksEnabled && $website.allowComments && $entry.commentsStillAllowed)
$text.get("macro.weblog.trackback") #showTrackbackURL($entry)
#end
#showNextPreviousControl()
#showEntryLinkbacks($entry) #showComments($entry) #if($commentsEnabled && $website.allowComments && $entry.commentsStillAllowed) #showCommentForm($entry) #else $text.get("comments.disabled") #end #else #if($searchResults) #set($map = $searchResults.results ) #showSearchAgainForm() #showSearchSummary() #foreach($day in $searchResults.results.keySet()) #set($entries = $searchResults.results.get($day)) #parse($dayTemplateId) #end #showSearchPager() #else #set($map = $pageModel.getRecentWeblogEntries($maxEntries, $category)) #if($map.size() == 0) $text.get("macro.weblog.noEntriesForDate") #else #foreach($day in $map.keySet()) #set($entries = $map.get($day)) #parse($dayTemplateId) #end #end
#showNextPreviousControl()
#end #end #end #** * Shows weblog entries by calling showWeblogEntriesInCategory() and passing * 'nil' to indicate that all categories are to be included. *# #macro( displayWeblogEntries ) #showWeblogEntriesInCategory("_day" 15 'nil') #end #** * Shows list of links to recent weblog entries in one category. * @param entryCount Maximum number of entry links to display **# #macro( showRecentEntriesInCategory $entryCount $catPath ) #set( $xmap = $pageModel.getRecentWeblogEntries($entryCount,$catPath) ) #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
#if ($pageModel.previousEntry) #showPrevWeblogLink($npcat) | #end #if ($pageModel.previousEntry || $pageModel.nextEntry) $page.name #end #if ($pageModel.nextEntry) | #showNextWeblogLink($npcat) #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 ) #formatDate( $plainFormat $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 )

#set( $cats = $pageModel.getWeblogCategories("nil") )

#end #** * Display search again form *# #macro( showSearchAgainForm )
$text.get( "macro.weblog.searchdictionary", [$searchResults.term, $searchResults.term, $searchResults.term] ) $text.get( "macro.weblog.searchhits", [$searchResults.hits])

#set( $cats = $pageModel.getWeblogCategories("nil") )
$text.get( "macro.weblog.searchgoogle", [$searchResults.term, $absBaseURL, $ctxPath, ${website.handle}] )
#end #** * Displays header like "1 - 10 of 20 found.". **# #macro( showSearchSummary ) #set( $min = $searchResults.offset + 1 ) #set( $max = $searchResults.offset + $searchResults.limit ) #if( $max > $searchResults.hits )#set( $max = $searchResults.hits )#end

$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)

$languageError

#end #set( $locales = $pageHelper.getSupportedLanguages() ) #if ($locales) #foreach($locale in $locales) ${locale.getDisplayLanguage()}
#end #else

$text.get("macro.weblog.nolanguages")

#end #end ## ======================================================================== ## Deprecated macros ## ======================================================================== #** * (DEPRECATED) Shows list of links for recent weblog entries in one category * using the link field (which is no longer exposed in the editor UI). * You should use showRecentEntriesInCategory() instead. * * @param numEntries Maximum number of entries to display * @param cat Category to be displayed **# #macro( showRecentEntryLinksInCategory $numEntries $cat) #set( $xmap = $pageModel.getRecentWeblogEntries($numEntries, $cat) ) #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