JSON is handed to the thymeleaf-layout-template via th:with
[maven-thymeleaf-skin] / src / main / resources / META-INF / maven / site.vm
1 <!DOCTYPE html>
2 <!--/*-->
3 <!-- Generated by Apache Maven Doxia Site Renderer#if( $doxiaSiteRendererVersion ) $doxiaSiteRendererVersion#end at $dateFormat.format( $currentDate ) -->
4
5
6 #set ( $pages = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
7 #set ( $stack = $project.getClass().forName('java.util.LinkedList').newInstance() )
8 #macro ( buildPages $menu )
9
10   #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
11   #set ( $currentItemHref = $currentItemHref.replaceAll( '\\', '/' ) )
12
13   #if ($currentItemHref)
14     #set( $sinkhole = $stack.peek().childs.put($currentItemHref, $menu.name) )
15   #end
16
17   #set ( $page = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
18   #set ( $sinkhole = $page.put("name", $menu.name) )
19   #set ( $sinkhole = $page.put("uri", $currentItemHref) )
20   #set ( $sinkhole = $page.put("childs", $project.getClass().forName('java.util.LinkedHashMap').newInstance()) )
21   #set ( $sinkhole = $stack.push( $page ) )
22
23   #if ($menu.title)
24     #set( $sinkhole = $page.put("title", $menu.title) )
25   #end
26   #if ($menu.alt)
27     #set( $sinkhole = $page.put("alt", $menu.alt) )
28   #end
29   #if ($menu.img)
30     #set( $sinkhole = $page.put("img", $menu.img) )
31   #end
32
33   #foreach ( $item in $menu.items )
34     #buildPages ( $item )
35   #end
36
37   #set ( $page = $stack.pop() )
38   #if ( $page.uri != "" )
39
40     #set ( $crumbs = $project.getClass().forName('java.util.LinkedList').newInstance() )
41     #set ( $crumb = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
42     #set ( $sinkhole = $crumb.put("uri", $page.uri) )
43     #set ( $sinkhole = $crumb.put("name", $page.name) )
44     #set ( $sinkhole = $crumbs.push($crumb) )
45     #foreach ( $entry in $stack )
46       #if ( $entry.uri != "" )
47         #set ( $crumb = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
48         #set ( $sinkhole = $crumb.put("uri", $entry.uri) )
49         #set ( $sinkhole = $crumb.put("name", $entry.name) )
50         #set ( $sinkhole = $crumbs.push($crumb) )
51       #end
52     #end
53     #set ( $sinkhole = $page.put("crumbs", $crumbs) )
54
55     #if ( $pages.containsKey($page.uri) )
56       #set ( $childs = $pages.get($page.uri).childs )
57       #set ( $sinkhole = $page.put("childs", $childs) )
58
59       <!-- OVERWRITING PAGE - uri: $page.uri, path: $crumbs, name: "$page.name", childs: $page.childs -->
60     #else
61
62       <!-- NEW PAGE - - - - - uri: $page.uri, path: $crumbs, name: "$page.name", childs: $page.childs -->
63     #end
64
65     #set ( $sinkhole = $pages.put($page.uri, $page) )
66
67   #else
68
69     <!-- DONE WITH MENUE -  - #if($page.name)$page.name-->#else(no name)-->
70       #set( $siteTitle = $menu.title )
71       #set( $siteAlt = $menu.alt )
72       #set( $siteImg = $menu.img )
73       #set( $sinkhole = $pages.get("index.html").put("childs", $page.childs) )
74     #end
75
76   #end
77 #end
78
79
80 ## Seiten einlesen
81 #set ( $page = $project.getClass().forName('java.util.LinkedHashMap').newInstance() )
82 #set ( $sinkhole = $page.put("uri", "index.html") )
83 #set ( $sinkhole = $page.put("name", "$project.name") )
84 #set ( $sinkhole = $stack.push($page) )
85 #foreach ( $menu in $decoration.body.menus )
86   ## Nur benannte Menüs werden berücksichtigt
87   #if ($menu.name)
88     #buildPages ( $menu )
89   #end
90 #end
91 #foreach ( $menu in $decoration.body.menus )
92   ## Nur unbenannte Menüs werden berücksichtigt
93   #if (!($menu.name))
94     #buildPages ( $menu )
95   #end
96 #end
97
98 ## Custom Variablen einlesen
99 #set ( $sitePath = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'path' ).getValue() )
100 #if ( !$sitePath )
101   #set ( $sitePath = "" )
102 #end
103 #set ( $siteCrumbs = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'crumbs' ).getValue() )
104
105 <!-- title: $title -->
106 <!-- short title: $shortTitle -->
107 <!-- current page: $alignedFileName -->
108 <!-- path: $sitePath -->
109 <!-- crumbs: $siteCrumbs -->
110 <!-- pages: $pages -->
111
112
113 <!--*/-->
114 <html
115     xmlns="http://www.w3.org/1999/xhtml"
116     xmlns:layout="http://www.thymeleaf.org"
117     layout:decorator="templates/layout"
118     th:with="
119       uri='$sitePath$alignedFileName',
120       json='merge:{&quot;pages&quot;:{#set($sep = "")#foreach($page in $pages)$sep&quot;$sitePath$page.uri&quot;:{&quot;name&quot;:&quot;$page.name&quot;,#if(!$page.childs.isEmpty())&quot;childs&quot;:{#set($csep = "")#foreach($child in $page.childs.entrySet())$csep&quot;$sitePath$child.key&quot;:&quot;$child.value&quot;#set($csep = ",")#end},#end&quot;crumbs&quot;:[#set($csep = "")#if($siteCrumbs)$siteCrumbs#set($csep = ",")#end#foreach($crumb in $page.crumbs)$csep{&quot;uri&quot;:&quot;$sitePath$crumb.uri&quot;,&quot;name&quot;:&quot;$crumb.name&quot;}#set($csep = ",")#end]#if($page.title),&quot;title&quot;:&quot;$page.title&quot;#end#if($page.alt),&quot;alt&quot;:&quot;$page.alt&quot;#end#if($page.img),&quot;img&quot;:&quot;$page.img&quot;#end}#set($sep = ",")#end}#if($siteTitle),&quot;site_title&quot;:&quot;$siteTitle&quot;#end#if($siteAlt),&quot;site_alt&quot;:&quot;$siteAlt&quot;#end#if($siteImg),&quot;site_img&quot;:&quot;$siteImg&quot;#end}'
121       "
122     >
123   <head>
124     <title>juplo - $title</title>
125     <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />
126     <link rel="canonical" href="$sitePath$alignedFileName"/>
127   </head>
128   <body>
129     <h2>Path</h2>
130     <p>
131       <ol>
132         #foreach($crumb in $pages.get($alignedFileName).crumbs)<li><a href="$crumb.uri">$crumb.name</a></li>#end
133       </ol>
134     </p>
135     <hr />
136     <article class="main" layout:fragment="maincontent">
137       <header><h1>$shortTitle</h1></header>
138       $bodyContent
139     </article>
140     <hr />
141     <h2>Pages</h2>
142     <p>
143       <ul>
144         #foreach($page in $pages)<li><a href="$page.uri">$page.name</a></li>#end
145       </ul>
146     </p>
147   </body>
148 </html>