Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 49201 invoked from network); 11 Dec 2007 12:53:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2007 12:53:55 -0000 Received: (qmail 26280 invoked by uid 500); 11 Dec 2007 12:53:44 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 26235 invoked by uid 500); 11 Dec 2007 12:53:44 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 26226 invoked by uid 99); 11 Dec 2007 12:53:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 04:53:44 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 12:53:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CAD031A9832; Tue, 11 Dec 2007 04:53:19 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r603230 - in /incubator/sling/trunk/microsling/microsling-core/src: main/java/org/apache/sling/microsling/experimental/ main/java/org/apache/sling/microsling/slingservlets/ main/webapp/ main/webapp/microjax/ main/webapp/microjax/test/ main/... Date: Tue, 11 Dec 2007 12:53:00 -0000 To: sling-commits@incubator.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071211125319.CAD031A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Tue Dec 11 04:52:56 2007 New Revision: 603230 URL: http://svn.apache.org/viewvc?rev=603230&view=rev Log: SLING-131, use 'ujax' as the short name for microjax in filenames, parameter names, etc. Added: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/assert.js incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/ujax-test.html incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/ujax.js incubator/sling/trunk/microsling/microsling-core/src/main/webapp/usling.css - copied unchanged from r603187, incubator/sling/trunk/microsling/microsling-core/src/main/webapp/microsling.css Removed: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/microjax/microjax.js incubator/sling/trunk/microsling/microsling-core/src/main/webapp/microjax/test/ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/microsling.css Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java 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/javascript.html incubator/sling/trunk/microsling/microsling-core/src/main/webapp/velocity-scripts.html incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/StaticContentTest.java incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxAutoPropertiesTest.java incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxSessionInfoTest.java incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletCreateTest.java incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletDeleteTest.java incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletOrderTest.java incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletUpdateTest.java Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/experimental/JstScriptEngine.java Tue Dec 11 04:52:56 2007 @@ -54,7 +54,7 @@ public JstScriptEngine() { // TODO hardcoded for now... - libraryScripts.add("/microjax/microjax.js"); + libraryScripts.add("/ujax/ujax.js"); htmlRenderer = new DefaultHtmlRenderer(); } Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxGetServlet.java Tue Dec 11 04:52:56 2007 @@ -35,13 +35,13 @@ import org.apache.sling.commons.json.JSONException; import org.apache.sling.commons.json.io.JSONWriter; -/** Servlet that provides some non-repository resources for microjax +/** Servlet that provides some non-repository resources for ujax * using GET requests, see SLING-92 */ public class MicrojaxGetServlet extends SlingSafeMethodsServlet { private static final long serialVersionUID = -8406117284723670902L; /** Handle GET requests starting with this prefix */ - public static final String URI_PREFIX = "/microjax:"; + public static final String URI_PREFIX = "/ujax:"; @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/MicrojaxPostServlet.java Tue Dec 11 04:52:56 2007 @@ -41,7 +41,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Servlet that implements the microjax POST "protocol", see SLING-92 */ +import freemarker.ext.ant.UnlinkedJythonOperationsImpl; + +/** Servlet that implements the ujax POST "protocol", see SLING-92 */ public class MicrojaxPostServlet extends SlingAllMethodsServlet { private static final long serialVersionUID = 1837674988291697074L; @@ -52,7 +54,7 @@ /** Prefix for parameter names which control this POST * (ujax stands for "microjax", RP_ stands for "request param") */ - public static final String RP_PREFIX = "ujax_"; + public static final String RP_PREFIX = "ujax:"; /** Optional request parameter: redirect to the specified URL after POST */ public static final String RP_REDIRECT_TO = RP_PREFIX + "redirect"; @@ -266,6 +268,12 @@ for(Map.Entry e : request.getRequestParameterMap().entrySet()) { final String paramName = e.getKey(); + + if(paramName.startsWith(RP_PREFIX)) { + // do not store parameters with names starting with ujax: + continue; + } + String propertyName = paramName; if(savePrefix!=null) { if(!paramName.startsWith(savePrefix)) { 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=603230&r1=603229&r2=603230&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 Tue Dec 11 04:52:56 2007 @@ -1,27 +1,27 @@ - microsling content creation forms - + µsling content creation forms + -

