You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by hs...@apache.org on 2012/04/04 19:36:02 UTC
svn commit: r1309498 - in /shindig/trunk:
content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml
features/src/main/javascript/features/actions/actions_container.js
Author: hsaputra
Date: Wed Apr 4 17:36:02 2012
New Revision: 1309498
URL: http://svn.apache.org/viewvc?rev=1309498&view=rev
Log:
Fix the actions-contributions feature param by wrapping it with <actions> tag to avoid DOM parser error to follow OpenSocial 2.0 specs. CR: https://reviews.apache.org/r/4626/
Modified:
shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml
shindig/trunk/features/src/main/javascript/features/actions/actions_container.js
Modified: shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml?rev=1309498&r1=1309497&r2=1309498&view=diff
==============================================================================
--- shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml (original)
+++ shindig/trunk/content/samplecontainer/examples/conservcontainer/sample-actions-voip.xml Wed Apr 4 17:36:02 2012
@@ -23,11 +23,9 @@
<Require feature="open-views"/>
<Require feature="actions">
<Param name="action-contributions"><![CDATA[
- <actions>
- <action id="org-samplevoip-chatwithperson" dataType="opensocial.Person" label="Chat" tooltip="Chat" />
- <action id="org-samplevoip-callbyperson" dataType="opensocial.Person" label="Call" tooltip="Call" />
- <action id="org-samplevoip-globalcall" path="container/navigationLinks" label="VOIP Call" tooltip="Call using VOIP" />
- </actions>
+ <action id="org-samplevoip-chatwithperson" dataType="opensocial.Person" label="Chat" tooltip="Chat" />
+ <action id="org-samplevoip-callbyperson" dataType="opensocial.Person" label="Call" tooltip="Call" />
+ <action id="org-samplevoip-globalcall" path="container/navigationLinks" label="VOIP Call" tooltip="Call using VOIP" />
]]></Param>
</Require>
<Optional feature="settitle"/>
Modified: shindig/trunk/features/src/main/javascript/features/actions/actions_container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/actions/actions_container.js?rev=1309498&r1=1309497&r2=1309498&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/actions/actions_container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/actions/actions_container.js Wed Apr 4 17:36:02 2012
@@ -337,17 +337,17 @@
dom.validateOnParse = false;
dom.resolveExternals = false;
if (!dom.loadXML(xmlString)) {
- response['errors'].push('500 Failed to parse XML');
- response['rc'] = 500;
+ response.errors = "500 Failed to parse XML";
+ response.rc = 500;
} else {
response['data'] = dom;
}
} else {
var parser = new DOMParser();
- dom = parser.parseFromString(xmlString, 'text/xml');
+ dom = parser.parseFromString(xmlString, 'application/xml');
if ('parsererror' === dom.documentElement.nodeName) {
- response['errors'].push('500 Failed to parse XML');
- response['rc'] = 500;
+ response.errors = "500 Failed to parse XML";
+ response.rc = 500;
} else {
response['data'] = dom;
}
@@ -500,6 +500,31 @@
};
/**
+ * Fix list of actions from actions contributions to check if it has been wrapped with <actions>
+ * tag to avoid DOM parser error.
+ *
+ * @param {string} actionsContributionsParam the string containing the action tags
+ * @return {string} the corrected actions list wrapped with <actions> tag to avoid DOM parser error.
+ */
+ function fixActionContributions(actionsContributionsParam) {
+ var actions = actionsContributionsParam;
+ if(typeof actions !== 'string') {
+ actions = actions.toString();
+ }
+
+ // cleanup the newlines and extra spaces
+ actions = actions.replace(/\n/g, '');
+ actions = actions.replace(/\s+</g, '<');
+ actions = actions.replace(/>\s+/g, '>');
+
+ // check if actions content is wrapped with <actions> tag
+ if (actions.indexOf("<actions>") === -1) {
+ actions = "<actions>" + actions + "</actions>";
+ }
+ return actions;
+ };
+
+ /**
* Callback for loading actions after gadget has been preloaded.
*
* @param {Object}
@@ -522,8 +547,12 @@
continue; // bail
}
+ // fix action-contributions param until OpenSocial specs change is implemented:
+ // http://code.google.com/p/opensocial-resources/issues/detail?id=1264
+ desc = fixActionContributions(desc);
+
var domResponse = createDom(desc);
- if (!domResponse || domResponse['errors']) {
+ if (!domResponse || domResponse.errors) {
continue; // bail
}