incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r603221 - in /incubator/sling/trunk/microsling/microsling-core/src: main/java/org/apache/sling/microsling/experimental/ main/java/org/apache/sling/microsling/scripting/ main/webapp/ test/java/org/apache/sling/microsling/integration/ test/re...
Date Tue, 11 Dec 2007 12:18:01 GMT
Author: bdelacretaz
Date: Tue Dec 11 04:17:59 2007
New Revision: 603221

URL: http://svn.apache.org/viewvc?rev=603221&view=rev
Log:
SLING-114 - ECT script engine renamed to JST (javascript templates), uses the jst extension

Added:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java
      - copied, changed from r603187, incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/EctScriptEngine.java
    incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.jst
      - copied, changed from r603187, incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ect
Removed:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/EctScriptEngine.java
    incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ect
Modified:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html
    incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SlingResourceTypeRenderingTest.java
    incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SyntheticResourceTest.java

Copied: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java
(from r603187, incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/EctScriptEngine.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java?p2=incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java&p1=incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/EctScriptEngine.java&r1=603187&r2=603221&rev=603221&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/EctScriptEngine.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java
Tue Dec 11 04:17:59 2007
@@ -20,8 +20,6 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -43,18 +41,18 @@
 import org.apache.sling.microsling.slingservlets.renderers.DefaultHtmlRenderer;
 import org.apache.sling.scripting.javascript.EspReader;
 
-/** Experimental ECT script engine: converts an ECT template (using the 
+/** Experimental JST script engine: converts a JST template (using the 
  *  same templating syntax as ESP) to client-side javascript code
  *  that renders the page.
  */
-public class EctScriptEngine implements SlingScriptEngine {
+public class JstScriptEngine implements SlingScriptEngine {
 
-    public static final String ECT_SCRIPT_EXTENSION = "ect";
+    public static final String JST_SCRIPT_EXTENSION = "jst";
     private final List<String> libraryScripts = new LinkedList<String>();
     private final DefaultHtmlRenderer htmlRenderer;
     private final ScriptFilteredCopy copier = new ScriptFilteredCopy();
     
-    public EctScriptEngine() {
+    public JstScriptEngine() {
         // TODO hardcoded for now...
         libraryScripts.add("/microjax/microjax.js");
         htmlRenderer = new DefaultHtmlRenderer();
@@ -84,8 +82,10 @@
             }
             
             // output HEAD with javascript initializations
-            w.println("<html><head><title id=\"EctPageTitle\">");
-            w.println("ECT rendering of " + r.getURI());
+            // TODO we should instead parse (at least minimally) the template file, and inject
our
+            // stuff in the right places
+            w.println("<html><head><title id=\"JstPageTitle\">");
+            w.println("JST rendering of " + r.getURI());
             w.println("</title>");
             
             // library scripts
@@ -101,7 +101,7 @@
             
             // onLoad method
             w.println("<script language=\"javascript\">");
-            w.println("function ectOnLoad() { if(typeof onLoad == \"function\") { onLoad();
} }");
+            w.println("function jstOnLoad() { if(typeof onLoad == \"function\") { onLoad();
} }");
             w.println("</script>");
             
             // data in JSON format
@@ -116,16 +116,16 @@
             }
             w.println(";");
             w.println("</script>");
-            w.println("</head><body onLoad=\"ectOnLoad()\">");
+            w.println("</head><body onLoad=\"jstOnLoad()\">");
             
             // output our parsed script, first in body
-            w.println("<div id=\"EctRenderingScript\">\n<script language='javascript'>");
+            w.println("<div id=\"JstRenderingScript\">\n<script language='javascript'>");
             copier.copy(er,w);
             w.println("</script>\n</div>");
             
             // default rendering, turned off automatically from the javascript that 
             // follows, if javascript is enabled
-            w.println("<div id=\"EctDefaultRendering\">");
+            w.println("<div id=\"JstDefaultRendering\">");
             if(n!=null) {
                 htmlRenderer.render(w, r, n);
             } else {
@@ -133,23 +133,23 @@
             }
             w.println("</div>");
             w.println("<script language=\"javascript\">");
-            w.println("document.getElementById(\"EctDefaultRendering\").setAttribute(\"style\",\"display:none\");");
+            w.println("document.getElementById(\"JstDefaultRendering\").setAttribute(\"style\",\"display:none\");");
             w.println("</script>");
             
             // all done
             w.println("</body></html>");
             
         } catch(RepositoryException re) {
-            throw new SlingException("RepositoryException in EctScriptEngine.eval()",re);
+            throw new SlingException("RepositoryException in JstScriptEngine.eval()",re);
             
         } catch(JSONException je) {
-            throw new SlingException("JSONException in EctScriptEngine.eval()",je);
+            throw new SlingException("JSONException in JstScriptEngine.eval()",je);
             
         }
     }
 
     public String getEngineName() {
-        return "ECT script engine (Ecmascript Client Templates)";
+        return "JST script engine (sling JavaScript Templates)";
     }
 
     public String getEngineVersion() {
@@ -157,7 +157,7 @@
     }
 
     public String[] getExtensions() {
-        return new String [] { ECT_SCRIPT_EXTENSION };
+        return new String [] { JST_SCRIPT_EXTENSION };
     }
     
 }

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java?rev=603221&r1=603220&r2=603221&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java
Tue Dec 11 04:17:59 2007
@@ -80,7 +80,7 @@
           "org.apache.sling.scripting.velocity.VelocityTemplatesScriptEngine",
           "org.apache.sling.scripting.freemarker.FreemarkerScriptEngine",
           "org.apache.sling.scripting.ruby.ErbScriptEngine",
