All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.maven.site-macros.vm Maven / Gradle / Ivy

Go to download

Reflow is an Apache Maven site skin built on Twitter Bootstrap. It allows various structural and stylistic customizations to create a modern-looking Maven-generated website. Requires Reflow Velocity Tools.

There is a newer version: 2.4.0-beta2
Show newest version
##
## Copyright 2012-2018 Christophe Friederich
##
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements.  See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership.  The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License.  You may obtain a copy of the License at
##
##     http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied.  See the License for the
## specific language governing permissions and limitations
## under the License.
##
#**
 * Convenience directive to invoke a method and ignore the return value.
 *
 * Usage:
 *    #call ( $hashtable.put("foo", "bar") )
 *#
#macro ( call $foo )#*
  *##if ($foo)#*
    ## do nothing - the 'if' is for ignoring the return value#*
  *##end#*
*##end
#*
 *
 * Creates a class="name" attribute if the given name exists
 *
 *#
#macro ( classAttr $name )#*

  *##if ( $name && '' != $name )#*
      *# class="$name" #*
  *##end#*
*##end
#*
 *
 * Shortcut to display a basic hyperlink
 *
 *##macro ( link $href $name $target $className)#*
  *##fullLink ( $href $name $target false false false false false false false $className)#*
*##end
#*
 *
 * Outputs a hyperlink with image and other attributes
 *
 *#
#macro ( fullLink $href $name $target $img $position $alt $border $width $height $icon $className)##
##
## The opening  tag
##
#*
    *##if ( $img && $position == "left" )#*
        ## Image on the left side of the name
        *##image ($img $alt $border $width $height)$name#*
    *##elseif ( $img )#*
        ## Image on the right side of the name
        *#${name}#if ($img) #image ($img $alt $border $width $height)#end#*
    *##else#*
        ## No image - optional icon though on the right of the name
        *#${name}#if ($icon) #end#*
    *##end##
##
##
#end
#*
 *
 * Outputs an image with attributes
 *
 *##macro ( image $img $alt $border $width $height )#*

    *##if ( $img )#*
        *#"#*
    *##end
#end
##
#**
 * Displays a 'Last published' date message.
 *
 *##macro ( publishDate )#*
    *##if ( $decoration.publishDate.format )#*
        *##set ( $format = $decoration.publishDate.format )#*
    *##else#*
        *##set ( $format = "yyyy-MM-dd" )#*
    *##end#*

    *#$dateFormat.applyPattern( $format )#*

    *##if ( $publishDate )#*
        *##set ( $dateValue = $dateFormat.format( $publishDate ) )#*
    *##elseif ( $config.publishDate )#*
        *##set ( $dateValue = $config.publishDate.getValue() )#*
    *##else#*
        *##set ( $dateValue = $dateFormat.format( $currentDate ) )#*
    *##end#*
    ## render with internationalization support *#
    $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateValue
#end
##
#**
 * Displays a site version message.
 *
 *##macro ( version )#*
    ## render with internationalization support
    *#$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}##
#end
##
#**
 * Outputs XML DOM objects as html elements into the rendered document.
 * Taken from maven-fluido-skin.
 *
 *##macro ( htmlContent $items )#*
    *##foreach ( $item in $items )#*
        *##set ( $itemHtml = $item.toString().trim() )#*
        *##set ( $documentHeader = '' )#*
        *##if ( $item.name == "script" )#*
            *##set ( $itemHtml = $StringUtils.replace( $item.toUnescapedString(), $documentHeader, "" ) )#*
        *##else#*
            *##set ( $itemHtml = $StringUtils.replace( $item.toString(), $documentHeader, "" ) )#*
        *##end#*
        ## eval the HTML - this will allow users to specify Velocity variables
        *##evaluate ( $itemHtml )#*
    *##end##
