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