incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r583855 - in /incubator/sling/whiteboard/microsling: ./ src/main/java/org/apache/sling/microsling/request/ src/main/java/org/apache/sling/microsling/requestcontext/ src/main/java/org/apache/sling/microsling/resource/ src/main/java/org/apach...
Date Thu, 11 Oct 2007 15:37:18 GMT
Author: bdelacretaz
Date: Thu Oct 11 08:37:15 2007
New Revision: 583855

URL: http://svn.apache.org/viewvc?rev=583855&view=rev
Log:
SLING-47 - microsling: VelocityTemplatesServlet and SlingScriptResolver for script-based resource
rendering

Added:
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
  (with props)
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
  (with props)
Modified:
    incubator/sling/whiteboard/microsling/   (props changed)
    incubator/sling/whiteboard/microsling/pom.xml
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/RequestAttributeNames.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/requestcontext/SlingRequestContext.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
    incubator/sling/whiteboard/microsling/src/main/webapp/WEB-INF/log4j.xml
    incubator/sling/whiteboard/microsling/src/main/webapp/index.html
    incubator/sling/whiteboard/microsling/src/main/webapp/microsling.css

Propchange: incubator/sling/whiteboard/microsling/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Oct 11 08:37:15 2007
@@ -9,3 +9,4 @@
 logs
 derby.log
 jackrabbit-repository
+velocity.log

Modified: incubator/sling/whiteboard/microsling/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/pom.xml?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/pom.xml (original)
+++ incubator/sling/whiteboard/microsling/pom.xml Thu Oct 11 08:37:15 2007
@@ -67,6 +67,11 @@
       <artifactId>jcr</artifactId>
       <version>1.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>1.5</version>
+    </dependency>
   </dependencies>
 
   <build>

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/RequestAttributeNames.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/RequestAttributeNames.java?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/RequestAttributeNames.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/request/RequestAttributeNames.java
Thu Oct 11 08:37:15 2007
@@ -22,4 +22,5 @@
     
     String REQUEST_ATTR_RESOURCE = PREFIX + "resource";
     String REQUEST_ATTR_CONTEXT = PREFIX + "context";
+    String REQUEST_ATTR_RESOLVED_SCRIPT_NODE = PREFIX + "scriptNode";
 }

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/requestcontext/SlingRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/requestcontext/SlingRequestContext.java?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/requestcontext/SlingRequestContext.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/requestcontext/SlingRequestContext.java
Thu Oct 11 08:37:15 2007
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
 package org.apache.sling.microsling.requestcontext;
 
 import javax.jcr.Repository;
@@ -9,6 +25,7 @@
 import org.apache.sling.microsling.api.SlingException;
 import org.apache.sling.microsling.request.RequestAttributeNames;
 