-          "org.apache.sling.microsling.experimental.EctScriptEngine"
+          "org.apache.sling.microsling.experimental.JstScriptEngine"
        };
 
     public MicroslingScriptResolver() throws SlingException {

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html?rev=603221&r1=603220&r2=603221&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html (original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html Tue Dec
11 04:17:59 2007
@@ -75,9 +75,9 @@
 &lt;/body>
 &lt;/html></pre>
 
-  <h2>Ecmascript Client Templates (ECT)</h2>
+  <h2>Sling Javascript Templates (JST)</h2>
   <p>
-  	If you prefer to waste your client's CPUs for rendering, ECT templates use the same syntax
as ESP, but generate
+  	If you prefer to waste your client's CPUs for rendering, JST templates use the same syntax
as ESP, but generate
   	javascript rendering code that's executed on the client, and include in the response both
a JSON version of the
   	data and a basic HTML rendering that is used for search engines, for example.
   </p>
@@ -85,9 +85,9 @@
   	See <a href="https://issues.apache.org/jira/browse/SLING-114">SLING-114</a>
for more info.
   </p>
   <p>
-  	For now, here's a simplistic ECT example. Make sure to have a look at what's sent to the
browser!  
+  	For now, here's a simplistic JST example. Make sure to have a look at what's sent to the
browser!  
   </p>
-  <pre>&lt;!-- Store this as html.ect in the appropriate scripts directory -->
+  <pre>&lt;!-- Store this as html.jst in the appropriate scripts directory -->
   currentNode.title = &lt;b> &lt;%= currentNode.title %> &lt;/b>
 &lt;/p>
 &lt;p>

Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SlingResourceTypeRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SlingResourceTypeRenderingTest.java?rev=603221&r1=603220&r2=603221&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SlingResourceTypeRenderingTest.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SlingResourceTypeRenderingTest.java
Tue Dec 11 04:17:59 2007
@@ -141,24 +141,24 @@
         }
     }
 
-    public void testEctHtml() throws IOException {
-        final String toDelete = uploadTestScript("rendering-test.ect","html.ect");
+    public void testJstHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.jst","html.jst");
         try {
             final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
-            assertTrue("Content includes ECT marker",content.contains("ECT template"));
+            assertTrue("Content includes JST marker",content.contains("JST template"));
             assertTrue("Content contains JSON data",content.contains("\"text\":\"" + testText
+ "\""));
-            assertTrue("Content contains default rendering",content.contains("div id=\"EctDefaultRendering"));
+            assertTrue("Content contains default rendering",content.contains("div id=\"JstDefaultRendering"));
             assertTrue("Content contains javascript rendering code",content.contains("out.write(
currentNode.text )"));
         } finally {
             testClient.delete(toDelete);
         }
     }
 
-    public void testEctHtmlScriptTagA() throws IOException {
-        final String toDelete = uploadTestScript("rendering-test.ect","html.ect");
+    public void testJstScriptTagA() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.jst","html.jst");
         try {
             final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
-            assertTrue("Content includes ECT marker",content.contains("ECT template"));
+            assertTrue("Content includes JST marker",content.contains("JST template"));
             assertTrue("Content contains scripted stuff (" + content + ")",
                     content.contains("something scripted"));
             assertFalse("Script opening tag must be broken in two in content (" + content
+ ")",
@@ -171,11 +171,11 @@
     }
 
     /** TODO this test currently fails, see SLING-114
-    public void testEctHtmlScriptTagB() throws IOException {
-        final String toDelete = uploadTestScript("rendering-test.ect","html.ect");
+    public void testJstHtmlScriptTagB() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.jst","html.jst");
         try {
             final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
-            assertTrue("Content includes ECT marker",content.contains("ECT template"));
+            assertTrue("Content includes JST marker",content.contains("JST template"));
             assertTrue("Content contains scripted stuff (" + content + ")",
                     content.contains("more scripting"));
             assertFalse("Script opening tag must be broken in two in content (" + content
+ ")",

Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SyntheticResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SyntheticResourceTest.java?rev=603221&r1=603220&r2=603221&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SyntheticResourceTest.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/SyntheticResourceTest.java
Tue Dec 11 04:17:59 2007
@@ -76,19 +76,19 @@
         assertDeepGetStatus(basePath,10,404,"");
     }
     
-    public void testSyntheticResourceWithEctTemplate() throws IOException {
+    public void testSyntheticResourceWithJstTemplate() throws IOException {
         final String synthResourceUrl = HTTP_BASE_URL + "/search/something.SyntheticResourceTest.html";
         {
             final String content = getContent(synthResourceUrl, CONTENT_TYPE_HTML);
-            assertFalse("Content must not include ECT marker before test",content.contains("ECT
template"));
+            assertFalse("Content must not include JST marker before test",content.contains("JST
template"));
         }
         
         final String scriptPath = "/apps/" + SyntheticResource.DEFAULT_RESOURCE_TYPE + "/SyntheticResourceTest";
         testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
-        final String toDelete = uploadTestScript(scriptPath,"rendering-test.ect","html.ect");
+        final String toDelete = uploadTestScript(scriptPath,"rendering-test.jst","html.jst");
         try {
             final String content = getContent(synthResourceUrl, CONTENT_TYPE_HTML);
-            assertTrue("Content includes ECT marker: " + content,content.contains("ECT template"));
+            assertTrue("Content includes JST marker: " + content,content.contains("JST template"));
         } finally {
             testClient.delete(toDelete);
         }

Copied: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.jst
(from r603187, incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ect)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.jst?p2=incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.jst&p1=incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ect&r1=603187&r2=603221&rev=603221&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ect
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.jst
Tue Dec 11 04:17:59 2007
@@ -1,6 +1,6 @@
 <%-- used by ScriptedRenderingTest --%>
 <p>
-	ECT template.
+	JST template.
 </p>
 
 <p>



Mime
View raw message