META-INF.maven.site.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reflow-maven-skin Show documentation
Show all versions of reflow-maven-skin Show documentation
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.
The newest version!
#*
* Copyright 2012 Andrius Velykis
*
* Licensed 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#* /call
--------------------------------------------------*###
#**
* Checks if the given link is an external one.
*###
#macro ( checkExtLink $href )#*
*##set ( $checkExtLink = false )#*
*##if ( $href && ($href.toLowerCase().startsWith("http:/") || $href.toLowerCase().startsWith("https:/")
|| $href.toLowerCase().startsWith("ftp:/") || $href.toLowerCase().startsWith("mailto:")
|| $href.toLowerCase().startsWith("file:/") || ($href.toLowerCase().indexOf("://") != -1) ))#*
*##set ( $checkExtLink = true )#*
*##end##
#end#* /checkExtLink
--------------------------------------------------*###
#**
* Relativizes the link
*###
#macro ( relativeLink $href )#*
*##if ( $href )#*
*##set ( $relativeLink = $PathTool.calculateLink( $href, $relativePath ) )#*
*##set ( $relativeLink = $relativeLink.replaceAll( "\\", "/" ) )#*
*##if ( ( $relativeLink == '' ) )#*
*##set ( $relativeLink = './' )#*
*##end#*
// Attempt to normalise the relative link - this is useful for active link
// calculations and better relative links for subdirectories.
//
// The issue is particularly visible with pages in subdirectories,
// so that if you are in /dev/index.html, the relative menu link to
// the _same_ page would likely be ../dev/index.html instead of '' or 'index.html'.
*##set ( $absoluteLink = $uriTool.toURI( "$currentFileLoc" ).resolve( "$relativeLink" ).normalize().toString() )#*
*##if ( $currentFileLoc == $absoluteLink )#*
// for matching link, use empty relative link
*##set ( $relativeLink = '' )#*
*##else#*
// relativize the absolute link based on current directory
// (uses Maven project link relativization)
*##set ( $currentFileDir = $PathTool.getDirectoryComponent( $currentFileLoc ) )#*
*##set ( $relativeLink = $uriTool.relativizeLink( $currentFileDir, $absoluteLink ) )#*
*##end#*
*##else#*
// null $href
*##set ( $relativeLink = false )#*
*##end##
#end#* /relativeLink
--------------------------------------------------*###
#**
* Checks if the given link is an external one. If not, calculates a relative link.
*###
#macro ( relativeExtLink $href )#*
*##checkExtLink ( $href )#*
*##if ( $checkExtLink )#*
// if external, keep the original
*##set ( $relativeExtLink = $href )#*
*##else#*
// if not external link, calculate an return the relative link
*##relativeLink ( $href )#*
*##set ( $relativeExtLink = $relativeLink )#*
*##end##
#end#* /relativeExtLink
--------------------------------------------------*###
#**
* Makes the link relative to the project URL, if one is set.
*###
#macro ( currentFileRelativeLink $href )#*
*##if ( $project.url && $project.url != '' && $currentFileName )#*
// if project URL is available, relativize the link using it as a base dir
// note that the current file can be nested under project URL, so take that into account
*##set ( $currentFileDir = $uriTool.toURI( "$project.url/" ).resolve( "$currentFileName" ).resolve(".").toString() )#*
*##set ( $currentFileRelativeLink = $uriTool.relativizeLink( $currentFileDir, $href ) )#*
*##else#*
// otherwise just keep the original link
*##set ( $currentFileRelativeLink = $href )#*
*##end##
#end#* /currentFileRelativeLink
--------------------------------------------------*###
#**
* Checks if the given link is the currently active one
*###
#macro ( activeLink $href )#*
*##relativeLink ( $href )#*
*##if ( $href )#*
// either empty link (pointing to a page), or if the current file is index.html,
// the link may point to the whole directory
*##if ( '' == $relativeLink || ( $alignedFileName.endsWith("index.html") && './' == $relativeLink ) )#*
*##set ( $activeLink = true )#*
*##set ( $activeClass = 'active' )#*
*##else#*
*##set ( $activeLink = false )#*
*##set ( $activeClass = '' )#*
*##end#*
*##else#*
// null href - disable the link
*##set ( $activeLink = false )#*
*##set ( $activeClass = 'disabled' )#*
*##end##
#end#* /activeLink
--------------------------------------------------*###
#**
* Creates a class="name" attribute if the given name exists
*###
#macro ( classAttr $name )#*
*##if ( $name && '' != $name )#*
*#class="$name"#*
*##end##
#end#* /class
--------------------------------------------------*###
#**
* Creates dropdown menu items
*###
#macro ( topMenu $menus )#*
*##foreach ( $menu in $menus )#*
*##if ( $menu.name )#*
// check if one of the subtree items is the current one
*##set ( $displayTree = false )#*
*##displayTree ( $menu )##
$menu.name
#* *##end#*
*##end## /foreach $menu
#end#* /topMenu
--------------------------------------------------*###
#**
* Outputs a list of links
*###
#macro ( links $links )#*
*##foreach ( $item in $links )#*
*##activeLink ( $item.href )##
#link ( $relativeLink $item.name $item.target )
#* *##end##
#end#* /links
--------------------------------------------------*###
#**
* Shortcut to display a basic hyperlink
*###
#macro ( link $href $name $target )#*
*##fullLink ( $href $name $target false false false false false false false )##
#end#* /link
--------------------------------------------------*###
#**
* Outputs a hyperlink with image and other attributes
*###
#macro ( fullLink $href $name $target $img $position $alt $border $width $height $icon)#*
// 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#*
// Close *###
##
#end#* /fullLink
--------------------------------------------------*###
#**
* Outputs an image with attributes
*###
#macro ( image $img $alt $border $width $height )#*
*##if ( $img )#*
*##*
*##end##
#end#* /image
--------------------------------------------------*###
#**
* Outputs a list of breadcrumbs
*###
#macro ( breadcrumbs $breadcrumbs )#*
*##foreach ( $item in $breadcrumbs )#*
*##relativeLink ( $item.href )##
#fullLink ( $relativeLink $item.name $item.target $item.img $item.position $item.alt $item.border $item.width $item.height false )
/
#* *##end##
#if ( $shortTitle )$shortTitle#else$title#end
#end#* /breadcrumbs
--------------------------------------------------*###
#**
* Outputs the top Table of Contents ( subnav )
*###
#macro ( topToc $topItems )#*
// read the top ToC max config to get the number of items to show
*##if ( $config.tocTopMax )#*
*##set ( $tocMax = $convert.toNumber($config.tocTopMax.getValue()) )#*
*##else#*
*##set ( $tocMax = -1 )#*
*##end#*
// check if we flatten the first 2 levels of ToC:
*##set ( $flattenConfig = $config.tocTopFlatten )#*
*##if ( !$flattenConfig )#*
// flatten config not available - calculate if need flattening:
// only flatten if the top level has not more than 2 elements
*##set ( $topItemsCount = $topItems.size() )#*
*##set ( $flattenLevel2 = $topItemsCount <= 2 )#*
*##elseif ( "true" == $flattenConfig.getValue() )#*
*##set ( $flattenLevel2 = true )#*
*##else#*
*##set ( $flattenLevel2 = false )#*
*##end#*
// count items at top and the next level that will be displayed in the ToC bar
*##set ( $tocBarItems = [] )#*
*##set ( $tocBarMaxItems = [] )#*
*##set ( $tocCount = 0 )#*
*##foreach ( $topItem in $topItems )#*
*##if ( ($tocCount < $tocMax) || ($tocMax < 0) )#*
// only add items if not after the maximum
*##call ( $tocBarItems.add( $topItem ) )#*
*##set ( $topInMax = false )#*
*##else#*
*##call ( $tocBarMaxItems.add( $topItem ) )#*
*##set ( $topInMax = true )#*
*##end#*
*##set ( $tocCount = $tocCount + 1 )#*
// if level 2 is flattened, traverse for subitems
*##if ( $flattenLevel2 )#*
*##foreach ( $item in $topItem.items )#*
*##if ( ($tocCount < $tocMax) || ($tocMax < 0) )#*
// only add subitems if not after the maximum
*##call ( $tocBarItems.add( $item ) )#*
*##elseif ( !$topInMax )#*
// top is not in the max - so add these directly to the max
*##call ( $tocBarMaxItems.add( $item ) )#*
*##end#*
*##set ( $tocCount = $tocCount + 1 )#*
*##end#* /foreach $item
*##end#*
*##end#* /foreach $topItem
// count items at top and the next level that will be displayed in the ToC bar
*##set ( $tocCount = 0 )#*
*##set ( $tocDivider = false )#*
*##foreach ( $topItem in $tocBarItems )#*
*##if ( $topItems.contains( $topItem ) && $tocDivider )##
#* *##end#*
*##if ( $topItem.items.isEmpty() )##
$topItem.text
#* *##elseif ( $topItems.contains( $topItem ) && $flattenLevel2 )#*
// top level item, but flattened: put it as a link, because its children are also in top bar *###
$topItem.text
#* *##else##
$topItem.text
#* *##end#*
*##set ( $tocDivider = true )#*
*##end#* /foreach $topItem
*##if ( $tocBarMaxItems.size() > 0 )#*
// put the max items into an extra dropdown *###
…
#* *##end##
#end#* /topToc
--------------------------------------------------*###
#**
* Recursively outputs the contents of top bar ToC dropdown item
*###
#macro ( topTocDropdown $items )#*
*##foreach ( $subitem in $items )#*
*##if ($subitem.items.isEmpty())##
$subitem.text
#* *##else##
$subitem.text
#* *##end#*
*##end## /foreach $subitem
#end#* /topTocOpenRemaining
--------------------------------------------------*###
#**
* Outputs Table of Contents into a list menu
*###
#macro ( listToc $menus )##
##
#end#* /listToc
--------------------------------------------------*###
#**
* Recursively outputs ToC item and its children
*###
#macro ( listTocItem $item )#*
*##if ( $item.items.size() > 0 )##
$item.text
#* *##if ( $item.items.size() > 0 )##
#* *##end##
#* *##else##
$item.text
#* *##set ( $addedDivider = false )##
#* *##end##
#end#* /listTocItem
--------------------------------------------------*###
#**
* Outputs the top banner contents
*###
#macro ( banner $banner $id )#*
*##if ( $banner )#*
*##if ( $banner.href )#*
*##relativeExtLink ( $banner.href )##
#*
*##else##
#*
*##end#*
*##if ( $banner.src )#* start image
*##relativeExtLink ( $banner.src )#*
*##* /end image
*##else#*
*#$banner.name
#*
*##end#*
*##if ( $banner.href )#*
*#
#* *##else#*
*#
#* *##end#*
// add slogan to correct position
*##if ( $config.slogan && $config.slogan != '' )#*
// read slogan position - if not set, use 'bannerLeft' as default
*##if ( $config.slogan.getAttribute("position") )#*
*##set ( $sloganPos = $config.slogan.getAttribute("position") )#*
*##else#*
*##set ( $sloganPos = "bannerLeft" )#*
*##end#*
*##if ( $id == $sloganPos )##
$config.slogan.getValue()
#* *##end#*
*##end#* /slogan
*##end##
#end#* /banner
--------------------------------------------------*###
#**
* Partitions the body contents into sections with possibly different representations.
* Available body types, indicated in custom page config `sections` tag:
*
*
* - the main body of the page
* - sidebar (should go after the body)
* x - x-column grid layout for thumbnails (first image is used as thumbnail)
* x - x-column grid layout
* - carousel (spinning images with captions)
*
*###
#macro ( bodySections $bodyContent $sectionConfig )#*
// Split everything in the content on the horizontal rule tags
*##set ( $sections = $htmlTool.split( $bodyContent, "hr" ) )#*
*##set ( $sectCount = $sectionConfig.getChildCount() )#*
// Check if sidebar is indicated somewhere in the sections, need to adjust layout accordingly
*##set ( $hasSidebar = $sectionConfig.getChild( 'sidebar' ) )#*
// flag to indicate that last section was a main body section (needs closing for non-body sections)
*##set ( $lastBody = false )#*
// flag to indicate that a body section has already been found (to avoid multiple page-headers)
*##set ( $bodyFound = false )#*
*##set ( $sectIndex = 0 )#*
*##foreach ($section in $sections)#*
// Determine section type from the configuration
*##if ( $sectIndex < $sectCount )#*
*##set ( $sectType = $sectionConfig.getChild($sectIndex).getName() )#*
*##set ( $sectTypeValue = $sectionConfig.getChild($sectIndex).getValue() )#*
*##else#*
*##set ( $sectType = 'body' )#*
*##end#*
*##if ( 'sidebar' == $sectType || 'thumbs' == $sectType || 'columns' == $sectType || 'carousel' == $sectType )#*
// split section into sub-sections for each header (h1, h2, etc tag)
*##set ( $subsections = $htmlTool.splitOnStarts( $section, "h1, h2, h3, h4, h5, h6") )#*
*##else#*
// keep the section
*##set ( $subsections = [ $section ] )#*
*##end#*
*##if ( 'thumbs' == $sectType || 'columns' == $sectType || 'carousel' == $sectType )#*
// for full width layouts, we first need to close the body if it is still open
*##if ( $lastBody )##