+/** Additional Request-based info used by for SlingServlets */
 public class SlingRequestContext {
 
     private final Session session;

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
Thu Oct 11 08:37:15 2007
@@ -1,3 +1,19 @@
+/*
+ * 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.
+ */
 package org.apache.sling.microsling.resource;
 
 import javax.jcr.Node;
@@ -5,6 +21,7 @@
 
 import org.apache.sling.microsling.api.Resource;
 
+/** A Resource that wraps a JCR Node */
 class JcrNodeResource implements Resource {
     final Node node;
     final String path;

Added: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java?rev=583855&view=auto
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
(added)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
Thu Oct 11 08:37:15 2007
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+package org.apache.sling.microsling.scripting;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.microsling.requestcontext.SlingRequestContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Find scripts in the repository, based on the current resource URI.
+ *  For now, a simple resolving algorithm is used, for example to find
+ *  a "vlt" script for request "content/testing/1192116498928.html":
+ *  
+ *  <pre>
+ *  SlingScriptResolver: Looking for script '/sling/scripts/content/testing/1192116498928/get.vlt'
+ *  SlingScriptResolver: Looking for script '/sling/scripts/content/testing/get.vlt'
+ *  SlingScriptResolver: Looking for script '/sling/scripts/content/get.vlt'
+ *  SlingScriptResolver: Found script '/sling/scripts/content/get.vlt' for resource path
'/content/testing/1192116498928'
+ *  </pre>
+ *  
+ *  The SlingScriptResolver goes up the hierarchy under /sling/scripts, starting from the
content path,
+ *  until a suitable script is found. In this case, the name of the script is "get" as Microsling
is 
+ *  currently processing an HTTP GET request.
+ */
+public class SlingScriptResolver {
+    
+    private static final Logger log = LoggerFactory.getLogger(SlingScriptResolver.class);
+    
+    public static final String SCRIPT_BASE_PATH = "/sling/scripts";
+    
+    /** Find a Node that contains a Script to handle the current resource, with the
+     *  specified script extension
+     */
+    public Node resolveScript(HttpServletRequest req,String extension) throws Exception {
+        final SlingRequestContext ctx = SlingRequestContext.getFromRequest(req);
+        final Session s = ctx.getSession();
+        String scriptPath = ctx.getContentPath();
+        Node result = null;
+        
+        while(result == null && scriptPath.length() > 0) {
+            final String scriptName = SCRIPT_BASE_PATH + scriptPath + "/" + req.getMethod().toLowerCase()
+ "." + extension;
+            log.debug("Looking for script '" + scriptName + "'");
+            try {
+                // do we have a script which is an nt:file at that path?
+                result = (Node)s.getItem(scriptName);
+                if(!result.hasNode("jcr:content")) {
+                    result = null;
+                }
+                log.info("Found script '" + result.getPath() + "' for resource path '" +
ctx.getContentPath() + "'");
+                
+            } catch(RepositoryException re) {
+                // ignore: script not found
+            }
+            
+            if(result==null) {
+                // go up the hierarchy to find a script
+                final int lastSlash = scriptPath.lastIndexOf('/');
+                if(lastSlash < 0) {
+                    scriptPath = "";
+                } else {
+                    scriptPath = scriptPath.substring(0,lastSlash); 
+                }
+            }
+        }
+        
+        return result;
+    }
+}

Propchange: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
Thu Oct 11 08:37:15 2007
@@ -36,6 +36,7 @@
 import org.apache.sling.microsling.resource.ResourceResolverFilter;
 import org.apache.sling.microsling.slingservlets.DefaultSlingServlet;
 import org.apache.sling.microsling.slingservlets.SlingPostServlet;
+import org.apache.sling.microsling.slingservlets.VelocityTemplatesServlet;
 
 /** The main Microsling servlet: processes requests using the Sling filters 
  *  to select a Resource and to apply processing to it.
@@ -51,12 +52,18 @@
     public void init() throws ServletException {
         super.init();
         
-        // TODO use OSGi to setup this list
-        requestFilters.add(new ResourceResolverFilter());
-        
-        // TODO use OSGi to setup this list 
-        servlets.add(new SlingPostServlet());
-        servlets.add(new DefaultSlingServlet());
+        try {
+            // TODO use OSGi to setup this list
+            requestFilters.add(new ResourceResolverFilter());
+            
+            // TODO use OSGi to setup this list 
+            servlets.add(new SlingPostServlet());
+            servlets.add(new VelocityTemplatesServlet());
+            servlets.add(new DefaultSlingServlet());
+            
+        } catch(Exception e) {
+            throw new ServletException("init() failed: " + e,e);
+        }
     }
 
     /** Process all requests by delegating to the first SlingServlet that

Added: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java?rev=583855&view=auto
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
(added)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
Thu Oct 11 08:37:15 2007
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+package org.apache.sling.microsling.slingservlets;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+
+import javax.jcr.Node;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.microsling.api.SlingException;
+import org.apache.sling.microsling.etc.AbstractSlingServlet;
+import org.apache.sling.microsling.request.RequestAttributeNames;
+import org.apache.sling.microsling.requestcontext.SlingRequestContext;
+import org.apache.sling.microsling.scripting.SlingScriptResolver;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+/** A SlingServlet that uses Velocity templates to render a Resource
+ *  in HTML.
+ */
+public class VelocityTemplatesServlet extends AbstractSlingServlet {
+
+    final SlingScriptResolver scriptResolver = new SlingScriptResolver();
+    public final static String VELOCITY_SCRIPT_EXTENSION = "vlt";
+    private final VelocityEngine velocity;
+        
+    public VelocityTemplatesServlet() throws Exception {
+        velocity = new VelocityEngine();
+        velocity.init();
+    }
+    
+    /** True if the request has an html extension, 
+     *  and if we find a Velocity templates script to handle it in
+     *  the repository.
+     */
+    public boolean canProcess(HttpServletRequest req) throws Exception {
+        boolean result = false;
+
+        final Node script = scriptResolver.resolveScript(req,VELOCITY_SCRIPT_EXTENSION);
+        if(script!=null) {
+            req.setAttribute(RequestAttributeNames.REQUEST_ATTR_RESOLVED_SCRIPT_NODE,script);
+            result = true;
+        }
+        
+        return result;
+    }
+
+    @Override
+    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws Exception
{
+        // grab the script node stored by canProcess
+        final Node scriptNode = (Node)req.getAttribute(RequestAttributeNames.REQUEST_ATTR_RESOLVED_SCRIPT_NODE);
+        if(scriptNode==null) {
+            throw new SlingException("Unexpected: scriptNode not found in request attributes");
+        }
+        
+        // access the script itself
+        final InputStream scriptStream = scriptNode.getNode("jcr:content").getProperty("jcr:data").getStream();
+        final Reader scriptReader = new InputStreamReader(scriptStream);
+        
+        // initialize the Velocity context
+        final VelocityContext c = new VelocityContext();
+        c.put("resource", getCurrentResource(req));
+        c.put("slingContext", SlingRequestContext.getFromRequest(req));
+        
+        // let Velocity evaluate the script, and send the output to the browser
+        resp.setContentType("text/html; charset=utf-8");
+        final Writer w = new OutputStreamWriter(resp.getOutputStream());
+        final String logTag = getClass().getSimpleName();
+        velocity.evaluate(c, w, logTag, scriptReader);
+        w.flush();
+    }
+    
+}

Propchange: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/slingservlets/VelocityTemplatesServlet.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/whiteboard/microsling/src/main/webapp/WEB-INF/log4j.xml
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/webapp/WEB-INF/log4j.xml?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/webapp/WEB-INF/log4j.xml (original)
+++ incubator/sling/whiteboard/microsling/src/main/webapp/WEB-INF/log4j.xml Thu Oct 11 08:37:15
2007
@@ -31,7 +31,7 @@
 
     <!-- log file -->
     <appender name="file" class="org.apache.log4j.FileAppender">
-        <param name="File" value="logs/jackrabbit-monarca-webapp.log"/>
+        <param name="File" value="logs/microsling.log"/>
         <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}:
%m (%F, line %L)%n"/>
         </layout>
@@ -40,7 +40,7 @@
     <!-- ====================================================================== -->
     <!-- C A T E G O R I E S                                                    -->
     <!-- ====================================================================== -->
-     <category name="org.apache.jackrabbit.monarca">
+     <category name="org.apache.sling">
       <priority value="debug"/>
       <appender-ref ref="console"/>
       <appender-ref ref="file"/>

Modified: incubator/sling/whiteboard/microsling/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/webapp/index.html?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/webapp/index.html (original)
+++ incubator/sling/whiteboard/microsling/src/main/webapp/index.html Thu Oct 11 08:37:15 2007
@@ -7,12 +7,12 @@
   <h1>Microsling homepage</h1>
   
   <p>
-  	Sling request processing, reduced to the max!
+  	<em>Sling request processing, reduced to the max!</em>
   </p>
   
   <h2>Overview</h2>
   <p>
-	The goal of this prototype is to demonstrate the Sling HTTP
+	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.
@@ -34,11 +34,16 @@
   	The SlingPostServlet allows nt:unstructured nodes to be created in the repository, for
testing,
   	by POSTing to URLs ending in <em>.sling</em>. See the <em>Content creation
form</em> below.
   </p>
+  <p>
+  	The SlingScriptResolver and VelocityTemplatesServlet are used to render content in HTML,
using
+  	Velocity scripts (we'll add more script languages soon) found in the repository under
/sling/scripts.
+  	See below, <em>Velocity Templates</em> for more info. 
+  </p>
   
   <h2>Microsling test links and forms</h2>
   <p>
     The <a href="microsling/testing-one-two.notfound">microsling/testing-one-two.notfound</a>
URL
-    should return a 404
+    should return an error 404.
   </p>
   
   <p>
@@ -47,7 +52,11 @@
       <h1>Content creation form</h1>
       <p>
         Submitting this form should create a node under content/testing, and display it using
-        an <em>html</em> extension:
+        an <em>html</em> extension. 
+      </p>
+      <p>
+        See below, <em>Velocity templates</em> for how to create
+        a rendering template for the resulting content.
       </p>
       <p>
 	      Title:
@@ -56,9 +65,9 @@
 	      <br/> 
 	      Text:
 	      <br/>
-	      <input name="text" type="text" size="80" value="Default text"/>
+	      <input name="text" type="text" size="80" value="Default text of the test node"/>
 	      <br/>
-	      <input type="submit" value="Update node"/> 
+	      <input type="submit" value="Create and display node"/> 
       </p>
     </form>
     
@@ -71,6 +80,61 @@
     </form>
     
   </p>
+  
+  <h2>Velocity templates</h2>
+  <p>
+  	When rendering content, the <em>VelocityTemplatesServlet</em> looks for scripts
with the
+  	<em>.vlt</em> extension under <em>/sling/scripts</em> in the JCR
repository. If a script
+  	is found, it used as a Velocity template to render the content.
+  </p>
+  <p>
+  	For microsling, Velocity is just another rendering templates mechanism, the architecture
allows
+  	additional rendering engines (JSP, Ruby, server-side Javascript, ...) to be plugged in
easily.   
+  </p>
+  <p>
+  	To test this, try storing (via WebDAV, see mount point URL below) the following script
in your 
+  	repository under <em>/sling/scripts/content/get.vlt</em>. Doing so will cause
the script to be used
+  	to render content found under <em>/content</em>, unless a more specific script
is
+  	found.
+  </p>
+  <p>
+  	 For example, when rendering the <em>/content/testing/xyz</em> resource, the

+  	 VelocityTemplatesServlet looks for scripts in this order:
+  	 <ul>
+  	   <li><em>/sling/scripts/content/testing/get.vlt</em></li>
+  	   <li><em>/sling/scripts/content/get.vlt</em></li>
+  	 </ul>  
+  	 The name <em>get.vlt</em> indicates that this script is meant to process
HTTP GET requests.
+  	 GET is probably the only request method that makes sense to process with Velocity, but
other
+  	 script types might be useful to process other HTTP methods. 
+  </p>
+  <p>
+    Here's the example script. See the <a href="http://velocity.apache.org">Velocity
website</a> for 
+    more info about the syntax. After activating it, content created using the <em>Content
creation form</em>
+    above should be displayed in HTML with a title that says <em>This is generated
from a Velocity template</em>.
+    <pre>
+&lt;html>
+&lt;body>
+&lt;h1>This is generated from a Velocity template&lt;/h1> 
+&lt;p> 
+  The current resource URI is &lt;b>$resource.URI&lt;/b>
+&lt;/p>
+
+&lt;h2>$resource.data.getProperty("title").getString()&lt;/h2>
+&lt;p>
+  $resource.data.getProperty("text").getString()
+&lt;/p>
+
+&lt;/body>
+&lt;/html></pre>
+    We could provide wrappers to allow simpler expressions to access data, but that's out
of scope
+    for this simple example.
+  </p>
+  <p>
+  	Removing or renaming the Velocity scripts found under <em>/sling/scripts/content/testing</em>

+  	will cause the <em>content/testing</em> pages to be rendered by the <em>DefaultSlingServlet</em>.

+  </p>
+  
   
   <h2>More test links</h2>
   <p>

Modified: incubator/sling/whiteboard/microsling/src/main/webapp/microsling.css
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/webapp/microsling.css?rev=583855&r1=583854&r2=583855&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/webapp/microsling.css (original)
+++ incubator/sling/whiteboard/microsling/src/main/webapp/microsling.css Thu Oct 11 08:37:15
2007
@@ -1,9 +1,11 @@
-/* use the jackrabbit site CSS */
-@import url("http://jackrabbit.apache.org/css/maven-base.css");
-@import url("http://jackrabbit.apache.org/css/maven-theme.css");
-@import url("http://jackrabbit.apache.org/css/site.css");
+body {
+	font-family: Verdana,Helvetica,Arial,sans-serif;
+}
+
+h1,h2,h3,h4 {
+	color:#869900;
+}
 
-/* for some reason the jackrabbit CSS doesn't define h1 */
 h1 {
 	border-color:#999999;
 	border-style:solid solid dotted;
@@ -14,6 +16,15 @@
 	padding:20px 4px 4px 0px;
 }
 
+h2 {
+	font-size: large;
+	font-weight:900;
+}
+
+h3 {
+	font-weight:900;
+}
+
 .testbox {
 	border: solid gray 1px;
 	margin: 1em;
@@ -24,4 +35,15 @@
 	padding: 1px;
 	margin: 1px;
 	font-size: 100%;		
+}
+
+p {
+	margin-bottom: 0.5em;
+}
+
+pre {
+	font-size: 120%;
+	background-color: #FFFFCC;
+	border: solid #FF9900 1px;
+	padding: 0.5em;
 }



Mime
View raw message