microsling content creation forms

+

µsling content creation forms

- Use these forms to test the microsling request processing and rendering SlingServlets. + Use these forms to test the µsling request processing and rendering SlingServlets.

- - + + -

SlingPostServlet content creation form

+

µjaxPostServlet content creation form

Submitting this form creates an nt:unstructured node under content/testing, and displays it using an html extension. @@ -42,7 +42,7 @@ sling:resourceType: (leave this empty to use the JCR node type for script resolution)
- +

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=603230&r1=603229&r2=603230&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 Tue Dec 11 04:52:56 2007 @@ -1,10 +1,10 @@ - microsling Ruby Erb templates - + µsling Ruby Erb templates + -

microsling Ruby Erb templates

+

µsling Ruby Erb templates

back to homepage 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=603230&r1=603229&r2=603230&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 Tue Dec 11 04:52:56 2007 @@ -1,10 +1,10 @@ - microsling FreeMarker templates - + µsling FreeMarker templates + -

microsling FreeMarker templates

+

µsling FreeMarker templates

back to homepage 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=603230&r1=603229&r2=603230&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 Tue Dec 11 04:52:56 2007 @@ -1,47 +1,48 @@ - microsling homepage - + µsling homepage + -

microsling homepage

+

µsling homepage

Overview

- microsling started as "back to basics" rewrite of Sling (which is heavier, using OSGi, and - at the time was much harder to understand). + µsling (pronounced microsling) started as "back to basics" rewrite of Sling, which is heavier, using OSGi, and + at the time was much harder to understand.

