Author: evan
Date: Thu Jan 29 22:09:10 2009
New Revision: 739044
URL: http://svn.apache.org/viewvc?rev=739044&view=rev
Log:
Patch for SHINDIG-861
NameSpace registration happens automatically if @tag="ns:Tag" is defined for
unknown namespace prefix (the URL can be supplied later)
OST now depends on opensocial-0.8 feature
Modified:
incubator/shindig/trunk/features/opensocial-templates/container.js
incubator/shindig/trunk/features/opensocial-templates/data.js
incubator/shindig/trunk/features/opensocial-templates/feature.xml
incubator/shindig/trunk/features/opensocial-templates/namespaces.js
Modified: incubator/shindig/trunk/features/opensocial-templates/container.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/container.js?rev=739044&r1=739043&r2=739044&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/container.js
(original)
+++ incubator/shindig/trunk/features/opensocial-templates/container.js Thu Jan
29 22:09:10 2009
@@ -360,10 +360,10 @@
if (template) {
var tagParts = name.split(':');
var nsObj = os.getNamespace(tagParts[0]);
- if (nsObj) {
- nsObj[tagParts[1]] = os.createTemplateCustomTag(template);
- } else {
- os.warn('Namespace ' + tagParts[0] + ' is not registered.');
+ if (!nsObj) {
+ // Auto Create a namespace for lazy registration.
+ nsObj = os.createNamespace(tagParts[0], null);
}
+ nsObj[tagParts[1]] = os.createTemplateCustomTag(template);
}
};
Modified: incubator/shindig/trunk/features/opensocial-templates/data.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/data.js?rev=739044&r1=739043&r2=739044&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/data.js (original)
+++ incubator/shindig/trunk/features/opensocial-templates/data.js Thu Jan 29
22:09:10 2009
@@ -612,7 +612,7 @@
* Pre-populate a Data Set based on application's URL parameters.
*/
(os.data.populateParams_ = function() {
- if (gadgets.util.hasFeature("views")) {
+ if (window["gadgets"] && gadgets.util.hasFeature("views")) {
os.data.DataContext.putDataSet("ViewParams", gadgets.views.getParams());
}
})();
\ No newline at end of file
Modified: incubator/shindig/trunk/features/opensocial-templates/feature.xml
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/feature.xml?rev=739044&r1=739043&r2=739044&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/feature.xml (original)
+++ incubator/shindig/trunk/features/opensocial-templates/feature.xml Thu Jan
29 22:09:10 2009
@@ -31,6 +31,7 @@
-->
<feature>
<name>opensocial-templates</name>
+ <dependency>opensocial-0.8</dependency>
<gadget>
<script
src="http://google-jstemplate.googlecode.com/svn/trunk/util.js"></script>
<script
src="http://google-jstemplate.googlecode.com/svn/trunk/jsevalcontext.js"></script>
Modified: incubator/shindig/trunk/features/opensocial-templates/namespaces.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-templates/namespaces.js?rev=739044&r1=739043&r2=739044&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-templates/namespaces.js
(original)
+++ incubator/shindig/trunk/features/opensocial-templates/namespaces.js Thu Jan
29 22:09:10 2009
@@ -65,6 +65,9 @@
tags = {};
os.nsmap_[ns] = tags;
os.nsurls_[ns] = url;
+ } else if (os.nsurls_[ns] == null ) {
+ // Lazily register an auto-created namespace.
+ os.nsurls_[ns] = url;
} else if (os.nsurls_[ns] != url) {
throw("Namespace " + ns + " already defined with url " + os.nsurls_[ns]);
}
@@ -78,9 +81,15 @@
return os.nsmap_[prefix];
};
-os.addNamespace = function(ns, url, nsObj) {
+os.addNamespace = function(ns, url, nsObj) {
if (os.nsmap_[ns]) {
- throw ("Namespace '" + ns + "' already exists!");
+ if (os.nsurls_[ns] == null) {
+ // Lazily register an auto-created namespace.
+ os.nsurls_[ns] = url;
+ return;
+ } else {
+ throw ("Namespace '" + ns + "' already exists!");
+ }
}
os.nsmap_[ns] = nsObj;
os.nsurls_[ns] = url;