[isidorus-cvs] r315 - in branches/new-datamodel: playground src/ajax/javascripts src/rest_interface src/unit_tests

Lukas Giessmann lgiessmann at common-lisp.net
Tue Sep 7 10:50:53 UTC 2010


Author: lgiessmann
Date: Tue Sep  7 06:50:53 2010
New Revision: 315

Log:
The ajax host prefix in constants.js is set automatically --> different mappings works for the same server now; the admin needn't set the host prefix manually

Added:
   branches/new-datamodel/playground/url_test.html
   branches/new-datamodel/playground/url_test.js
Modified:
   branches/new-datamodel/src/ajax/javascripts/constants.js
   branches/new-datamodel/src/rest_interface/set-up-json-interface.lisp
   branches/new-datamodel/src/unit_tests/atom_test.lisp

Added: branches/new-datamodel/playground/url_test.html
==============================================================================
--- (empty file)
+++ branches/new-datamodel/playground/url_test.html	Tue Sep  7 06:50:53 2010
@@ -0,0 +1,48 @@
+<!-- ======================================================================= -->
+<!--  Isidorus                                                               -->
+<!--  (c) 2008-2009 Marc Kuester, Christoph Ludwig, Lukas Giessmann          -->
+<!--                                                                         -->
+<!--  Isidorus is freely distributable under the LGPL license.               -->
+<!--  This ajax module uses the frameworks PrototypeJs and Scriptaculous,    -->
+<!--  both are distributed under the MIT license.                            -->
+<!--  You can find a detailed description in trunk/docs/LGPL-LICENSE.txt and -->
+<!--  in trunk/src/ajax/javascripts/external/MIT-LICENSE.txt.                -->
+<!-- ======================================================================= -->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <title>isidorus</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+
+    <!-- error handling for javascript code -->
+    <script language="JavaScript" type="text/javascript"> <!--
+    var __DEBUG__ = true;
+	
+    function onError(message, url, line)
+    {
+	window.alert("onError in \"" + url + "\" at line: "  + line + "\n" + message);
+	return true;
+    }
+
+    if(__DEBUG__ === true){
+	window.onerror = onError;
+    }
+
+    // -->
+    </script>
+
+    
+    <!-- includes the prototype and scriptaculous frameworks -->
+
+    <!-- includes own javascript files -->
+    <script language="JavaScript" type="text/javascript" src="url_test.js"></script>
+  </head>
+
+  <body onload="entryPoint()">
+    <div id="page">
+      <h1>URL:<span id="content"></span></h1>
+    </div>
+  </body>
+</html>

Added: branches/new-datamodel/playground/url_test.js
==============================================================================
--- (empty file)
+++ branches/new-datamodel/playground/url_test.js	Tue Sep  7 06:50:53 2010
@@ -0,0 +1,16 @@
+function entryPoint(){
+    var elem = getElem();
+    var url = window.location.href;
+    var urlFrags = url.split("/");
+    var newUrl = "";
+    for(var i = 0; i !== urlFrags.length; ++i){
+	if (newUrl.length !== 0) newUrl += "/";
+	newUrl += urlFrags[i];
+    }
+    elem.innerHTML = " " + newUrl;
+}
+
+
+function getElem(){
+    return document.getElementById("content");
+}
\ No newline at end of file

Modified: branches/new-datamodel/src/ajax/javascripts/constants.js
==============================================================================
--- branches/new-datamodel/src/ajax/javascripts/constants.js	(original)
+++ branches/new-datamodel/src/ajax/javascripts/constants.js	Tue Sep  7 06:50:53 2010
@@ -11,7 +11,7 @@
 
 
 // --- Some constants fot the http connections via the XMLHttpRequest-Object
-var HOST_PREF = "http://localhost:8000/"; // of the form "http://(.+)/"
+var HOST_PREF = getHostPref();
 var GET_PREFIX = HOST_PREF + "json/get/";
 var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
 var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
@@ -90,4 +90,20 @@
 	       "instances" : function(){ return "instances"; },
 	       "subtypes" : function(){ return "subtypes"; },
 	       "topicPsis" : function(){ return "topicPsis"; }
-	      };
\ No newline at end of file
+	      };
+
+
+// --- returns the current host prefix as string, so the user/admin needn't
+// --- setting it manually
+function getHostPref(){
+    var splitter = "/";
+    var splitterRate = 3;
+    var fullUrl = window.location.href;
+    var urlFragments = fullUrl.split("/");
+    var hostPref = "";
+    for(var i = 0; i !== splitterRate; ++i){
+	hostPref += urlFragments[i];
+	hostPref += "/";
+    }
+    return hostPref;
+}
\ No newline at end of file

Modified: branches/new-datamodel/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- branches/new-datamodel/src/rest_interface/set-up-json-interface.lisp	(original)
+++ branches/new-datamodel/src/rest_interface/set-up-json-interface.lisp	Tue Sep  7 06:50:53 2010
@@ -133,6 +133,7 @@
 		       (setf (hunchentoot:content-type*) "text")
 		       (format nil "Condition: \"~a\"" err)))))
 
+
 (defun return-all-tmcl-instances(&optional param)
   "Returns all topic-psis that are valid instances of any topic type.
    The validity is only oriented on the typing of topics, e.g.

Modified: branches/new-datamodel/src/unit_tests/atom_test.lisp
==============================================================================
--- branches/new-datamodel/src/unit_tests/atom_test.lisp	(original)
+++ branches/new-datamodel/src/unit_tests/atom_test.lisp	Tue Sep  7 06:50:53 2010
@@ -103,9 +103,13 @@
               (find 'atom::snapshots-feed
                     (atom:subfeeds worms-feed)
                     :key #'type-of)))
+	  
+	  (format t "~a~%~%~a~%" fragments-feed (map 'list #'atom::psi (atom:entries fragments-feed)))
           (is (= 11 (length (atom:entries fragments-feed))))
-          (is (string= "http://london.ztt.fh-worms.de:8000/feeds/worms/fragments" (link fragments-feed)))
-          (is (string= "http://london.ztt.fh-worms.de:8000/feeds/worms/snapshots" (link snapshots-feed)))
+          (is (string= "http://london.ztt.fh-worms.de:8000/feeds/worms/fragments"
+		       (link fragments-feed)))
+          (is (string= "http://london.ztt.fh-worms.de:8000/feeds/worms/snapshots"
+		       (link snapshots-feed)))
 
           (format t "~a" (cxml:with-xml-output 
                              (cxml:make-string-sink :canonical t)




More information about the Isidorus-cvs mailing list