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

META-INF.maven.components.layout.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 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.
##
##
#parse( "carousel.vm" )##
#parse( "columns.vm" )##
#parse( "thumbnails.vm" )##
#parse( "sidebar.vm" )##
#**
 * 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 ( renderBodySections $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 )##
#* *##end#* ## Print the subsections into columns *##if ( 'thumbs' == $sectType )#* *##renderThumbnails ( $sectTypeValue $subsections )#* *##elseif ( 'columns' == $sectType )#* *##columns ( $sectTypeValue $subsections )#* *##else#* *##carousel ( $subsections )#* *##end#* *##elseif ( 'sidebar' == $sectType )#* ## for sidebar, close the body if needed but not body row - then add the sidebar *##if ( $lastBody )## #* *##else##
#* *##end
## Print the subsections into sidebar #sidebar ( $subsections )
#* *##set ( $lastBody = false )#* *##else#* ## handle all other cases as 'body' type *##if ( !$lastBody )##
#* *##if ( $hasSidebar)#* ## has a sidebar - take part width *#
#* *##else#* ## no sidebar - take full width *#
#* *##end##
#* *##else#* ## reinstate the horizontal rule for continuing body *#
#* *##end#* ## set the contents *##foreach ( $subsection in $subsections )#* ## if first body section, output with page-header *##if ( !$bodyFound )#* *##bodyWithHeader ( $subsection )#* *##else#* *#$subsection#* *##end#* *##set ( $bodyFound = true )#* *##end#* foreach *##set ( $lastBody = true )#* *##end#* ## increment the section counter (need to advance through the types) *##set ( $sectIndex = $sectIndex + 1 )#* *##end#* ## After the loop, check if body section still needs closing (if it was the last section) *##if ( $lastBody )##
#* *##end## #end##