#** * 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 ) #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 #** * 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 ) #if($trackbacksEnabled && $website.allowComments && $entry.commentsStillAllowed)
$text.get( "macro.weblog.trackback" ) #showTrackbackURL($entry)
#end #showComments($entry) #if($commentsEnabled && $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 #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) ) #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) ) #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) ${locale.getDisplayLanguage()}
#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( $npcat = 'nil' ) #set( $catLink = "" ) #if ( $catPath && $catPath != "") #set( $npcat = $catPath ) #set( $catLink = "?catname=$catPath" ) #end
#if ($pageModel.previousEntry) #showPrevEntryLink($npcat) | #end #if ( $pageModel.previousEntry || $pageModel.nextEntry) $page.name #end #if ($pageModel.nextEntry) | #showNextEntryLink($npcat) #end
#end #** * Display link to chronologically previous entry in the * same category (if specified). **# #macro( showPrevEntryLink $category) #if( $pageModel.previousEntry ) #set( $prev = $pageModel.previousEntry ) #set( $prevURL = "${ctxPath}${prev.permaLink}" ) « $utilities.truncateNicely($prev.title, 30, 30, "...") #end #end #** * Display link to chronologically next entry in the * same category (if specified). **# #macro( showNextEntryLink $category) #if( $pageModel.nextEntry ) #set( $next = $pageModel.nextEntry ) #set( $nextURL = "${ctxPath}${next.permaLink}" ) $utilities.truncateNicely($next.title, 30, 30, "...") » #end #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 #** * 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, ${searchResults.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