Revision: 1673 http://svn.sourceforge.net/vexi/?rev=1673&view=rev Author: mkpg2 Date: 2007-02-14 00:08:56 -0800 (Wed, 14 Feb 2007)
Log Message: ----------- Use getResource (can execute as a jar) for resources. Modified Paths: -------------- tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/FreemarkerGenerator.java tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/Main.java tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/util/Util.java Added Paths: ----------- tools/trunk/org.vexi.widgetdoc/build.xml tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/Resource.java tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/mainframe.html tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/style.css tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/Resource.java tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/index.ftl tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/packageindex.ftl tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/summary.ftl tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/template.ftl Added: tools/trunk/org.vexi.widgetdoc/build.xml =================================================================== --- tools/trunk/org.vexi.widgetdoc/build.xml (rev 0) +++ tools/trunk/org.vexi.widgetdoc/build.xml 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<!-- ====================================================================== + Feb 14, 2007 3:20:42 PM + mikey + ====================================================================== --> +<project name="project" default="build"> + <!-- remark. Arguably this should be + <target name="build"> + + + </target> + +</project> Added: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/Resource.java =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/Resource.java (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/Resource.java 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,3 @@ +package org.vexi.autodoc.staticfiles; + +public class Resource {} Copied: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/mainframe.html (from rev 1664, tools/trunk/org.vexi.widgetdoc/static/mainframe.html) =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/mainframe.html (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/mainframe.html 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,11 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<html><head><title>Vexi Widget Doc</title></head> + +<frameset cols="20%,80%"> + <frameset rows="30%,70%"> + <frame src="packageindex.html" name="packageListFrame" title="All Packages"> + <frame src="indices/_alltemplates.html" name="indexFrame" title="Template Index"> + </frameset> + <frame src="summary.html" name="infoFrame"> +</frameset> +</html> \ No newline at end of file Copied: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/style.css (from rev 1664, tools/trunk/org.vexi.widgetdoc/static/style.css) =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/style.css (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/staticfiles/style.css 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,12 @@ +tr.template { + background: #CCFF99; +} + +tr.static { + background: #FFCC99; +} + +tr.core { + background: #FF9900; +} + Added: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/Resource.java =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/Resource.java (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/Resource.java 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,3 @@ +package org.vexi.autodoc.templates; + +public class Resource {} Copied: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/index.ftl (from rev 1664, tools/trunk/org.vexi.widgetdoc/templates/index.ftl) =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/index.ftl (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/index.ftl 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,9 @@ +<html> +<body> +<p><b>Index:</b> +<#list names as name> +<br>${templatelink(name)} +</#list> +</p> +</body> +</html> \ No newline at end of file Copied: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/packageindex.ftl (from rev 1664, tools/trunk/org.vexi.widgetdoc/templates/packageindex.ftl) =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/packageindex.ftl (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/packageindex.ftl 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,11 @@ +<html> +<body> +<p><b>Index:</b> +<a href="indices/_alltemplates.html" target="indexFrame">All packages</a> +<br> +<#list names as name> +<br><a href="indices/${name}.html" target="indexFrame">${name}</a> +</#list> +</p> +</body> +</html> \ No newline at end of file Copied: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/summary.ftl (from rev 1663, tools/trunk/org.vexi.widgetdoc/templates/summary.ftl) =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/summary.ftl (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/summary.ftl 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,11 @@ +<html> +<body> +<p><b>Overview:</b> This is the api documentation for the latest Vexi widgets</p> +<p><b>Widget Set Version:</b> ${version}</p> +<p><b>Generated on:</b> ${generation_date?datetime?string.medium}</p> + +<p>Powered by <a href="http://www.freemarker.org">Freemarker</a></p> +<p>Vexi WidgetDoc Generator written by Mike Goodwin (mike at vexi.org)</p> +<p>Copyright The Vexi Project @copy; 2005</p> +</body> +</html> \ No newline at end of file Copied: tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/template.ftl (from rev 1668, tools/trunk/org.vexi.widgetdoc/templates/template.ftl) =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/template.ftl (rev 0) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/autodoc/templates/template.ftl 2007-02-14 08:08:56 UTC (rev 1673) @@ -0,0 +1,89 @@ +<#assign recurseType = 0> +<#assign depth = 1> +<#macro TemplateFile> +<!-- HACK, appears for a given data model we can only have one recursive + macro. Using a var inside macro to have more than one behaviour --> + <#assign hasrefimpl = .node.hasreferenceimpl > + <#if recurseType=0> + ${""?left_pad(depth, "-")} ${templatelink(.node.name)} + <#if .node?parent.hasreferenceimpl ><font color="red">(reference implementation)</font></#if> + <br> + <#assign depth = depth + 1> + <#recurse .node> + <#assign depth = depth - 1> + <#else> + <br> + <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> + <TR CLASS="${.node.type}"> + <TD><B>Inherited from ${templatelink(.node.name)}</B> + <#if (.node?parent.hasreferenceimpl)!false ><font color="red">(reference implementation)</font></#if> + </TD></TR> + <TR><TD><#list .node.props as prop>${prop}, </#list></TD></TR> + <#if .node?children?size != 0 > + <TR><TD><#recurse .node></TD></TR> + </#if> + </TABLE> + </#if> +</#macro> + +<html> +<head> +<link rel="stylesheet" type="text/css" href="../style.css" /> +</head> +<body> +<font size="+1">${meta.name}</font><br> +<#if templatefile?exists> + <#assign recurseType = 0> + <#recurse templatefile> +</#if> + +<p><b>Description:</b> ${meta.desc}</p> +<p><b>Usage:</b> ${meta.usage}</p> +<p><b>Author:</b> ${meta.author}</p> + +<#if templatefile.sprops?has_content > + <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> + <TR CLASS="static"> + <TD COLSPAN=2><FONT SIZE="+2"><B>Static Properties</B></FONT></TD></TR> + <#list templatefile.sprops as pname> + <TR BGCOLOR="white" CLASS="TableRowColor"> + <TD WIDTH="20%"><B>${pname}</B></TD> + <TD>${(meta.sprops[pname])!"<i><undocumented></i>"}</TD> + </TR> + </#list> + </TABLE><br> +</#if> + + +<#list templates as template> + <#if template.props?has_content > + <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> + <TR CLASS="${template.type}"> + <TD COLSPAN=2><FONT SIZE="+2"><B>Properties</B></FONT></TD></TR> + <#list template.props as pname> + + <TR BGCOLOR="white" CLASS="TableRowColor"> + <TD WIDTH="20%"><B>${pname}</B></TD> + <TD>${(meta.props[pname])!"<i><undocumented></i>"}</TD> + </TR> + </#list> + </TABLE> + </#if> + + <#list template.redirectTargets as target> + <br> + <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> + <TR CLASS="${template.type}"> + <TD><B>Redirect to ${templatelink(target.name)}</B></TD></TR> + <TD><#list target.props as prop>${prop}, </#list></TD> + </TABLE> + </#list> + <#if template.refs?exists> + <#assign recurseType = 1> + <#visit template.refs> + </#if> +</#list> + + +</body> +</html> \ No newline at end of file Modified: tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/FreemarkerGenerator.java =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/FreemarkerGenerator.java 2007-02-13 17:37:29 UTC (rev 1672) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/FreemarkerGenerator.java 2007-02-14 08:08:56 UTC (rev 1673) @@ -14,7 +14,6 @@ public class FreemarkerGenerator { - static final String TEMPLATE_DIR = "templates"; static final String OUTPUT_DIR = "generated"; // Singleton @@ -25,11 +24,8 @@ cfg = new Configuration(); // Specify the data source where the template files come from. // Here I set a file directory for it: - try { - cfg.setDirectoryForTemplateLoading(new File(TEMPLATE_DIR)); - } catch (IOException e) { - e.printStackTrace(); - } + cfg.setClassForTemplateLoading( org.vexi.autodoc.templates.Resource.class, ""); + // Specify how templates will see the data model. This is an // advanced topic... // but just use this: Modified: tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/Main.java =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/Main.java 2007-02-13 17:37:29 UTC (rev 1672) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/Main.java 2007-02-14 08:08:56 UTC (rev 1673) @@ -3,6 +3,7 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; +import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; @@ -83,9 +84,10 @@ static private void copyStaticFile(String name) throws IOException{ System.out.println("++++ Copying " + name); - File frameIn = new File("static/"+name); - File frameOut = new File(FreemarkerGenerator.OUTPUT_DIR + "/"+name); - Util.copy(frameIn, frameOut); + InputStream is = org.vexi.autodoc.staticfiles.Resource.class.getResourceAsStream(name); + + File out = new File(FreemarkerGenerator.OUTPUT_DIR + "/"+name); + Util.copy(is, out); } static public void traverse(String rootPath, String vexiPath) { Modified: tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/util/Util.java =================================================================== --- tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/util/Util.java 2007-02-13 17:37:29 UTC (rev 1672) +++ tools/trunk/org.vexi.widgetdoc/src/org/vexi/widgetdoc/util/Util.java 2007-02-14 08:08:56 UTC (rev 1673) @@ -6,6 +6,8 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.Reader; import java.io.StringWriter; import java.nio.MappedByteBuffer; @@ -52,6 +54,67 @@ } } + /** + * Copies an <code>InputStream</code> to a file using [EMAIL PROTECTED] #copy(InputStream, OutputStream)}. + * + * @param in stream to copy from + * @param outputFile file to copy to + * @return the number of bytes copied + * @throws IOException if an I/O error occurs (may result in partially done work) + * @see #copy(InputStream, OutputStream) + */ + public static long copy(InputStream in, File outputFile) throws IOException { + FileOutputStream out = null; + try { + out = new FileOutputStream(outputFile); + return copy(in, out); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + } + } + } + } + /** + * Copies an <code>InputStream</code> to an <code>OutputStream</code> using a local internal buffer for performance. + * Compared to [EMAIL PROTECTED] #globalBufferCopy(InputStream, OutputStream)} this method allows for better + * concurrency, but each time it is called generates a buffer which will be garbage. + * + * @param in stream to copy from + * @param out stream to copy to + * @return the number of bytes copied + * @throws IOException if an I/O error occurs (may result in partially done work) + * @see #globalBufferCopy(InputStream, OutputStream) + */ + public static long copy(InputStream in, OutputStream out) throws IOException { + // we need a buffer of our own, so no one else interferes + byte[] buf = new byte[1024]; + return copy(in, out, buf); + } + /** + * Copies an <code>InputStream</code> to an <code>OutputStream</code> using the specified buffer. + * + * @param in stream to copy from + * @param out stream to copy to + * @param copyBuffer buffer used for copying + * @return the number of bytes copied + * @throws IOException if an I/O error occurs (may result in partially done work) + * @see #globalBufferCopy(InputStream, OutputStream) + * @see #copy(InputStream, OutputStream) + */ + public static long copy(InputStream in, OutputStream out, byte[] copyBuffer) throws IOException { + long bytesCopied = 0; + int read = -1; + + while ((read = in.read(copyBuffer, 0, copyBuffer.length)) != -1) { + out.write(copyBuffer, 0, read); + bytesCopied += read; + } + return bytesCopied; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn