incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r602157 - in /incubator/sling/trunk/microsling/microsling-core/src/main/webapp: content-creation-forms.html erb-scripts.html freemarker-scripts.html index.html javascript.html server-side-javascript.html velocity-scripts.html
Date Fri, 07 Dec 2007 17:19:58 GMT
Author: bdelacretaz
Date: Fri Dec  7 09:19:57 2007
New Revision: 602157

URL: http://svn.apache.org/viewvc?rev=602157&view=rev
Log:
Reworked the index.html and javascript.html explanation pages (assuming lots of people are
going to play with microsling over the weekend ;-)

Added:
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html
      - copied, changed from r602107, incubator/sling/trunk/microsling/microsling-core/src/main/webapp/server-side-javascript.html
Removed:
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/server-side-javascript.html
Modified:
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/erb-scripts.html
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/freemarker-scripts.html
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/index.html
    incubator/sling/trunk/microsling/microsling-core/src/main/webapp/velocity-scripts.html

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html?rev=602157&r1=602156&r2=602157&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/content-creation-forms.html
Fri Dec  7 09:19:57 2007
@@ -27,7 +27,7 @@
         and displays it using an <em>html</em> extension. 
       </p>
       <p>
-        See the <em>Velocity scripts</em> and <em>server-side Javascript</em>
pages for how to
+        See the <a href="javascript.html">javascript</a> info page for how to
         render the content using templates and scripts.
       </p>
       <p>

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/erb-scripts.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/erb-scripts.html?rev=602157&r1=602156&r2=602157&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/erb-scripts.html (original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/erb-scripts.html Fri
Dec  7 09:19:57 2007
@@ -9,6 +9,9 @@
   <div class="note">
     <a href="../">back to homepage</a>
   </div>
+  <p>
+  	(this page might not be up to date)
+  </p>
   <p> 
   	Scripts found by the <code>SlingScriptResolver</code> using the <code>.erb</code>
extension are executed by
     the <code>ErbScriptEngine</code>.

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/freemarker-scripts.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/freemarker-scripts.html?rev=602157&r1=602156&r2=602157&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/freemarker-scripts.html
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/freemarker-scripts.html
Fri Dec  7 09:19:57 2007
@@ -9,6 +9,11 @@
   <div class="note">
     <a href="index.html">back to homepage</a>
   </div>
+  
+  <p>
+  	(this page might not be up to date)
+  </p>
+  
   <p> 
   	Scripts found by the <code>SlingScriptResolver</code> using the <code>.ftl</code>
extension are executed by
     the <code>FreemarkerScriptEngine</code>.

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/index.html?rev=602157&r1=602156&r2=602157&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/index.html (original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/index.html Fri Dec  7
09:19:57 2007
@@ -6,41 +6,67 @@
 <body>
   <h1>microsling homepage</h1>
   
+  <h2>Overview</h2>
   <p>
-  	<em>Sling request processing, reduced to the max!</em>
+  	microsling started as "back to basics" rewrite of Sling (which is heavier, using OSGi,
and
+  	at the time was much harder to understand).
+  </p>
+  <p>
+  	As I write this (early December 2007), microsling is perfectly usable to create scripted

+  	JCR-based applications (it runs <a href="http://dev.day.com">dev.day.com</a>
for example). 
+  	We have decided to focus on javascript, using it for either server-side
+  	or client side templates (see links below), or for handling other HTTP requests besides
GET.
+  </p>
+  <p>
+  	The microjax.js client-side javascript library provides a simple javascript "proxy" on
the
+  	JCR repository. 
   </p>
-  
-  <h2>Overview</h2>
   <p>
-	The goal of microsling is to demonstrate the Sling HTTP
-	request processing in the simplest possible way, to help the
-	community converge on the goals and architecture of this 
-	module.
+  	Documentation and examples are scarce for now, but the automated tests (both unit and
integration tests)
+  	are extensive and up to date, if you can read simple java code they might help. 
   </p>
   
-  <h2>microsling test links</h2>
+  <h2>microsling main test links</h2>
   <ul>
     <li>
+      <a href="content-creation-forms.html">
+        Content creation forms
+      </a>. Start here: use this page to create content and test the rendering mechanisms,
and then have a look
+      at the <a href="javascript.html">javascript</a> info page for rendering.
+    </li>
+    <li>
+      <a href="javascript.html">
+        Server-side and client-side javascript templates
+      </a>: explains how to use server-side javascript and javascript-based ESP and
ECT templates to render content
+    </li>
+    <li>
       Automated testing of the <a href="microjax/test/microjax-test.html">
         microjax
       </a> client-side javascript "JCR proxy" library. 
     </li>
-    <li>
-      <a href="content-creation-forms.html">
-        Content creation forms
-      </a>: use this page to create content and test the rendering mechanisms.
-    </li>
+  </ul>
+  
+  <h2>more test links</h2>
+  <p>
+  	Script engines are (almost) pluggable, so we support various templating and scripting
languages.
+  	But our focus is definitely on javascript, as it allows using the same language on both
the server
+  	and client sides.
+  </p>
+  <ul>
+     <li>
+       <a href="repository-info">repository-info</a>, dumps the JCR repository
+       properties.
+     </li>
+     <li>
+       <a href="repository/default">WebDAV mount point</a>: use this URL to mount
+       the repository via WebDAV (login = admin/admin).
+     </li>
     <li>
       <a href="velocity-scripts.html">
         Velocity templates
       </a>: explains how to use Velocity templates to render content.
     </li>
     <li>
-      <a href="server-side-javascript.html">
-        Server-side javascript and ESP templates
-      </a>: explains how to use server-side javascript and javascript-based ESP templates
to process requests.
-    </li>
-    <li>
       <a href="freemarker-scripts.html">
         FreeMarker templates
       </a>: explains how to use FreeMarker templates to render content.
@@ -52,106 +78,5 @@
     </li>
   </ul>
   
-  <h2>Show me the code</h2>
-  <p>
-  	Here's a brief description of how microsling processes HTTP requests. Follow the links
to the source code
-    for more details.
-    <ul>
-      <li>
-        The main <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java?view=markup">MicroSlingServlet</a>
-         handles HTTP requests. That's probably where you want to
-        start studying the code.
-      </li>
-      <li>
-        <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/RequestFilter.java?view=markup">RequestFilter</a>
-         objects process the incoming requests before passing them on to SlingServlet objects
-        which do the actual processing.
-        <ul>
-          <li>
-	      	The
-	        <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/ResourceResolverFilter.java?view=markup">ResourceResolverFilter</a>
-	        selects the <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/Resource.java?view=markup">Resource</a>
(currently a JCR Node, OCM is not used yet) to process. 
-	      </li>
-	      <li>
-		      The <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/contenttype/ResponseContentTypeResolverFilter.java?view=markup">ResponseContentTypeResolverFilter</a>
-		      computes the desired <em>Content-Type</em> for the response, so that
rendering scripts or SlingServlets know what output format to generate.
-	      </li>
-	    </ul>
-	    	        Other filters would include
-	        Locale selection, client capabilities analysis, etc.
-	    
-      </li>
-      <li>
-        After applying the RequestFilters, the MicroSlingServlet selects a 
-        <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/api/SlingServlet.java?view=markup">SlingServlet</a>
to process the request.
-        The first SlingServlet where canProcess(...) returns true is used.
-      </li>
-      <li>
-        The <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/requestcontext/SlingRequestContext.java?view=markup">SlingRequestContext</a>
is
-        stored as a request attribute, and gives access to Sling-specific objects (Resource,
repository Session, etc.) used for request processing.
-      </li>
-      <li>
-        A few SlingServlet classes are implemented (source code <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/">here</a>):
-        <ul>
-          <li>
-            The SlingPostServlet allows Nodes to be created by POSTing to URLs ending
-            with ".sling".
-          </li>
-          <li>
-            The VelocityTemplatesServlet and RhinoJavascriptServlet execute server-side scripts
in those
-            languages to process requests. 
-          </li>
-          <li>
-            The DefaultSlingServlet is used when no other SlingServlet wants the request.
-          </li>
-        </ul>
-      </li>
-      <li>
-        The <a href="http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java?view=markup">SlingScriptResolver</a>

-        is used by the scripting SlingServlet classes to locate scripts in the repository.
-        See comments in that class for how script paths are computed based on the Resource's
resourceType and the
-        request method and extension.
-      </li>
-      <li>
-        Rendering scripts can generate various output formats, for example a Velocity script
named "get.xml.vlt" will
-        cause a page with <em>Content-Type=text/xml</em> to be generated by the
VelocityTemplatesServlet. 
-      </li>
-      <li>
-        The microsling architecture allows
-        additional scripting engines (JSP, JRuby, BSF,...) to be plugged in easily - and
this would
-        of course be much easier with OSGi.   
-      </li>
-      <li>
-        We'll probably need a ResponseFilter interface at some point, but for now it's not
needed. It could be useful
-        to apply "rendering standards" to the output, adding header/footers/glitter to HTML
pages for example. 
-      </li>
-    </ul> 
-    <p>
-      If you have followed the links to source code in the above descriptions, you've seen
most or all of the interesting
-      microsling source code. What's remaining are a few simple support classes.  
-    </p>
-  </p>
-    
-  <h2>No OSGi</h2>
-  <p>
-    To keep things simple, microsling does <em>not</em> use OSGi.
-    We will of course continue to use OSGi in the real Sling, and there are many
-    places in the code which say <em>TODO - use OSGi plugins here</em>. Keeping
things
-    "static" for this example makes it easier to concentrate on the basics.
-  </p>
-  
-   <h2>More test links</h2>
-  <p>
-    <ul>
-      <li>
-        <a href="repository-info">repository-info</a>, dumps the JCR repository
-        properties.
-      </li>
-      <li>
-        <a href="repository/default">WebDAV mount point</a>: use this URL to
mount
-        the repository via WebDAV (login = admin/admin).
-      </li>
-    </ul>
-  </p>
 </body>
 </html>

Copied: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html (from
r602107, incubator/sling/trunk/microsling/microsling-core/src/main/webapp/server-side-javascript.html)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html?p2=incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html&p1=incubator/sling/trunk/microsling/microsling-core/src/main/webapp/server-side-javascript.html&r1=602107&r2=602157&rev=602157&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/server-side-javascript.html
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/javascript.html Fri Dec
 7 09:19:57 2007
@@ -1,52 +1,40 @@
 <html>
 <head>
-  <title>microsling server-side javascript and ESP templates</title>
+  <title>Use of javascript in microsling</title>
   <link rel="stylesheet" href="microsling.css"/>
 </head>
 <body>
-  <h1>microsling server-side javascript and ESP templates</h1>
+  <h1>Use of javascript in microsling</h1>
   
   <div class="note">
     <a href="index.html">back to homepage</a>
   </div>
   
+  <h2>Scripting basics</h2>
   <p>
-    Server-side javascript code and javascript-based ESP templates can be used by microsling
to process requests. 
-    The scripts are located by the
-    <a href="http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/MicroslingScriptResolver.java?view=markup">MicroslingScriptResolver</a>
-    , as for the <a href="velocity-scripts.html">Velocity templates</a> (see
that
-    page for more details about how this resolution works).  
-  </p>
-  <p>
-  	Scripts can either:
-  	<ul>
-  	  <li>
-  	  	Have the <em>.esp</em> extension to use the microsling <em>ECMAscript
Server Pages</em> syntax
-  	  	described below.
-  	  </li>
-  	  <li>
-  	  	Have the <em>.js</em> extension to use "raw" javascript.
-  	  </li>
-  	</ul>
-  </p>
-  <p>
-    Server-side javascript support is implemented by the 
-    <a href="http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/scripting/engines/rhino/RhinoJavascriptEngine.java?view=markup">RhinoJavascriptEngine</a>.
-  </p>
-  <p>
-  	To test this, remove or rename <a href="velocity-scripts.html">Velocity templates</a>
-    if you played with them before (Velocity has priority due to the order in which the SlingServlet
classes
-    are setup),  and store one of the scripts shown
-  	below under <em>/sling/scripts/microsling/example/</em>, using the filenames
shown in comments in the scripts below.
+  	Scripts are located based on the <em>sling:resourceType</em> property of nodes
(and some other variants, but for
+  	now we'll leave it at that).
+  </p>
+  <p>
+  	If you created content with the microsling test content creation form, rendering scripts
should be stored
+  	in the repository under <em>/sling/scripts/microsling/example/</em>. Mount
the repository with WebDAV to
+  	do that, see the WebDAV link on the <a href="index.html">homepage</a>.
+  </p>
+  <p>
+  	To activate a script, remove or rename any existing templates in there, and store one
of the scripts shown
+  	below there, using the filenames shown in comments in the scripts below.
   </p>
   <p>
   	Content nodes created with the <a href="content-creation-forms.html">Content creation
forms</a>
     should then be displayed in HTML, with a layout defined by the example scripts.
   </p>
   <p>
-    As for the Velocity templates, other output formats can be generated, for example by
renaming the ESP template 
-    to <em>plain.esp</em> (as the Content-type for text is <em>text/plain</em>),
modifying it to output plain text 
-    and using a <em>.txt</em> extension in the request.
+    Other output formats can be generated, for example by renaming the ESP template 
+    to <em>txt.esp</em>, modifying it to output plain text 
+    and using a <em>.txt</em> extension in the request. Or xml, or any other
extension.
+  </p>
+  <p>
+  	TODO explain selectors, default scripts location, non-GET requests, etc.
   </p>
   
   <h2>ECMAscript Server Pages (ESP)</h2>
@@ -86,9 +74,37 @@
 %>
 &lt;/body>
 &lt;/html></pre>
+
+  <h2>Ecmascript Client Templates (ECT)</h2>
+  <p>
+  	If you prefer to waste your client's CPUs for rendering, ECT 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>
+  <p>
+  	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!  
+  </p>
+  <pre>&lt;!-- Store this as html.ect in the appropriate scripts directory -->
+  currentNode.title = &lt;b> &lt;%= currentNode.title %> &lt;/b>
+&lt;/p>
+&lt;p>
+  currentNode.text = &lt;em> &lt;%= currentNode.text %> &lt;/em> (changed)
+&lt;/p>
+
+&lt;%
+  // if present, this function is called by body.onLoad
+  function onLoad() {
+    document.title = currentNode.title;
+  }
+%></pre>
+  
   <h2>Raw javascript</h2>
   <p>
-  	Raw javascript is probably more useful to handle the POST, PUT or DELETE methods.
+  	Raw javascript is probably more useful to handle the POST, PUT or DELETE methods. To do
that, name
+  	the script after the method name, uppercased, i.e. <em>POST.js</em>.
   </p>
   
   <h3>Javascript example</h3>
@@ -107,7 +123,7 @@
   <h2>Directory listing example</h2>
   <p>
     Store the following template under 
-    <code>sling/scripts/NODETYPES/nt/unstructured/html.esp</code> to render a
simple
+    <code>sling/scripts/nt/unstructured/html.esp</code> to render a simple
     directory listing for <em>nt:unstructured</em> nodes which do not have a

     <code>slingComponentId</code> property.
   </p>

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/velocity-scripts.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/velocity-scripts.html?rev=602157&r1=602156&r2=602157&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/velocity-scripts.html
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/velocity-scripts.html
Fri Dec  7 09:19:57 2007
@@ -10,6 +10,10 @@
     <a href="index.html">back to homepage</a>
   </div>
   <p>
+  	(this page might not be up to date)
+  </p>
+
+  <p>
   	When processing requests, the <em>VelocityTemplatesServlet</em> ask the <em>SlingScriptResolver</em>
     for scripts with the <em>.vlt</em> extension.
   </p>



Mime
View raw message