- As I write this (early December 2007), microsling is perfectly usable to create scripted + As I write this (early December 2007), µsling is perfectly usable to create scripted JCR-based applications (it runs dev.day.com 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.

- The microjax.js client-side javascript library provides a simple javascript "proxy" on the - JCR repository. + The ujax.js client-side javascript library provides a simple javascript "proxy" on the + JCR repository. The name ujax should really by written µjax (microjax), but for all + filenames and technical names (parameters etc.) with use "ujax" to avoid encoding problems.

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.

-

microsling main test links

+

µsling main test links

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=603230&r1=603229&r2=603230&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:52:56 2007 @@ -1,10 +1,10 @@ - Use of javascript in microsling - + Use of javascript in µsling + -

Use of javascript in microsling

+

Use of javascript in µsling

back to homepage @@ -16,8 +16,8 @@ now we'll leave it at that).

- If you created content with the microsling test content creation form, rendering scripts should be stored - in the repository under /sling/scripts/microsling/example/. Mount the repository with WebDAV to + If you created content with the µsling test content creation form, rendering scripts should be stored + in the repository under /sling/scripts/usling/example/. Mount the repository with WebDAV to do that, see the WebDAV link on the homepage.

@@ -51,14 +51,14 @@ <%= ... %> tags include the result of a javascript expression in the output.

  • - Several standard objects are available in javascript to access microsling data + Several standard objects are available in javascript to access µsling data (TODO: document these objects - for now see the RhinoJavascriptServlet source code)
  • ESP template example

    -<%-- microsling ESP template example, store this as html.esp --%>
    +<%-- ESP template example, store this as html.esp --%>
     <html>
     <body>
     <p>This page is generated from an ESP template!</p>
    @@ -128,7 +128,7 @@
         slingComponentId property.
       

    -<%-- microsling ESP directory listing example -%>
    +<%-- ESP directory listing example -%>
     <html>
     <body>
     <p>This HTML directory listing is generated from an ESP template!</p>
    @@ -137,7 +137,7 @@
     <%
     for (var prop in resource.node) {
         if (resource.node[prop]["text"]) {
    -        %><li><a href="/microsling<%= resource.node[prop] %>.html"><%= resource.node[prop] %></a></li><%
    +        %><li><a href="/<%= resource.node[prop] %>.html"><%= resource.node[prop] %></a></li><%
         }
     }
     %>
    
    Added: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/assert.js
    URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/assert.js?rev=603230&view=auto
    ==============================================================================
    --- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/assert.js (added)
    +++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/assert.js Tue Dec 11 04:52:56 2007
    @@ -0,0 +1,46 @@
    +/*
    + * 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.
    + */
    +
    +/* 
    +	Minimal javascript assertion framework, used for ujax automated testing.
    +	
    +	$Id$
    + */
    +
    +function assert(message,condition) {
    +  if(condition != true) {
    +    alert("Assertion failed: " + message);
    +  }
    +}
    +
    +function assertEquals(message,a,b) {
    +  if(a!=b) {
    +    alert("assertEquals failed: " + message + ": " + a + "!=" + b);
    +  }
    +}
    +
    +function assertNotNull(message,o) {
    +  if(o==null) {
    +    alert("assertNotNull failed: " + message);
    +  }
    +}
    +
    +function assertNull(message,o) {
    +  if(o!=null) {
    +    alert("assertNull failed: " + message);
    +  }
    +}
    
    Added: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/ujax-test.html
    URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/ujax-test.html?rev=603230&view=auto
    ==============================================================================
    --- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/ujax-test.html (added)
    +++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/test/ujax-test.html Tue Dec 11 04:52:56 2007
    @@ -0,0 +1,132 @@
    +
    +	
    +
    +	
    +		µjax test page
    +		
    +		
    +		
    +    
    +        
    +	
    +	
    +	
    + 
    +	 

    Automated µjax tests

    +

    + Loading this page executes some simple automated javascript tests of the µjax library. +

    + +

    Test results

    +

    + If all goes well, the paragraph styled like this below should say "Done running tests". +

    +

    + Tests run quickly, this might have happened already. +

    +

    + To run the tests again click here. +

    +
    + Tests are not running yet. +
    + +

    More info

    +

    + After running the tests at least once, + /ujax-test/testhtml-nodes.json + should show the JSON data of the nodes created by the test cases. +

    +

    + See the source code of this page for details. +

    + + + + + + Added: incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/ujax.js URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/ujax.js?rev=603230&view=auto ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/ujax.js (added) +++ incubator/sling/trunk/microsling/microsling-core/src/main/webapp/ujax/ujax.js Tue Dec 11 04:52:56 2007 @@ -0,0 +1,402 @@ +/* + * 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. + */ + +/** + * The ujax javascript client gives access to a JCR repository + * from client-side java code, using microsling as a back-end. + * + * @version $Rev: $, $Date: 2007-03-27 16:30:52 +0200 (Tue, 27 Mar 2007) $ + */ + +var ujax = null; + +// start ujax code scope +(function() { + + ujax = new Object(); + ujax.NAME_OF_THIS_FILE = "ujax.js"; + + /** This method tries to figure out what to do with a page */ + ujax.wizard = function() { + //TODO add lots of magic here + var form=document.getElementById("ujaxform"); + if (!form) form=document.forms[0]; + if (form) { + var sp=new Object(); + sp.formElement=form; + ujax.setupPage(sp); + } + + } + /** Call this to merge ujax data in an HTML page + TODO deprecate other functions + */ + ujax.setupPage = function(options) { + var tree = ujax.getContent(ujax._getJsonUrl(),1); + + if(options.formElement) { + ujax._setFormValues(options.formElement,ujax._getJsonUrl(),tree); + } + + if(options.displayElement) { + ujax.displayValues(options.displayElement,tree); + } + } + + /** + * HTTP GET XHR Helper + * @param {String} url The URL + * @return the XHR object, use .responseText for the data + * @type String + */ + ujax.httpGet = function(url) { + var httpcon = ujax.getXHR(); + if (httpcon) { + httpcon.open('GET', url, false); + httpcon.send(null); + return httpcon; + } else { + return null; + } + } + /** + * Produces a "sort-of-json" string representation of a object + * for debugging purposes only + * @param {Object} obj The object + * @param {int} level The indentation level + * @return The result + * @type String + */ + ujax.dumpObj = function(obj, level) { + var res=""; + for (var a in obj) { + if (typeof(obj[a])!="object") { + res+=a+":"+obj[a]+" "; + } else { + res+=a+": { "; + res+=ujax.dumpObj(obj[a])+"} "; + } + } + return (res); + } + + /** Produces an aggregate of get all the property names used + * in a tree as a helper for table oriented display + * @param {Object} obj The Content Tree object + * @param {Object} names internal object used for collecting all + * the names during the recursion + * @return An Array of names of properties that exist in a tree + * @type Array + */ + ujax.getAllPropNames = function(obj, names) { + var root=false; + if (!names) { + names=new Object(); + root=true; + } + for (var a in obj) { + if (typeof(obj[a])!="object") { + names[a]="1"; + } else { + getAllPropNames(obj[a], names); + } + } + if (root) { + var ar=new Array(); + var i=0; + for (var a in ar) { + ar[i]=a; + i++; + } + names=ar; + } + return (names); + } + + /** Reads a tree of items given a maxlevel from the repository as JSON + * @param {String} path Path into the current workspace + * @param {int} maxlevel maximum depth to traverse to + * @param {Array} filters filter only these properties + * @return An Object tree of content nodes and properties, null if not found + * @type Object + */ + ujax.getContent = function(path, maxlevels) { + var obj=new Object(); + if (!path) { + path=ujax.currentPath; + } + if (path.indexOf("/")==0) { + /* + this assumes that paths that start with a slash + are meant to be workspace paths rather than URLs + and therefore need some additions before they are sent + to the server + */ + path=ujax.baseurl+path+".json"; + } + //checking for a trailing "/*" + if (path.indexOf("/*")>=0) return obj; + + // TODO for now we explicitely defeat caching on this...there must be a better way + // but in tests IE6 tends to cache too much + var passThroughCacheParam = "?clock=" + new Date().getTime(); + var res=ujax.httpGet(path + passThroughCacheParam + (maxlevels?"&maxlevels="+maxlevels:"")); + + if(res.status == 200) { + return ujax.evalString(res.responseText); + } + return null; + } + + /** Remove content by path */ + ujax.removeContent = function(path) { + var httpcon = ujax.getXHR(); + if (httpcon) { + var params = "ujax:delete="+path; + httpcon.open('POST', ujax.baseurl + ujax.currentPath, false); + + // Send the proper header information along with the request + httpcon.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + httpcon.setRequestHeader("Content-length", params.length); + httpcon.setRequestHeader("Connection", "close"); + httpcon.send(params); + return httpcon; + } else { + return false; + } + } + + /** eval str, accepting various object delimiters */ + ujax.evalString = function(str) { + var obj = null; + if(str.indexOf('[')==0) { + eval("obj="+str); + } else if(str.indexOf('{')==0) { + eval("obj="+str); + } else { + eval("obj={"+str+"}"); + } + return obj; + } + + /** Get "session info" from repository. Mainly answers the question: "Who am I" + * and "Which workspace am I logged into. + * @return An Object tree containing the session information, null if server status <> 200 + * @type Object + */ + ujax.getSessionInfo = function() { + var res=ujax.httpGet(ujax.baseurl+"/ujax:sessionInfo.json"); + if(res.status == 200) { + return ujax.evalString(res.responseText); + } + return null; + } + + /** Replace extension in a path */ + ujax._replaceExtension = function(path,newExtension) { + var i = path.lastIndexOf("."); + if(i >= 0) path = path.substring(0,i); + i = path.lastIndexOf("."); + if(i >= 0) path = path.substring(0,i); + return path + newExtension; + } + + /** Get the JSON data URL that for the current page + * (assuming a .extension for the current page, .html or something else) + */ + ujax._getJsonUrl = function() { + return ujax._replaceExtension(window.location.href,".json"); + } + + /** Get the content repository path from the URL + * (assuming a .extension for the current page, .html or something else) + */ + ujax._getPath = function() { + + var noextensions=ujax._replaceExtension(window.location.href,""); + var path=noextensions.substring(ujax.baseurl.length); + return (path); + } + + /** Display values inside a container: an element inside given container, + * with an id like ./stuff, has its innerHTML set to the value of stuff + * in the tree, if it exists. + */ + ujax.displayValues = function(container,tree) { + if(!tree) { + tree = ujax.getContent(ujax._getJsonUrl(),1); + } + + var elements = container.getElementsByTagName("*"); + var toSet = new Array(); + for (var i = 0; i < elements.length; i++) { + var value = ujax._getElementValue(elements[i],tree); + if(value) { + toSet[toSet.length] = { e:elements[i], v:value }; + } + } + + for(var i = 0; i < toSet.length; i++) { + toSet[i].e.innerHTML = toSet[i].v; + } + } + + /** If e has an ID that matches a property of tree, set e's innerHTML accordingly */ + ujax._getElementValue = function(e,tree) { + var id = e.getAttribute("id"); + if(id) { + return tree[id.substring(2)]; + } + } + + + /** Set form elements based on the tree of items passed into the method + * @param {IdOrElement} form the Form element to set, or its id + * @param {String} path passes a string specifying the path + * @param {Object} tree optionally pass the content that you want the + * form to be populated with. This assumes an item tree as returned by + * getContent(). + * Returns an object indicating whether data was found on the server. + * + */ + ujax._setFormValues = function(form, path, tree) { + var result = new Object(); + + /** TODO: deal with abolute paths? + * TODO: deal with @ValueFrom + */ + if (!path) return; + + form.setAttribute("action", path); + + if (!tree) { + tree=ujax.getContent(path,1); + } + + var elems=form.elements; + var i=0; + formfieldprefix=""; + + while (elems.length > i) { + var elem=elems[i]; + var a=elem.name; + if (a.indexOf("./")==0) { + formfieldprefix="./"; + break; + } + i++; + } + + var i=0; + while (elems.length > i) { + var elem=elems[i]; + var a=elem.name; + if (a.indexOf(formfieldprefix)==0) { + var propname=a.substring(formfieldprefix.length); + if (tree[propname]) { + if (elem.type == "file") { + // cannot edit uplodaded files for now + } else if (elem.type == "checkbox") { + var vals; + if (typeof(tree[propname])=="object") vals=tree[a.substring(2)]; + else { + vals=new Array(); + vals[0]=tree[propname]; + } + var j=0; + while (vals.length > j) { + if (vals[j] == elem.value) elem.checked=true; + j++; + } + } else { + elem.value=tree[propname]; + } + } + + } + i++; + } + + } + + /** return Path as specified as the URL Parameter + * @param URL + * @return The Path parameter isolated from the URL + * @type String + */ + ujax.TODO_NOT_USED_isolatePathFromUrl = function(url) { + var pattern = "[\\?&]Path=([^&#]*)"; + var regex = new RegExp( pattern ); + var results = regex.exec( url ); + if( results == null ) + // none found + return ""; + else + // found + return unescape(results[1]); + } + + /** + * Get an XMLHttpRequest in a portable way + * + */ + ujax.getXHR = function () { + var xhr=null; + + if(!xhr) { + try { + // built-in (firefox, recent Opera versions, etc) + xhr=new XMLHttpRequest(); + } catch (e) { + // ignore + } + } + + if(!xhr) { + try { + // IE, newer versions + xhr=new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + // ignore + } + } + + if(!xhr) { + try { + // IE, older versions + xhr=new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + // ignore + } + } + + if(!xhr) { + alert("Unable to access XMLHttpRequest object, ujax will not work!"); + } + + return xhr; + } + + // obtain the base_url to communicate with ujax on the server + var scripts = document.getElementsByTagName("SCRIPT") + var script = scripts[scripts.length-1].src + ujax.baseurl = script.substring(0,script.length - ("/" + ujax.NAME_OF_THIS_FILE.length)); + ujax.currentPath = ujax._getPath(); + ujax.isNew = (ujax.currentPath.indexOf("/*")>=0)?true:false; + +// end ujax code scope +})(); \ No newline at end of file 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=603230&r1=603229&r2=603230&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 Tue Dec 11 04:52:56 2007 @@ -1,10 +1,10 @@ - microsling Velocity templates - + µsling Velocity templates + -

    microsling Velocity templates

    +

    µsling Velocity templates

    back to homepage @@ -22,10 +22,10 @@ is found, it used as a Velocity template to render the content.

    - To test this, try storing (via WebDAV, see mount point URL on the microsling homepage) the following script in your - repository under /sling/scripts/microsling/example/html.vlt . - Doing so will cause microsling to use that script - to render nodes having sling:resourceType=microsling/example. + To test this, try storing (via WebDAV, see mount point URL on the µsling homepage) the following script in your + repository under /sling/scripts/usling/example/html.vlt . + Doing so will cause µsling to use that script + to render nodes having sling:resourceType=usling/example.

    To try that rendering, use the content creation page to create Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PostRedirectTest.java Tue Dec 11 04:52:56 2007 @@ -29,7 +29,7 @@ public void testForcedRedirect() throws IOException { final Map params = new HashMap(); - params.put("ujax_redirect","http://forced/"); + params.put("ujax:redirect","http://forced/"); final Map headers = new HashMap(); headers.put("Referer", "http://referer/"); @@ -54,7 +54,7 @@ public void testMagicStarRedirect() throws IOException { final Map params = new HashMap(); - params.put("ujax_redirect","*"); + params.put("ujax:redirect","*"); final Map headers = new HashMap(); headers.put("Referer", "http://referer/"); final String location = testClient.createNode(postUrl, params, headers); Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/StaticContentTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/StaticContentTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/StaticContentTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/StaticContentTest.java Tue Dec 11 04:52:56 2007 @@ -27,11 +27,11 @@ } public void testContentTypeCss() throws IOException { - getContent(HTTP_BASE_URL + "/microsling.css", CONTENT_TYPE_CSS); + getContent(HTTP_BASE_URL + "/usling.css", CONTENT_TYPE_CSS); } public void testContentTypeJs() throws IOException { - getContent(HTTP_BASE_URL + "/microjax/microjax.js", CONTENT_TYPE_JS); + getContent(HTTP_BASE_URL + "/ujax/ujax.js", CONTENT_TYPE_JS); } public void testWebInfForbidden() throws IOException { Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxAutoPropertiesTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxAutoPropertiesTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxAutoPropertiesTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxAutoPropertiesTest.java Tue Dec 11 04:52:56 2007 @@ -30,7 +30,7 @@ public class MicrojaxAutoPropertiesTest extends MicroslingHttpTestBase { - public static final String TEST_BASE_PATH = "/microjax-tests"; + public static final String TEST_BASE_PATH = "/ujax-tests"; private String postUrl; @Override Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxSessionInfoTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxSessionInfoTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxSessionInfoTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/MicrojaxSessionInfoTest.java Tue Dec 11 04:52:56 2007 @@ -22,16 +22,16 @@ import org.apache.sling.microsling.integration.MicroslingHttpTestBase; -/** Test the microjax:sessionInfo resource */ +/** Test the ujax:sessionInfo resource */ public class MicrojaxSessionInfoTest extends MicroslingHttpTestBase { public void testSessionInfo() throws IOException { - final String content = getContent(HTTP_BASE_URL + "/microjax:sessionInfo.json", CONTENT_TYPE_JSON); + final String content = getContent(HTTP_BASE_URL + "/ujax:sessionInfo.json", CONTENT_TYPE_JSON); assertJavascript("admin.default", content, "out.println(data.userID + '.' + data.workspace)"); } public void testNonexistentMicrojaxUrl() throws IOException { - assertHttpStatus(HTTP_BASE_URL + "/microjax:nothing", HttpServletResponse.SC_NOT_FOUND); + assertHttpStatus(HTTP_BASE_URL + "/ujax:nothing", HttpServletResponse.SC_NOT_FOUND); } } Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletCreateTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletCreateTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletCreateTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletCreateTest.java Tue Dec 11 04:52:56 2007 @@ -26,7 +26,7 @@ /** Test node creation via the MicrojaxPostServlet */ public class PostServletCreateTest extends MicroslingHttpTestBase { - public static final String TEST_BASE_PATH = "/microjax-tests"; + public static final String TEST_BASE_PATH = "/ujax-tests"; private String postUrl; @Override @@ -101,7 +101,7 @@ props.put("++a","123"); props.put("++b","456"); props.put("c","not saved"); - props.put("ujax_saveParamPrefix","++"); + props.put("ujax:saveParamPrefix","++"); final String createdNodeUrl = testClient.createNode(postUrl + "/*", props); final String content = getContent(createdNodeUrl + ".json", CONTENT_TYPE_JSON); assertJavascript("123456", content, "out.println(data.a + data.b)"); Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletDeleteTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletDeleteTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletDeleteTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletDeleteTest.java Tue Dec 11 04:52:56 2007 @@ -27,7 +27,7 @@ /** Test node deletion via the MicrojaxPostServlet */ public class PostServletDeleteTest extends MicroslingHttpTestBase { - public static final String TEST_BASE_PATH = "/microjax-tests"; + public static final String TEST_BASE_PATH = "/ujax-tests"; private String postUrl; @Override @@ -55,7 +55,7 @@ // delete one and check final List params = new LinkedList (); - final String deleteCmd = "ujax_delete"; + final String deleteCmd = "ujax:delete"; params.add(new NameValuePair(deleteCmd,urlToNodePath(urlA))); assertPostStatus(postUrl,HttpServletResponse.SC_OK,params,"Delete must return status OK (1)"); assertHttpStatus(urlA, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (1)"); Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletOrderTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletOrderTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletOrderTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletOrderTest.java Tue Dec 11 04:52:56 2007 @@ -26,7 +26,7 @@ /** Test the order option for node creation via the MicrojaxPostServlet */ public class PostServletOrderTest extends MicroslingHttpTestBase { - public static final String TEST_BASE_PATH = "/microjax-tests"; + public static final String TEST_BASE_PATH = "/ujax-tests"; private String postUrl; @Override @@ -67,7 +67,7 @@ /** Create several nodes with the order option, and check ordering */ public void testZeroOrder() throws IOException { final Map props = new HashMap (); - props.put("ujax_order","0"); + props.put("ujax:order","0"); final String [] nodeUrl = new String[4]; nodeUrl[0] = testClient.createNode(postUrl + "/*", props); Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletUpdateTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletUpdateTest.java?rev=603230&r1=603229&r2=603230&view=diff ============================================================================== --- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletUpdateTest.java (original) +++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/microjax/PostServletUpdateTest.java Tue Dec 11 04:52:56 2007 @@ -26,7 +26,7 @@ /** Test node updates via the MicrojaxPostServlet */ public class PostServletUpdateTest extends MicroslingHttpTestBase { - public static final String TEST_BASE_PATH = "/microjax-tests"; + public static final String TEST_BASE_PATH = "/ujax-tests"; private String postUrl; @Override