This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch site-model-rework
in repository https://gitbox.apache.org/repos/asf/maven-fluido-skin.git

commit be74bf6ed43d77066ab77655f467e686e2cd92f6
Author: Michael Osipov <micha...@apache.org>
AuthorDate: Fri Jun 30 17:12:23 2023 +0200

    Rewrite banner macro
---
 src/main/resources/META-INF/maven/site-macros.vm | 95 ++++++++++++++----------
 1 file changed, 56 insertions(+), 39 deletions(-)

diff --git a/src/main/resources/META-INF/maven/site-macros.vm 
b/src/main/resources/META-INF/maven/site-macros.vm
index b1cff7a..369cab3 100644
--- a/src/main/resources/META-INF/maven/site-macros.vm
+++ b/src/main/resources/META-INF/maven/site-macros.vm
@@ -100,6 +100,37 @@
 #**##end
 #end
 ##
+#macro ( image2 $image )
+#*  *##if ( !$decoration.isLink( $image.src ) )
+#*    *##set ( $src = $PathTool.calculateLink( $image.src, $relativePath ) )
+#*    *##set ( $src = $src.replace( '\\', '/' ) )
+#*    *##set ( $src = ' src="' + $src + '"' )
+#*  *##else
+#*    *##set ( $src = ' src="' + $image.src + '"' )
+#*  *##end
+#*  *##if( $image.alt )
+#*    *##set ( $alt = ' alt="' + $esc.xml( $image.alt ) + '"' )
+#*  *##else
+#*    *##set ( $alt = "" )
+#*  *##end
+#*  *##if( $image.width )
+#*    *##set ( $width = 'width: ' + $image.width + '; ' )
+#*  *##else
+#*    *##set ( $width = "" )
+#*  *##end
+#*  *##if( $image.height )
+#*    *##set ( $height = 'height: ' + $image.height + ';' )
+#*  *##else
+#*    *##set ( $height = "" )
+#*  *##end
+#*  *##if( $image.style )
+#*    *##set ( $style = $image.style )
+#*  *##else
+#*    *##set ( $style = "" )
+#*  *##end
+<img class="imageLink"$src$alt style="$width$height$style" />##
+#end
+##
 #macro ( image $img $alt $border $width $height )
 #**##if( $img )
 #*  *##if ( !$decoration.isLink( $img ) )
@@ -135,58 +166,44 @@
 ##
 #macro ( banner $banner $id )
 #**##if ( $banner )
-#*  *##if( $banner.href )
-#*    *##set ( $hrf = $banner.href )
-#*    *##if ( !$decoration.isLink( $hrf ) )
-#*      *##set ( $hrf = $PathTool.calculateLink( $hrf, $relativePath ) )
-#*      *##set ( $hrf = $hrf.replaceAll( '\\', '/' ) )
-#*      *##if ( ( $hrf == '' ) )
-#*        *##set ( $hrf = './' )
-#*      *##end
-#*    *##end
-#*    *#<a href="$hrf" id="$id">##
+#*  *#<div id="$id"><h1>##
+#*  *##if( $banner.name )
+#*    *##set ( $name = $esc.xml( $banner.name ) )
 #*  *##else
-#*    *#<div id="$id">##
+#*    *##set ( $name = "" )
 #*  *##end
-##
-#*  *##if( $banner.src )
-#*    *##set ( $src = $banner.src )
-#*    *##if ( !$decoration.isLink( $src ) )
-#*      *##set ( $src = $PathTool.calculateLink( $src, $relativePath ) )
-#*      *##set ( $src = $src.replaceAll( '\\', '/' ) )
-#*    *##end
-#*    *##if ( $banner.alt )
-#*      *##set ( $alt = ' alt="' + $esc.xml( $banner.alt ) + '"' )
-#*    *##elseif ( $banner.name )
-#*      *##set ( $alt = ' alt="' + $esc.xml( $banner.name ) + '"' )
-#*    *##else
-#*      *##set ( $alt = "" )
-#*    *##end
-#*    *##if( $banner.border )
-#*      *##set ( $imgBorder = 'border: ' + $banner.border + '; ' )
-#*    *##else
-#*      *##set ( $imgBorder = "" )
+#*  *##if( $banner.href )
+#*    *##set ( $href = $banner.href )
+#*    *##if ( !$decoration.isLink( $href ) )
+#*      *##set ( $href = $PathTool.calculateLink( $href, $relativePath ) )
+#*      *##set ( $href = $href.replaceAll( '\\', '/' ) )
+#*      *##if ( ( $href == '' ) )
+#*        *##set ( $href = './' )
+#*      *##end
 #*    *##end
-#*    *##if( $banner.width )
-#*      *##set ( $imgWidth = 'width: ' + $banner.width + '; ' )
+#*    *##if( $banner.target )
+#*      *##set ( $target = ' target="' + $banner.target + '"' )
 #*    *##else
-#*      *##set ( $imgWidth = "" )
+#*      *##set ( $target = "" )
 #*    *##end
-#*    *##if( $banner.height )
-#*      *##set ( $imgHeight = 'height: ' + $banner.height + ';' )
+#*    *#<a href="$href"$target>##
+#*  *##end
+##
+#*  *##if( $banner.image )
+#*    *##set ( $img = "#image2( $banner.image )" )
+#*    *##if( $banner.image.position == "left" )
+#*      *#$img#if ( $name ) $name#end##
 #*    *##else
-#*      *##set ( $imgHeight = "" )
+#*      *##if ( $name )$name #end$img##
 #*    *##end
-#*    *#<img src="$src"$alt style="$imgBorder$imgWidth$imgHeight" />##
 #*  *##else
-#*    *#<h1>$esc.xml( $banner.name )</h1>
+#*    *#$name##
 #*  *##end
 ##
 #*  *##if( $banner.href )
 #*    *#</a>##
-#*  *##else
-#*    *#</div>
 #*  *##end
+#*  *#</h1></div>
 #**##end
 #end
 ##

Reply via email to