incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r643830 - in /incubator/sling/trunk: launchpad/content/src/main/resources/content/sling-test/sling/ sling/servlets-post/ sling/servlets-post/src/main/resources/bundles/ sling/servlets-post/src/main/resources/bundles/sling/ sling/servlets-po...
Date Wed, 02 Apr 2008 10:12:10 GMT
Author: bdelacretaz
Date: Wed Apr  2 03:11:54 2008
New Revision: 643830

URL: http://svn.apache.org/viewvc?rev=643830&view=rev
Log:
SLING-351 - Use uppercase Sling in sling.js, and sling.js moved to /bundles/sling/sling.js
as /sling/sling.js is hidden by the OSGi console

Added:
    incubator/sling/trunk/sling/servlets-post/src/main/resources/bundles/
    incubator/sling/trunk/sling/servlets-post/src/main/resources/bundles/sling/
      - copied from r643785, incubator/sling/trunk/sling/servlets-post/src/main/resources/sling/
Removed:
    incubator/sling/trunk/sling/servlets-post/src/main/resources/sling/
Modified:
    incubator/sling/trunk/launchpad/content/src/main/resources/content/sling-test/sling/sling-test.html
    incubator/sling/trunk/sling/servlets-post/pom.xml
    incubator/sling/trunk/sling/servlets-post/src/main/resources/bundles/sling/sling.js

Modified: incubator/sling/trunk/launchpad/content/src/main/resources/content/sling-test/sling/sling-test.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/content/src/main/resources/content/sling-test/sling/sling-test.html?rev=643830&r1=643829&r2=643830&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/content/src/main/resources/content/sling-test/sling/sling-test.html
(original)
+++ incubator/sling/trunk/launchpad/content/src/main/resources/content/sling-test/sling/sling-test.html
Wed Apr  2 03:11:54 2008
@@ -18,9 +18,9 @@
 -->
 
 <head>
-	<title>&micro;jax test page</title>
+	<title>Sling client library test page</title>
 	
-	<script src="/sling/sling.js"></script>
+	<script src="/bundles/sling/sling.js"></script>
 	<script src="assert.js"></script>
 	
 	<style type="text/css">
@@ -41,13 +41,13 @@
 
 <body onload="runTests()">
 
-<h1>Automated &micro;jax tests</h1>
+<h1>Automated Sling client library tests</h1>
 <p class="warning">TODO: for now, running these tests requires setting <em>Allow
 Anonymous Access</em> to <em>false</em> on the Sling <em>Authentication
 Filter</em> configuration page.</p>
 
 <p>Loading this page executes some simple automated javascript tests
-of the &micro;jax library.</p>
+of the Sling client library.</p>
 
 <h2>Test results</h2>
 <p>If all goes well, the paragraph styled <span class="output">like
