Projekt-Seite erstellt: Velocity-Template - parent-Definition überschreibbar
[simple-mapper] / src / site / template.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 #set ( $parent = $decoration.custom.getChild( 'thymeproxy' ).getChild( 'parent' ).getValue() )
105
106 <!-- title: $title -->
107 <!-- short title: $shortTitle -->
108 <!-- current: $alignedFileName -->
109 <!-- path: $sitePath -->
110 <!-- crumbs: $siteCrumbs -->
111 <!-- pages: $pages -->
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="title='$title', uri='$sitePath$alignedFileName'"
119     >
120   <head>
121     <title>juplo - $title</title>
122     <!--/*-->
123     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
124     <link rel="stylesheet/less" type="text/css" href="../../less/base.less"/>
125     <link rel="stylesheet/less" type="text/css" href="../../less/screen.less" media="screen"/>
126     <link rel="stylesheet/less" type="text/css" href="../../less/print.less" media="print"/>
127     <script src="../../js/less-1.7.0.min.js"></script>
128     <!--*/-->
129     <link rel="canonical" href="$sitePath$alignedFileName"/>
130   </head>
131   <body
132       thymeproxy:variables="merge:{&quot;pages&quot;:{#if($parent)$parent#end#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}"
133       >
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       <header><h1>$shortTitle</h1></header>
143       $bodyContent
144     </article>
145     <hr />
146     <h2>Common</h2>
147     <ul>
148       <li><strong>Parent</strong>: $parent</li>
149       <li><strong>Title</strong>: $title</li>
150       <li><strong>Short Title</strong>: $shortTitle</li>
151       <li><strong>Current</strong>: $alignedFileName</li>
152       <li><strong>Path</strong>: $sitePath</li>
153       <li><strong>Crumbs</strong>: $siteCrumbs</li>
154       <li><strong><code>title</code></strong>: $siteTitle</li>
155       <li><strong><code>alt</code></strong>: $siteAlt</li>
156       <li><strong><code>img</code></strong>: $siteImg</li>
157     </ul>
158     <h2>Pages</h2>
159     <ul>
160       #foreach($page in $pages)
161       <li>
162         <a href="$sitePath$page.uri" title="$page.title">
163           #if($page.img)
164             <img src="$page.img" alt="$page.alt"/>
165           #end
166           $page.name
167         </a>
168         #if($page.title)
169           <code>title</code>=$page.title
170         #end
171         #if($page.img)
172           <code>img</code>=$page.img
173         #end
174         #if($page.alt)
175           <code>alt</code>=$page.alt
176         #end
177         #if(!$page.childs.isEmpty())
178         <br />
179         Childs:
180         <ol>
181           #foreach($child in $page.childs.entrySet())
182           <li><a href="$sitePath$child.key">$child.value</a></li>
183           #end
184         </ol>
185         #end
186       </li>
187       #end
188     </ul>
189     <h2>Crumbs</h2>
190     <ol>
191       #foreach($crumb in $page.crumbs)
192       <li><a href="$sitePath$crumb.uri">$crumb.name</a></li>
193       #end
194     </ol>
195   </body>
196 </html>