## ## Content Stylesheet for Site ## ## Defined variables ## #set ($year = $date.getYear()+1900) ## ## Start and end the processing ## #document() ## ## This is where the macros live ## #macro ( color_table $table ) #set ($table = $table.setAttribute("class", "colortable")) #foreach ( $tw in $treeWalk.allElements($table) ) #if ($tw.getName().equals("trh")) #set ($tw = $tw.setAttribute("align", "left")) #set ($tw = $tw.setName("th")) #end #end #if (! $table.getAttributeValue("width")) #set ($table = $table.setAttribute("width", "100%")) #end $table #end ## #macro ( make_toc ) #set ($allSections = $root.getChild("body").getChildren("section")) #end ## ## #macro ( make_note $note)
$note
#end ## ## #macro ( metaauthor $author $email ) #end ## ## #macro ( metaatom $title $url ) #end ## ## #macro ( source $value )
$escape.getText($value.getText())
#end ## ## #macro ( section $section $level ) #if ($section.getChild("title")) #set ($heading = $section.getChildText("title")) #elseif ($section.getAttributeValue("id")) #set ($heading = $section.getAttributeValue("id")) #else #set ($heading = "") #end ## add id="anchor" as link target rather than #set ($tmp = "$!section.getAttributeValue('id')") #if ($tmp != "")#set ($id=" id='$tmp'")#else#set ($id="")#end #if ($level == 1) $heading #elseif ($level == 2) $heading #elseif ($level == 3) $heading #else $heading #end
## output the section-level children with transformers #foreach ( $items in $section.getChildren() ) #if ($items.getName().equals("source")) #source ($items) #elseif ($items.getName().equals("table")) #color_table ($items) #elseif ($items.getName().equals("note")) #make_note ($items) #elseif ($items.getName().equals("toc")) #make_toc () #elseif ($items.getName().equals("section")) ##set ($sublevel = $level + 1) #if ($level == 1) #section ($items 2) #elseif ($level == 2) #section ($items 3) #elseif ($level == 3) #section ($items 4) #else #section ($items 5) #end #elseif ($items.getName().equals("title")) ## we already handled this one #else $items #end #end
#end ## ## #macro ( makeProject ) #set ($menus = $project.selectNodes("body/menu")) #foreach ( $menu in $menus ) #set ($title = $menu.getChild("title")) #if ($title.getAttributeValue("href"))
#else #end #foreach ( $item in $menu.getChildren("li") ) $item #end #end #end ## ## #macro ( listProjects ) #set ($menus = $project.selectNodes("body/projects")) #foreach ( $menu in $menus ) #set ($title = $menu.getChild("title")) ## Convert site-absolute links to site-relative #set ( $href = "$!title.getAttributeValue('href')" ) #if ($href != "") #if ($href.startsWith("/")) #set ($href = "$relativePath$href") #end #else #end #foreach ( $item in $menu.getChildren("li") ) ## much simpler than descending the tree here $item.toString().replaceAll(" #end #end ## ## #macro ( getProjectImage )
The Apache Software Foundation
The Apache Software Foundation Incubator
#end ## ## #macro ( document ) #if ( $root.getChild("properties").getChild("base") ) $root.getChild("properties").getChild("base") #end #set ($atoms = $root.getChild("properties").getChildren("atom")) #foreach ( $atom in $atoms ) #metaatom ( $atom.getText() $atom.getAttributeValue("url") ) #end #set ($authors = $root.getChild("properties").getChildren("author")) #foreach ( $au in $authors ) #metaauthor ( $au.getText() $au.getAttributeValue("email") ) #end $root.getChild("properties").getChild("title").getText() - $project.getChild("title").getText() #set ($scripts = $root.getChild("properties").getChildren("script")) #if ( $scripts ) $scripts #end
#getProjectImage()

#listProjects()
#set ($allSections = $root.getChild("body").getChildren("section")) #foreach ( $section in $allSections ) #section ($section 1) #end

#end