@@ -67,7 +67,7 @@
 
 <script language="javascript">
 	  function slingPost(url,params) {
-	    var httpcon = sling.getXHR();
+	    var httpcon = Sling.getXHR();
 	    httpcon.open("POST", url, false);
 	    httpcon.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 	    httpcon.setRequestHeader("Content-length", params.length);
@@ -87,7 +87,7 @@
 	  }
 	  
 	  function verifyPostedElement() {
-	    var data = sling.getContent(testPath,1);
+	    var data = Sling.getContent(testPath,1);
 	    assertNotNull("data",data);
 	    assertEquals("title matches","hello",data.title);
 	    assertEquals("time matches",now,data.time);
@@ -99,7 +99,8 @@
 	  }
 	  
 	  function testGetSessionInfo() {
-	    var session = sling.getSessionInfo();
+	    var session = Sling.getSessionInfo();
+	    assertNotNull("Sling.getSessionInfo()", session);
 	    assertEquals("session.userID is a string","string",typeof(session.userID));
         assertEquals("session.userID == 'admin'","admin",session.userID);
 	    assertEquals("session.workspace is a string","string",typeof(session.workspace));
@@ -111,19 +112,19 @@
 	    var c = slingPost(deletePath,"title=hello&created=&dummy=&time=" + now);
 	    assert("Expected 200 status for POST",c.status == 200);
 	    
-	    var data = sling.getContent(deletePath,1);
+	    var data = Sling.getContent(deletePath,1);
 	    assertNotNull("data must be found before removeContent",data);
 	    
-	    var d = sling.removeContent(deletePath);
+	    var d = Sling.removeContent(deletePath);
 	    assert("Expected 200 status for removeContent, got " + d.status,d.status == 200);
-	    data = sling.getContent(deletePath,1);
+	    data = Sling.getContent(deletePath,1);
 	    assertNull("data should be gone after deletePath (" + deletePath + ")",data);
 	  }
 	  
 	  function testJsonLevels() {
 	    var c = slingPost(baseTestPath + "/json-levels", "title=JsonLevelsTest");
-	    var data0 = sling.getContent(baseTestPath,0);
-	    var data1 = sling.getContent(baseTestPath,1);
+	    var data0 = Sling.getContent(baseTestPath,0);
+	    var data1 = Sling.getContent(baseTestPath,1);
 	    assert("Level 0 must not provide child", typeof data0['json-levels'] == "undefined");
 	    assert("Level 1 must provide child", typeof data1['json-levels'] == "object");
 	    assert("Level 1 must provide child title", data1['json-levels'].title == "JsonLevelsTest");

Modified: incubator/sling/trunk/sling/servlets-post/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/pom.xml?rev=643830&r1=643829&r2=643830&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/pom.xml (original)
+++ incubator/sling/trunk/sling/servlets-post/pom.xml Wed Apr  2 03:11:54 2008
@@ -64,7 +64,7 @@
                             org.apache.sling.servlets.post.impl
                         </Private-Package>
                         <Sling-Bundle-Resources>
-                            /sling/sling.js
+                            /bundles/sling/sling.js
                         </Sling-Bundle-Resources>
                     </instructions>
                 </configuration>

Modified: incubator/sling/trunk/sling/servlets-post/src/main/resources/bundles/sling/sling.js
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-post/src/main/resources/bundles/sling/sling.js?rev=643830&r1=643785&r2=643830&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-post/src/main/resources/bundles/sling/sling.js (original)
+++ incubator/sling/trunk/sling/servlets-post/src/main/resources/bundles/sling/sling.js Wed
Apr  2 03:11:54 2008
@@ -22,38 +22,38 @@
  * @version $Rev: $, $Date: 2007-03-27 16:30:52 +0200 (Tue, 27 Mar 2007) $
  */
 
-var sling = null;
+var Sling = null;
 
 // start sling code scope
 (function() {
 
-	sling = new Object();
-	sling.NAME_OF_THIS_FILE = "sling.js";
+	Sling = new Object();
+	Sling.NAME_OF_THIS_FILE = "Sling.js";
 	
 	/** This method tries to figure out what to do with a page */
-	sling.wizard = function() {
+	Sling.wizard = function() {
 	    //TODO add lots of magic here
 	    var form=document.getElementById("slingform");
 	    if (!form) form=document.forms[0];
 	    if (form) {
 	        var sp=new Object();
 	        sp.formElement=form;
-	        sling.setupPage(sp);
+	        Sling.setupPage(sp);
 	    }
 	
 	}
 	/** Call this to merge sling data in an HTML page
 		TODO deprecate other functions
 	*/
-	sling.setupPage = function(options) {
-	  var tree = sling.getContent(sling._getJsonUrl(),1);
+	Sling.setupPage = function(options) {
+	  var tree = Sling.getContent(Sling._getJsonUrl(),1);
 	  
 	  if(options.formElement) {
-		sling._setFormValues(options.formElement,sling._getJsonUrl(),tree);
+		Sling._setFormValues(options.formElement,Sling._getJsonUrl(),tree);
 	  }
 	  
 	  if(options.displayElement) {
-	  	sling.displayValues(options.displayElement,tree);
+	  	Sling.displayValues(options.displayElement,tree);
 	  }
 	}
 	
@@ -63,8 +63,8 @@
 	 * @return the XHR object, use .responseText for the data
 	 * @type String
 	 */
-	sling.httpGet = function(url) {
-	    var httpcon = sling.getXHR();
+	Sling.httpGet = function(url) {
+	    var httpcon = Sling.getXHR();
 	    if (httpcon) {
 			httpcon.open('GET', url, false);
 			httpcon.send(null);
@@ -81,14 +81,14 @@
 	 * @return The result
 	 * @type String
 	 */
-	sling.dumpObj = function(obj, level) {
+	Sling.dumpObj = function(obj, level) {
 		var res="";
 		for (var a in obj) {
 			if (typeof(obj[a])!="object") {
 				res+=a+":"+obj[a]+"  ";
 			} else {
 				res+=a+": { ";
-				res+=sling.dumpObj(obj[a])+"} ";
+				res+=Sling.dumpObj(obj[a])+"} ";
 			}
 		}
 		return (res);
@@ -102,7 +102,7 @@
 	 * @return An Array of names of properties that exist in a tree
 	 * @type Array
 	 */
-	sling.getAllPropNames = function(obj, names) {
+	Sling.getAllPropNames = function(obj, names) {
 		var root=false;
 	    if (!names) {
 	        names=new Object();
@@ -134,10 +134,10 @@
 	 * @return An Object tree of content nodes and properties, null if not found
 	 * @type Object
 	 */
-	sling.getContent = function(path, maxlevels, filter) {
+	Sling.getContent = function(path, maxlevels, filter) {
 	    var obj=new Object();
 	    if (!path)  {
-	        path=sling.currentPath;
+	        path=Sling.currentPath;
 	    }
 	    if (path.indexOf("/")==0) {
 			/*
@@ -151,7 +151,7 @@
 			} else {
 			  maxlevels = "";
 			}
-			path=sling.baseurl + path + maxlevels + ".json";
+			path=Sling.baseurl + path + maxlevels + ".json";
 		}
 	    //checking for a trailing "/*"
 	    if (path.indexOf("/*")>=0) return obj;
@@ -159,10 +159,10 @@
 		// 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=sling.httpGet(path + passThroughCacheParam + (maxlevels?"&maxlevels="+maxlevels:""));
+	    var res=Sling.httpGet(path + passThroughCacheParam + (maxlevels?"&maxlevels="+maxlevels:""));
 	    
 	    if(res.status == 200) {
-	    	var obj=sling.evalString(res.responseText);
+	    	var obj=Sling.evalString(res.responseText);
 			if (!filter) {
 				for (var a in obj) {
 					if (a.indexOf("jcr:")==0) delete(obj[a]);
@@ -174,11 +174,11 @@
 	}
 	
 	/** Remove content by path */
-	sling.removeContent = function(path) {
-		var httpcon = sling.getXHR();
+	Sling.removeContent = function(path) {
+		var httpcon = Sling.getXHR();
 		if (httpcon) {
 			var params = "sling:post:delete="+path;
-			httpcon.open('POST', sling.baseurl + path, false);
+			httpcon.open('POST', Sling.baseurl + path, false);
 
 			// Send the proper header information along with the request
 			httpcon.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
@@ -192,7 +192,7 @@
 	}
 	
 	/** eval str, accepting various object delimiters */
-	sling.evalString = function(str) {
+	Sling.evalString = function(str) {
 		var obj = null;
 	    if(str.indexOf('[')==0) {
 		    eval("obj="+str);
@@ -209,16 +209,16 @@
 	 * @return An Object tree containing the session information, null if server status <>
200
 	 * @type Object
 	 */
-	sling.getSessionInfo = function() {
-	    var res=sling.httpGet(sling.baseurl+"/sling.sessionInfo.json");
+	Sling.getSessionInfo = function() {
+	    var res=Sling.httpGet(Sling.baseurl+"/system/sling/info.sessionInfo.json");
 	    if(res.status == 200) {
-	    	return sling.evalString(res.responseText);
+	    	return Sling.evalString(res.responseText);
 	    }
 	    return null;
 	}
 	
 	/** Replace extension in a path */
-	sling._replaceExtension = function(path,newExtension) {
+	Sling._replaceExtension = function(path,newExtension) {
 		var i = path.lastIndexOf(".");
 		if(i >= 0) path = path.substring(0,i);
 		i = path.lastIndexOf(".");
@@ -229,17 +229,17 @@
 	/** Get the JSON data URL that for the current page
 	 *	(assuming a .extension for the current page, .html or something else)	
 	 */
-	sling._getJsonUrl = function() {
-	  return sling._replaceExtension(window.location.href,".json");
+	Sling._getJsonUrl = function() {
+	  return Sling._replaceExtension(window.location.href,".json");
 	}
 	
 	/** Get the content repository path from the URL
 	 *	(assuming a .extension for the current page, .html or something else)
 	 */
-	sling._getPath = function() {
+	Sling._getPath = function() {
 	
-	    var noextensions=sling._replaceExtension(window.location.href,"");
-	    var path=noextensions.substring(sling.baseurl.length);
+	    var noextensions=Sling._replaceExtension(window.location.href,"");
+	    var path=noextensions.substring(Sling.baseurl.length);
 	    return (path);
 	}
 	
@@ -247,15 +247,15 @@
 	 *	with an id like ./stuff, has its innerHTML set to the value of stuff
 	 *	in the tree, if it exists.
 	 */
-	sling.displayValues = function(container,tree) {
+	Sling.displayValues = function(container,tree) {
 	  if(!tree) {
-	    tree = sling.getContent(sling._getJsonUrl(),1);
+	    tree = Sling.getContent(Sling._getJsonUrl(),1);
 	  }
 	  
 	  var elements = container.getElementsByTagName("*"); 
 	  var toSet = new Array();
 	  for (var i = 0; i < elements.length; i++) { 
-	    var value = sling._getElementValue(elements[i],tree);
+	    var value = Sling._getElementValue(elements[i],tree);
 	    if(value) {
 	      toSet[toSet.length] = { e:elements[i], v:value };
 	    }
@@ -267,7 +267,7 @@
 	}
 	
 	/** If e has an ID that matches a property of tree, set e's innerHTML accordingly */
-	sling._getElementValue = function(e,tree) {
+	Sling._getElementValue = function(e,tree) {
 	  var id = e.getAttribute("id");
 	  if(id) {
 	    return tree[id.substring(2)];
@@ -284,7 +284,7 @@
 	 * Returns an object indicating whether data was found on the server.
 	 *
 	 */
-	sling._setFormValues = function(form, path, tree) {
+	Sling._setFormValues = function(form, path, tree) {
 		var result = new Object();
 		
 	    /** TODO: deal with abolute paths?
@@ -295,7 +295,7 @@
 	    form.setAttribute("action", path);
 	
 	    if (!tree) {
-			tree=sling.getContent(path,1);
+			tree=Sling.getContent(path,1);
 	    }
 	
 	    var elems=form.elements;
@@ -320,7 +320,7 @@
 			if (a.indexOf("/")==0) {
 				var nodepath=a.substring(0,a.lastIndexOf("/"));
 				var propname=a.substring(a.lastIndexOf("/")+1);
-				var node=sling.getContent(nodepath);
+				var node=Sling.getContent(nodepath);
 				var propval=node[propname];
 			} else if (a.indexOf(formfieldprefix)==0) {
 	            var propname=a.substring(formfieldprefix.length);
@@ -356,7 +356,7 @@
 	 *  @return The Path parameter isolated from the URL
 	 *  @type String
 	 */
-	sling.TODO_NOT_USED_isolatePathFromUrl = function(url) {
+	Sling.TODO_NOT_USED_isolatePathFromUrl = function(url) {
 	  var pattern = "[\\?&]Path=([^&#]*)";
 	  var regex = new RegExp( pattern );
 	  var results = regex.exec( url );
@@ -372,7 +372,7 @@
 	 *	Get an XMLHttpRequest in a portable way
 	 *		
 	 */
-	sling.getXHR = function () {
+	Sling.getXHR = function () {
 		var xhr=null;
 		
 		if(!xhr) {
@@ -412,9 +412,9 @@
 	// obtain the base_url to communicate with sling on the server
 	var scripts = document.getElementsByTagName("SCRIPT")
 	var script = scripts[scripts.length-1].src
-	sling.baseurl = script.substring(0,script.length - ("/" + sling.NAME_OF_THIS_FILE.length));
-	sling.currentPath = sling._getPath();
-	sling.isNew  = (sling.currentPath.indexOf("/*")>=0)?true:false;
+	Sling.baseurl = script.substring(0,script.length - ("/" + Sling.NAME_OF_THIS_FILE.length));
+	Sling.currentPath = Sling._getPath();
+	Sling.isNew  = (Sling.currentPath.indexOf("/*")>=0)?true:false;
 
 // end sling code scope	
 })();



Mime
View raw message