Projekt-Seite erstellt: Velocity-Template - site-path und crumbs von Config
authorKai Moritz <kai@juplo.de>
Fri, 8 Jul 2016 09:23:26 +0000 (11:23 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 11 Jul 2016 16:57:55 +0000 (18:57 +0200)
Die URI-Pfade und der generierte Breadrumb-Path werden durch Informationen
aus der Konfigurationsdatei src/site/site.xml erg√§nzt.

src/site/site.xml
src/site/template.vm

index 02fc7c8..ce59948 100644 (file)
@@ -9,4 +9,10 @@
     </menu>
     <menu ref="reports"/>
   </body>
+  <custom>
+    <thymeproxy>
+      <path>/simple-mapper/</path>
+      <crumbs>{"uri":"/projects.html","name":"Projects"},{"uri":"/simple-mapper/index.html","name":"Simple Mapper 4 JSON"}</crumbs>
+    </thymeproxy>
+  </custom>
 </project>
index 6a5b765..01e16bf 100644 (file)
   #end
 #end
 
+## Custom Variablen einlesen
+#set ( $sitePath = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'path' ).getValue() )
+#if ( !$sitePath )
+  #set ( $sitePath = "" )
+#end
+#set ( $siteCrumbs = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'crumbs' ).getValue() )
 
 <!-- title: $title -->
 <!-- short title: $shortTitle -->
 <!-- current page: $alignedFileName -->
+<!-- path: $sitePath -->
+<!-- crumbs: $siteCrumbs -->
 <!-- pages: $pages -->
 
 
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:layout="http://www.thymeleaf.org"
     layout:decorator="templates/layout"
-    th:with="uri='$alignedFileName'"
+    th:with="uri='$sitePath$alignedFileName'"
     >
   <head>
     <title>juplo - $title</title>
     <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />
-    <link rel="canonical" href="$project.url/$alignedFileName"/>
+    <link rel="canonical" href="$sitePath$alignedFileName"/>
   </head>
   <body>
-    <article class="main" layout:fragment="maincontent" juplo:variables='merge:{"pages":{#set($sep = "")#foreach($page in $pages)$sep"$page.uri":{"name":"$page.name",#if(!$page.childs.isEmpty())"childs":{#set($csep = "")#foreach($child in $page.childs.entrySet())$csep"$child.key":"$child.value"#set($csep = ",")#end},#end"crumbs":[#set($csep = "")#foreach($crumb in $page.crumbs)$csep{"uri":"$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}'>
+    <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>
       $bodyContent
     </article>