Author: twilliams Date: Tue Jun 8 02:34:31 2010 New Revision: 952512 URL: http://svn.apache.org/viewvc?rev=952512&view=rev Log: Add some trivial autonavigation for now
Added: forrest/trunk/whiteboard/f9/src/main/resources/project/ forrest/trunk/whiteboard/f9/src/main/resources/project/css/ forrest/trunk/whiteboard/f9/src/main/resources/project/css/style.css (with props) forrest/trunk/whiteboard/f9/src/main/resources/project/images/ forrest/trunk/whiteboard/f9/src/main/resources/project/images/group-logo.gif (with props) forrest/trunk/whiteboard/f9/src/main/resources/project/images/group.svg (with props) forrest/trunk/whiteboard/f9/src/main/resources/project/images/icon-e.png (with props) forrest/trunk/whiteboard/f9/src/main/resources/project/images/project-logo.gif (with props) forrest/trunk/whiteboard/f9/src/main/resources/project/images/project.svg (with props) forrest/trunk/whiteboard/f9/src/main/resources/project/images/usemap.gif (with props) forrest/trunk/whiteboard/f9/src/main/resources/project/scripts/ forrest/trunk/whiteboard/f9/src/main/resources/project/site.xsl (with props) Modified: forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/Main.scala forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/filters/HtmlFileSink.scala forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/task/BuildTask.scala Added: forrest/trunk/whiteboard/f9/src/main/resources/project/css/style.css URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/css/style.css?rev=952512&view=auto ============================================================================== --- forrest/trunk/whiteboard/f9/src/main/resources/project/css/style.css (added) +++ forrest/trunk/whiteboard/f9/src/main/resources/project/css/style.css Tue Jun 8 02:34:31 2010 @@ -0,0 +1,48 @@ +body { + font-family: "Verdana", sans-serif; + font-size: 80%; +} + +#flite-content-wrapper { + +} + +#flite-header { + background: #eeeeee; + text-align: center; + font-size: x-large; +} + +#flite-content { + float:right; + width: 65%; + margin-left: 5%; +} + +#flite-left { + + width: 30%; + list-style: none; + border: 1px solid #dddddd; + margin: 5px; +} + +#flite-left ul, #flite-left li{ + list-style: none; + margin: 0px; + padding-left: 4px; + padding-top: 4px; + text-decoration: none; +} + +#flite-left > ul > li > a { + font-weight: bold; + font-family: "Lucida Grande", sans-serif; +} + + + +#flite-footer { + clear: both; + background: #eeeeee; +} \ No newline at end of file Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/css/style.css ------------------------------------------------------------------------------ svn:eol-style = native Added: forrest/trunk/whiteboard/f9/src/main/resources/project/images/group-logo.gif URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/images/group-logo.gif?rev=952512&view=auto ============================================================================== Binary file - no diff available. Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/images/group-logo.gif ------------------------------------------------------------------------------ svn:mime-type = image/gif Added: forrest/trunk/whiteboard/f9/src/main/resources/project/images/group.svg URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/images/group.svg?rev=952512&view=auto ============================================================================== --- forrest/trunk/whiteboard/f9/src/main/resources/project/images/group.svg (added) +++ forrest/trunk/whiteboard/f9/src/main/resources/project/images/group.svg Tue Jun 8 02:34:31 2010 @@ -0,0 +1,82 @@ +<?xml version="1.0" standalone="no"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + SVG Anteater logo + +To get started with SVG, I'd recommend getting the Adobe SVG plugin, and the +xml-batik CVS module. Then have a look at the xml-batik/samples files. Use the +SVG spec (http://www.w3.org/TR/SVG/) as a reference. +--> + +<!-- See Forrest Issue: FOR-229 +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" +"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" +[ + <!ATTLIST svg xmlns:for CDATA #FIXED "http://apache.org/forrest"> + <!ENTITY % textExt "|for:group-name"> + <!ELEMENT for:group-name (#PCDATA)> +]> +--> +<svg xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xsl:version="1.0" + xmlns:for="http://apache.org/forrest" + width="220" height="65" > + <title>Anteater logo</title> + + <defs> + + <!-- + <radialGradient id="radialGradient"> + <stop style="stop-color:gold" offset="0"/> + <stop style="stop-color:orange" offset=".5"/> + <stop style="stop-color:crimson" offset="1"/> + </radialGradient> + <linearGradient id="linearGradient"> + <stop style="stop-color:gold" offset="0"/> + <stop style="stop-color:orange" offset=".5"/> + <stop style="stop-color:crimson" offset="1"/> + </linearGradient> + --> + + <linearGradient id="gradient" x1="0" y1="0" x2="0" y2="1"> + <stop style="stop-color:white" offset="0"/> + <stop style="stop-color:lightgreen" offset="1"/> + </linearGradient> + + <filter id="shadowFilter" filterUnits="objectBoundingBox" width="1.4" height="1.4"> + <!-- Takes the alpha channel (black outline of the text), blurs it and saves as 'blur' --> + <feGaussianBlur in="SourceAlpha" stdDeviation="2 2" result="blur"/> + <!-- Takes saved 'blur' and offsets it by 4 pixels, saves as 'offsetBlur' --> + <feOffset in="blur" dx="4" dy="4" result="offsetBlur"/> + <!-- Merges SourceGraphic (original image) and 'offsetBlur', putting the + former 'over' the latter, and using the merged result as the finished + image --> + <feComposite in="SourceGraphic" in2="offsetBlur" operator="over"/> + </filter> + + </defs> + + <g filter="url(#shadowFilter)" fill="url(#gradient)"> + <text x="40%" y="60%" style="font-size:24pt; font-family:Verdana ; text-anchor: middle"> + <for:group-name /> + </text> + </g> +</svg> Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/images/group.svg ------------------------------------------------------------------------------ svn:eol-style = native Added: forrest/trunk/whiteboard/f9/src/main/resources/project/images/icon-e.png URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/images/icon-e.png?rev=952512&view=auto ============================================================================== Binary file - no diff available. Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/images/icon-e.png ------------------------------------------------------------------------------ svn:mime-type = image/png Added: forrest/trunk/whiteboard/f9/src/main/resources/project/images/project-logo.gif URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/images/project-logo.gif?rev=952512&view=auto ============================================================================== Binary file - no diff available. Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/images/project-logo.gif ------------------------------------------------------------------------------ svn:mime-type = image/gif Added: forrest/trunk/whiteboard/f9/src/main/resources/project/images/project.svg URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/images/project.svg?rev=952512&view=auto ============================================================================== --- forrest/trunk/whiteboard/f9/src/main/resources/project/images/project.svg (added) +++ forrest/trunk/whiteboard/f9/src/main/resources/project/images/project.svg Tue Jun 8 02:34:31 2010 @@ -0,0 +1,80 @@ +<?xml version="1.0" standalone="no"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- +To get started with SVG, recommend getting the Adobe SVG plugin, and the +xml-batik CVS module. Then have a look at the xml-batik/samples files. Use the +SVG spec (http://www.w3.org/TR/SVG/) as a reference. +--> + +<!-- See Forrest Issue: FOR-229 +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" +"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" +[ + <!ATTLIST svg xmlns:for CDATA #FIXED "http://apache.org/forrest"> + <!ENTITY % textExt "|for:project-name"> + <!ELEMENT for:project-name (#PCDATA)> +]> +--> +<svg xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xsl:version="1.0" + xmlns:for="http://apache.org/forrest" + width="520" height="65" > + <title>Project logo</title> + + <defs> + + <!-- + <radialGradient id="radialGradient"> + <stop style="stop-color:gold" offset="0"/> + <stop style="stop-color:orange" offset=".5"/> + <stop style="stop-color:crimson" offset="1"/> + </radialGradient> + <linearGradient id="linearGradient"> + <stop style="stop-color:gold" offset="0"/> + <stop style="stop-color:orange" offset=".5"/> + <stop style="stop-color:crimson" offset="1"/> + </linearGradient> + --> + + <linearGradient id="gradient" x1="0" y1="0" x2="0" y2="1"> + <stop style="stop-color:white" offset="0"/> + <stop style="stop-color:lightgreen" offset="1"/> + </linearGradient> + + <filter id="shadowFilter" filterUnits="objectBoundingBox" width="1.4" height="1.4"> + <!-- Takes the alpha channel (black outline of the text), blurs it and saves as 'blur' --> + <feGaussianBlur in="SourceAlpha" stdDeviation="2 2" result="blur"/> + <!-- Takes saved 'blur' and offsets it by 4 pixels, saves as 'offsetBlur' --> + <feOffset in="blur" dx="4" dy="4" result="offsetBlur"/> + <!-- Merges SourceGraphic (original image) and 'offsetBlur', putting the + former 'over' the latter, and using the merged result as the finished + image --> + <feComposite in="SourceGraphic" in2="offsetBlur" operator="over"/> + </filter> + + </defs> + + <g filter="url(#shadowFilter)" fill="url(#gradient)"> + <text x="99%" y="60%" style="font-size:24pt; font-family:Verdana ; text-anchor: end" > + <for:project-name /> + </text> + </g> +</svg> Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/images/project.svg ------------------------------------------------------------------------------ svn:eol-style = native Added: forrest/trunk/whiteboard/f9/src/main/resources/project/images/usemap.gif URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/images/usemap.gif?rev=952512&view=auto ============================================================================== Binary file - no diff available. Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/images/usemap.gif ------------------------------------------------------------------------------ svn:mime-type = image/gif Added: forrest/trunk/whiteboard/f9/src/main/resources/project/site.xsl URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/resources/project/site.xsl?rev=952512&view=auto ============================================================================== --- forrest/trunk/whiteboard/f9/src/main/resources/project/site.xsl (added) +++ forrest/trunk/whiteboard/f9/src/main/resources/project/site.xsl Tue Jun 8 02:34:31 2010 @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:variable name="nav" select="document('/nav.xml')"/> + <xsl:template match="/"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="body"> + <div id="flite-content-wrapper"> + <div id="flite-header"></div> + <div id="flite-content"> + <xsl:apply-templates/> + </div> + <div id="flite-left"> + <xsl:copy-of select="$nav"/> + </div> + <div id="flite-footer">Footer</div> + </div> + </xsl:template> + + <xsl:template match="head"> + <link rel="stylesheet" type="text/css" href="/resources/css/style.css" media="screen"/> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="node() | @*"> + <xsl:copy> + <xsl:apply-templates select="@*"/> + <xsl:apply-templates/> + </xsl:copy> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file Propchange: forrest/trunk/whiteboard/f9/src/main/resources/project/site.xsl ------------------------------------------------------------------------------ svn:eol-style = native Modified: forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/Main.scala URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/Main.scala?rev=952512&r1=952511&r2=952512&view=diff ============================================================================== --- forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/Main.scala (original) +++ forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/Main.scala Tue Jun 8 02:34:31 2010 @@ -31,7 +31,6 @@ object Main { // we have to always init first, so ignore CL args var state = "init" var next = "" - val currDir = new File(".") while(true) { state match { Modified: forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/filters/HtmlFileSink.scala URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/filters/HtmlFileSink.scala?rev=952512&r1=952511&r2=952512&view=diff ============================================================================== --- forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/filters/HtmlFileSink.scala (original) +++ forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/filters/HtmlFileSink.scala Tue Jun 8 02:34:31 2010 @@ -10,7 +10,7 @@ import java.io.FileWriter class HtmlFileSink(base: String) extends Filter { private val xmldecl = "<?xml version='1.0' encoding='UTF-8'?>\n" private val extension = ".xhtml" - private val pinst = "<?xml-stylesheet type=\"text/xsl\" href=\"/resources/site.xsl\"?>\n" + private val pinst = "<?xml-stylesheet type=\"text/xsl\" href=\"/resources/f9/site.xsl\"?>\n" def process(model: Map[String, Any]) = { println("Processing HtmlFileSink: " + model("requestUri")) Modified: forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/task/BuildTask.scala URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/task/BuildTask.scala?rev=952512&r1=952511&r2=952512&view=diff ============================================================================== --- forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/task/BuildTask.scala (original) +++ forrest/trunk/whiteboard/f9/src/main/scala/org/apache/forrest/f9/task/BuildTask.scala Tue Jun 8 02:34:31 2010 @@ -28,10 +28,21 @@ object BuildTask extends Task("build", f def call(state: AppState):Boolean = { println("Incoming state: " + state.projectDir) base = new File(state.projectDir, "sources/docs") - val resBase = new File(state.projectDir, "sources/resources") - val resOut = new File(state.projectDir, "output/resources") + val resBase = new File(state.projectDir, "src/main/resources/project") + val resOut = new File(state.projectDir, "output/resources/f9") + //Copy all the static resources over. FileUtils.copyDirectory(resBase, resOut) + + //Maybe create some autonav for them. + val srcNav = new File(state.projectDir, "sources/docs/nav.xml") + + if(!srcNav.exists) { + FileUtils.writeStringToFile( new File(state.projectDir, "output/nav.xml"), + "<?xml version=\"1.0\"?>" + getNav(base, state)) + } + + //Now, go ahead and generate the main content. call(base) true } @@ -46,7 +57,7 @@ object BuildTask extends Task("build", f */ private def call(f: File) { - if(!f.isDirectory()) { + if(!f.isDirectory() && !f.isHidden()) { val file = new File(base, f.getPath) val r = Map("requestUri"->(f.getCanonicalPath.replace(base.getCanonicalPath, "")), "contentType"->"application/xhtml+xml") @@ -58,5 +69,60 @@ object BuildTask extends Task("build", f }) } } + + + + def getNav(d: File, state: AppState): String = { + val buf = new StringBuilder + //println("CONTENT_DIR: " + d.getAbsolutePath) + //println(".. relative: " + d.getAbsolutePath.replace(contentDirFile.getAbsolutePath,"")) + if (d.isHidden) return buf.toString + + if(d.isDirectory() && !d.isHidden) { + + if(isVisible(d)) { + buf.append("<ul><li>") + buf.append(format(d.getName)) + buf.append("<ul>") + d.listFiles().foreach((f: File) => { + buf.append(getNav(f, state)) + }) + buf.append("</ul>") + buf.append("</li></ul>") + } + } else { + val srcpath = new File(state.projectDir, "sources/docs") + val path = srcpath.toURI.relativize(d.toURI) + buf.append("<li><a href=\"/") + /** + * TODO: I'm not at all sure where this is going. I'd like to be able to auto + * generate some nav for simple sites. I reckon we need some notion of a default + * Media Type which implies an extension, but not sure. Ideally, no extension with + * HTTP Conneg would take place maybe. + **/ + buf.append(path.toString.replace(".xml",".xhtml")) + buf.append("\">") + buf.append(format(d.getName)) + buf.append("</a></li>") + } + + buf.toString + } + + def format(s: String): String = { + val s2 = s.replace("_"," ").capitalize + + + if (s2.lastIndexOf(".") > 0) + s2.substring(0,s2.lastIndexOf(".")) + else + s2 + } + def isVisible(dir: File): Boolean = { + val hideme = new File(dir.getAbsolutePath() + "/hideme") + + return !hideme.exists() + + } } \ No newline at end of file