tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1153804 - in /openejb/trunk/sandbox/tools/src/main: java/org/apache/openejb/tools/examples/ resources/generate-index/velocity/
Date Thu, 04 Aug 2011 09:29:17 GMT
Author: rmannibucau
Date: Thu Aug  4 09:29:16 2011
New Revision: 1153804

URL: http://svn.apache.org/viewvc?rev=1153804&view=rev
Log:
adding variable to manage in examples md zip address, java files, apis and resources

Added:
    openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/api.vm
    openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/java.vm
    openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/resources.vm
Modified:
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/OpenEJBTemplate.java
    openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/example.vm

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java?rev=1153804&r1=1153803&r2=1153804&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
Thu Aug  4 09:29:16 2011
@@ -174,6 +174,17 @@ public class GenerateIndex {
                         sourceFile.getPath() + ".html");
             }
 
+            List<String> resources = removePrefix(example.getPath(), resourceFiles);
+            List<String> javaFileLinks = removePrefix(example.getPath(), javaFiles);
+
+            html = html.replace("${zip}", zip.getName());
+            html = html.replace("${apis}", OpenEJBTemplate.get().apply("api.vm",
+                    newMap(String.class, Object.class).add("apis", apiCount).map()));
+            html = html.replace("${resources}", OpenEJBTemplate.get().apply("resources.vm",
+                    newMap(String.class, Object.class).add("resources", resources).map()));
+            html = html.replace("${javas}", OpenEJBTemplate.get().apply("java.vm",
+                    newMap(String.class, Object.class).add("files", javaFileLinks).map()));
+
             if (html.isEmpty()) {
                 LOGGER.warn("no readme for example " + example.getName() + " [" + example.getPath()
+ "]");
 
@@ -183,8 +194,8 @@ public class GenerateIndex {
                                 .add(OpenEJBTemplate.USER_JAVASCRIPTS, newList(String.class).add("prettyprint.js").list())
                                 .add("apis", apiCount)
                                 .add("link", zip.getName())
-                                .add("files", removePrefix(example.getPath(), javaFiles))
-                                .add("resources", removePrefix(example.getPath(), resourceFiles))
+                                .add("files", javaFileLinks)
+                                .add("resources", resources)
                                 .map(),
                         index.getPath());
             } else {

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/OpenEJBTemplate.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/OpenEJBTemplate.java?rev=1153804&r1=1153803&r2=1153804&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/OpenEJBTemplate.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/OpenEJBTemplate.java
Thu Aug  4 09:29:16 2011
@@ -8,6 +8,7 @@ import org.apache.velocity.runtime.log.C
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.StringWriter;
 import java.io.Writer;
 import java.net.URL;
 import java.util.HashMap;
@@ -100,6 +101,29 @@ public final class OpenEJBTemplate {
         }
     }
 
+    public String apply(String template, Map<String, Object> mapContext) {
+        StringWriter writer = null;
+        try {
+            writer = new StringWriter();
+            evaluate(template, mapContext, writer);
+        } catch (IOException ioe) {
+            LOGGER.error("can't apply template " + template, ioe);
+        } finally {
+            if (writer != null) {
+                try {
+                    writer.flush();
+                    writer.close();
+                } catch (IOException e) {
+                    LOGGER.error("can't flush writer", e);
+                }
+            }
+        }
+        if (writer == null) {
+            return "";
+        }
+        return writer.toString();
+    }
+
     public static OpenEJBTemplate get() {
         return INSTANCE;
     }

Added: openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/api.vm
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/api.vm?rev=1153804&view=auto
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/api.vm (added)
+++ openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/api.vm Thu Aug
 4 09:29:16 2011
@@ -0,0 +1,8 @@
+           <div id="api">
+                <ul>
+                    APIs:
+#foreach( $api in $apis.entrySet() )
+                    <li>$api.key is used $api.value times</li>
+#end
+                </ul>
+            </div>
\ No newline at end of file

Modified: openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/example.vm
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/example.vm?rev=1153804&r1=1153803&r2=1153804&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/example.vm (original)
+++ openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/example.vm Thu
Aug  4 09:29:16 2011
@@ -3,30 +3,8 @@
                 <a href="$link">Download as zip</a>
             </div>
 
-            <div id="javaFiles">
-                <ul>
-                    Files:
-#foreach( $file in $files )
-                    <li><a href="${file}.html">$file</a></li>
-#end
-                </ul>
-            </div>
-
-            <div id="api">
-                <ul>
-                    APIs:
-#foreach( $api in $apis.entrySet() )
-                    <li>$api.key is used $api.value times</li>
-#end
-                </ul>
-            </div>
+#parse("generate-index/velocity/java.vm")
+#parse("generate-index/velocity/api.vm")
+#parse("generate-index/velocity/resources.vm")
 
-            <div id="api">
-                <ul>
-                    Resources:
-#foreach( $resource in $resources )
-                    <li><a href="${resource}.html">$resource</a></li>
-#end
-                </ul>
-            </div>
 #parse("generate-index/velocity/footer.vm")

Added: openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/java.vm
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/java.vm?rev=1153804&view=auto
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/java.vm (added)
+++ openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/java.vm Thu Aug
 4 09:29:16 2011
@@ -0,0 +1,8 @@
+           <div id="javaFiles">
+                <ul>
+                    Files:
+#foreach( $file in $files )
+                    <li><a href="${file}.html">$file</a></li>
+#end
+                </ul>
+            </div>
\ No newline at end of file

Added: openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/resources.vm
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/resources.vm?rev=1153804&view=auto
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/resources.vm (added)
+++ openejb/trunk/sandbox/tools/src/main/resources/generate-index/velocity/resources.vm Thu
Aug  4 09:29:16 2011
@@ -0,0 +1,8 @@
+           <div id="api">
+                <ul>
+                    Resources:
+#foreach( $resource in $resources )
+                    <li><a href="${resource}.html">$resource</a></li>
+#end
+                </ul>
+            </div>
\ No newline at end of file



Mime
View raw message