#end
##
#**
 * Marks the first header inside the content as page header, by wrapping it into
 * a div with `page-header` class
 *
 *##macro ( bodyWithHeader $content )#*
    *##if ( $config.not( "markPageHeader" ) )#*
        ## do not mark page header, just print the content
        *##set ( $bodyWithHeader = $content )#*
    *##else#*
        ## try marking the header
        *##set ( $bodyWithHeader = $htmlTool.wrap($content, "h1", '', 1) )#*
        *##if ( $bodyWithHeader == $content )#*
            ## nothing's changed - try with h2
            *##set ( $bodyWithHeader = $htmlTool.wrap($content, "h2", '', 1) )#*
        *##end#*
    *##end#*
    *#$bodyWithHeader##
#end##
##
#**
 * Strips empty paragraphs 

from the content and outputs the result * *##macro ( stripEmptyP $content )#* ## use CSS selector for paragraphs that have no text content (only whitespace - \s), ## neither nested elements *#$htmlTool.remove($content, "p:matchesOwn(^${esc.backslash}s*$):not(*:has(*))")## #end## ## #** * Adds Google analytics tracker with the given account ID * *##macro ( googleAnalytics $accountId )#* *##if( $accountId && $accountId != "" )## #* *##end #end ## #* * Adapt bodyContent. *# #macro ( adaptBodyContent )#* *##if ( !$config.not( "imgLightbox" ) )#* ## lightbox is enabled by default, so check for false and negate ## TODO explain more? *##set ( $bodyContent = $htmlTool.setAttr( $bodyContent, "a[href$=jpg], a[href$=JPG], a[href$=jpeg], a[href$=JPEG], a[href$=png], a[href$=gif], a[href$=bmp]:has(img)", "data-lightbox", "page" ))#* *##end ## #if ( !$config.not( "html5Anchor" ) )## ## HTML5-style anchors are enabled by default, so check for false and negate #set ( $bodyContent = $htmlTool.headingAnchorToId( $bodyContent ) )## #end ## #if ( !$config.not( "bootstrapCss" ) )## ## Bootstrap CSS class conversion is enabled by default, so check for false and negate #set ( $bodyContent = $htmlTool.addClass( $bodyContent, "table.bodyTable", ["table", "table-striped", "table-hover"] ) )## ## image is responsive by default #set ( $bodyContent = $htmlTool.addClass( $bodyContent, "img", ["img-fluid"] ) )## #set ( $bodyContent = $htmlTool.fixTableHeads( $bodyContent ) )## #end ## #if ( !$config.not( "bootstrapIcons" ) )## ## Bootstrap Icons are enabled by default, so check for false and negate #set ( $iconReplacements = { 'img[src$=images/add.gif]' : '', 'img[src$=images/remove.gif]' : '', 'img[src$=images/fix.gif]' : '', 'img[src$=images/update.gif]' : '', 'img[src$=images/icon_help_sml.gif]' : '', 'img[src$=images/icon_success_sml.gif]' : '', 'img[src$=images/icon_warning_sml.gif]' : '', 'img[src$=images/icon_error_sml.gif]' : '', 'img[src$=images/icon_info_sml.gif]' : '' } )## #set ( $bodyContent = $htmlTool.replaceAll( $bodyContent, $iconReplacements ) )## ## The tag is not supported in HTML5 (see https://www.w3schools.com/tags/tag_tt.asp). #set ( $bodyContent = $htmlTool.replaceWith( $bodyContent, 'tt', '' ) )## #end## #if ( $pageContext.toc.enabled )## ## Ensure IDs on all headings to refer to them in TOC #set ( $bodyContent = $htmlTool.ensureHeadingIds( $pageContext.type, $config.fileId, $bodyContent, "_" ) )## #set ( $tocItems = $htmlTool.headingTree( $bodyContent, $config.getChildren( $config.sections ) ) )## #end #end #* * Add Edit button if content is editable *# #macro ( renderFeedbackLink ) #end