WIP: Normal links are rendered...
[maven-thymeleaf-skin] / src / main / resources / META-INF / maven / site.vm
index 7afc958..50bd7ca 100644 (file)
@@ -1,4 +1,5 @@
 <!DOCTYPE html>
+<!--/*-->
 <!-- Generated by Apache Maven Doxia Site Renderer#if( $doxiaSiteRendererVersion ) $doxiaSiteRendererVersion#end at $dateFormat.format( $currentDate ) -->
 
 
@@ -6,7 +7,11 @@
 #set ( $stack = $project.getClass().forName('java.util.LinkedList').newInstance() )
 #macro ( buildPages $menu )
 
-  #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
+  #if ( $menu.href )
+    #set ( $currentItemHref = $PathTool.calculateLink( $menu.href, $relativePath ) )
+  #else
+    #set ( $currentItemHref = '' )
+  #end
   #set ( $currentItemHref = $currentItemHref.replaceAll( '\\', '/' ) )
 
   #if ($currentItemHref)
   #if ( $page.uri != "" )
 
     #set ( $crumbs = $project.getClass().forName('java.util.LinkedList').newInstance() )
+    #set ( $crumb = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
+    #set ( $sinkhole = $crumb.put("uri", $page.uri) )
+    #set ( $sinkhole = $crumb.put("name", $page.name) )
+    #set ( $sinkhole = $crumbs.push($crumb) )
     #foreach ( $entry in $stack )
       #if ( $entry.uri != "" )
         #set ( $crumb = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
       #set ( $childs = $pages.get($page.uri).childs )
       #set ( $sinkhole = $page.put("childs", $childs) )
 
-      <!-- OVERWRITING PAGE - uri: $page.uri, path: $crumbs, name: "$page.name", childs: $page.childs -->
+      <!-- OVERWRITING PAGE - uri: $page.uri -->
     #else
 
-      <!-- NEW PAGE - - - - - uri: $page.uri, path: $crumbs, name: "$page.name", childs: $page.childs -->
+      <!-- NEW PAGE - - - - - uri: $page.uri -->
     #end
 
     #set ( $sinkhole = $pages.put($page.uri, $page) )
@@ -65,6 +74,7 @@
       #set( $siteTitle = $menu.title )
       #set( $siteAlt = $menu.alt )
       #set( $siteImg = $menu.img )
+      #set( $sinkhole = $pages.get("index.html").put("childs", $page.childs) )
     #end
 
   #end
@@ -73,8 +83,8 @@
 
 ## Seiten einlesen
 #set ( $page = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
-#set ( $sinkhole = $page.put("uri", $alignedFileName) )
-#set ( $sinkhole = $page.put("name", "About") )
+#set ( $sinkhole = $page.put("uri", "index.html") )
+#set ( $sinkhole = $page.put("name", "$project.name") )
 #set ( $sinkhole = $stack.push($page) )
 #foreach ( $menu in $decoration.body.menus )
   ## Nur benannte Menüs werden berücksichtigt
 #end
 
 ## Custom Variablen einlesen
-#set ( $sitePath = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'path' ).getValue() )
-#if ( !$sitePath )
-  #set ( $sitePath = "" )
+#set ( $canonicalPath = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'path' ).getValue() )
+#if ( !$canonicalPath )
+  #set ( $canonicalPath = "" )
 #end
+#set ( $sitePath = $canonicalPath + $project.version + "/" )
 #set ( $siteCrumbs = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'crumbs' ).getValue() )
 
+<!-- name: $pages.get($alignedFileName).name -->
 <!-- title: $title -->
 <!-- short title: $shortTitle -->
 <!-- current page: $alignedFileName -->
 <!-- pages: $pages -->
 
 
+<!--*/-->
 <html
     xmlns="http://www.w3.org/1999/xhtml"
-    xmlns:layout="http://www.thymeleaf.org"
-    layout:decorator="templates/layout"
-    th:with="uri='$sitePath$alignedFileName'"
+    th:replace="~{/templates/layout.html :: layout(
+      uri='$sitePath$alignedFileName',
+      json='MERGE:
+      {
+        &quot;_names&quot;: {
+          #set($sep = "")
+          #foreach($page in $pages)
+            $sep
+            &quot;$sitePath$page.uri&quot;: &quot;$page.name&quot;
+            #set($sep = ",")
+          #end
+        },
+        &quot;_childs&quot;: {
+          #set($sep = "")
+          #foreach($page in $pages)
+            #if(!$page.childs.isEmpty())
+              $sep
+              &quot;$sitePath$page.uri&quot;: [
+                #set($csep = "")
+                #foreach($child in $page.childs.entrySet())
+                  $csep
+                  &quot;$sitePath$child.key&quot;
+                  #set($csep = ",")
+                #end
+              ]
+              #set($sep = ",")
+            #end
+          #end
+        },
+        &quot;_crumbs&quot;: {
+          #set($sep = "")
+          #foreach($page in $pages)
+            $sep
+            &quot;$sitePath$page.uri&quot;: [
+              #set($csep = "")
+              #if($siteCrumbs)
+                $siteCrumbs
+                #set($csep = ",")
+              #end
+              #set($last = "")
+              #foreach($crumb in $page.crumbs)
+                #if($sitePath+$crumb.uri != $last)
+                  $csep
+                  &quot;$sitePath$crumb.uri&quot;
+                  #set($csep = ",")
+                  #set($last = $sitePath+$crumb.uri)
+                #end
+              #end
+            ]
+            #set($sep = ",")
+          #end
+        }
+      }
+      ')}"
     >
   <head>
-    <title>juplo - $title</title>
+    <title id="title">#if($shortTitle and $shortTitle != '')$title#else$project.name &mdash; $pages.get($alignedFileName).name#end</title>
     <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />
-    <link rel="canonical" href="$sitePath$alignedFileName"/>
+    <link id="canonical" rel="canonical" href="$canonicalPath$alignedFileName"/>
   </head>
   <body>
     <h2>Path</h2>
       </ol>
     </p>
     <hr />
-    <article class="main" layout:fragment="maincontent" juplo:variables='merge:{"pages":{#set($sep = "")#foreach($page in $pages)$sep"$sitePath$page.uri":{"name":"$page.name",#if(!$page.childs.isEmpty())"childs":{#set($csep = "")#foreach($child in $page.childs.entrySet())$csep"$sitePath$child.key":"$child.value"#set($csep = ",")#end},#end"crumbs":[#set($csep = "")#if($siteCrumbs)$siteCrumbs#set($csep = ",")#end#foreach($crumb in $page.crumbs)$csep{"uri":"$sitePath$crumb.uri","name":"$crumb.name"}#set($csep = ",")#end]#if($page.title),"title":"$page.title"#end#if($page.alt),"alt":"$page.alt"#end#if($page.img),"img":"$page.img"#end}#set($sep = ",")#end}#if($siteTitle),"site_title":"$siteTitle"#end#if($siteAlt),"site_alt":"$siteAlt"#end#if($siteImg),"site_img":"$siteImg"#end}'>
-      <header><h1>$shortTitle</h1></header>
+    <article class="maincontent">
       $bodyContent
     </article>
     <hr />