Author: rbaxter85
Date: Mon Aug 15 16:03:10 2011
New Revision: 1157899
URL: http://svn.apache.org/viewvc?rev=1157899&view=rev
Log:
SHINDIG-1572
Committed For Matt Hatem
Fix to support for VIEW and VIEW_TARGET in actions feature
Added:
shindig/trunk/features/src/main/javascript/features/actions/constants.js
Modified:
shindig/trunk/content/samplecontainer/examples/conservcontainer/ConServContainer.js
shindig/trunk/features/src/main/javascript/features/actions/actions_container.js
shindig/trunk/features/src/main/javascript/features/actions/feature.xml
Modified:
shindig/trunk/content/samplecontainer/examples/conservcontainer/ConServContainer.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/conservcontainer/ConServContainer.js?rev=1157899&r1=1157898&r2=1157899&view=diff
==============================================================================
---
shindig/trunk/content/samplecontainer/examples/conservcontainer/ConServContainer.js
(original)
+++
shindig/trunk/content/samplecontainer/examples/conservcontainer/ConServContainer.js
Mon Aug 15 16:03:10 2011
@@ -1,6 +1,11 @@
// Create the common container object.
var CommonContainer = new osapi.container.Container({});
+// Default the security token for the container. Using this example security
+// token requires enabling the DefaultSecurityTokenCodec to let
+// UrlParameterAuthenticationHandler create valid security token.
+shindig.auth.updateSecurityToken('john.doe:john.doe:appid:cont:url:0:default');
+
// Wrapper function to set the gadget site/id and default width.
CommonContainer.renderGadget = function(gadgetURL, gadgetId) {
// going to hardcode these values for width.
@@ -15,7 +20,7 @@ CommonContainer.renderGadget = function(
// Function for pre-rendering gadgets. Gadget pre-rendering
// occurs when an action contributed by a pre-loaded gadget
// is executed.
-function preRenderGadget(gadgetUrl, opt_metadata) {
+function preRenderGadget(gadgetUrl, opt_params) {
var gadgetId = getGadgetId(gadgetUrl);
var el = $('#gadget-site-' + gadgetId);
var gadgetSite = CommonContainer.renderGadget(gadgetUrl, gadgetId);
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=1157899&r1=1157898&r2=1157899&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
Mon Aug 15 16:03:10 2011
@@ -43,9 +43,6 @@
// one-to-many association of urls to gadget sites
this.urlToSite = {};
- // one-to-one relationship of each url to the gadget metadata
- this.urlToMetadata = {};
-
// one-to-one relationship of each action to the url
this.actionToUrl = {};
@@ -297,29 +294,6 @@
this.getUrl = function(actionId) {
return this.actionToUrl[actionId];
};
-
- /**
- * Saves the metadata associated with a url
- *
- * @param {String}
- * url Gadget spec url.
- * @param {Object}
- * metadata Metadata of the gadget.
- */
- this.setGadgetMetadata = function(url, metadata) {
- this.urlToMetadata[url] = metadata;
- };
-
- /**
- * Returns the metadata associated with a url
- *
- * @param {String}
- * url Gadget spec url.
- * @return {Object} metadata Metadata for a gadget.
- */
- this.getGadgetMetadata = function(url) {
- return this.urlToMetadata[url];
- };
};
/**
@@ -451,7 +425,6 @@
for (var url in response) {
var metadata = response[url];
if (!metadata.error) {
- registry.setGadgetMetadata(url, metadata);
if (metadata.modulePrefs) {
var feature = metadata.modulePrefs.features['actions'];
if (feature && feature.params) {
@@ -581,9 +554,9 @@
* @param {String}
* gadgetSpecUrl The gadget spec url.
* @param {Object}
- * gadgetMetadata The gadget meta data.
+ * opt_params The optional parameters for rendering the gadget.
*/
- var renderGadgetInContainer = function(gadgetSpecUrl, gadgetMetadata) {};
+ var renderGadgetInContainer = function(gadgetSpecUrl, opt_params) {};
// instantiate the singleton action registry
var registry = new ActionRegistry();
@@ -608,7 +581,6 @@
}
return /** @scope osapi.container.actions */ {
-
/**
* Registers a function to display actions in the container.
*
@@ -643,7 +615,7 @@
* @param {function}
* The container's function to render gadgets in its UI.
* The function takes in two parameters: the gadget spec
- * url and the gadget metadata.
+ * url and optional parameters.
*/
registerNavigateGadgetHandler: function(renderGadgetFunction) {
if (typeof renderGadgetFunction === 'function') {
@@ -664,17 +636,24 @@
* The action id.
*/
runAction: function(actionId) {
- if (registry.getItemById(actionId)) {
+ var action = registry.getItemById(actionId);
+ if (action) {
// if gadget site has not been registered yet
// the gadget needs to be rendered
var gadgetSite = registry.getGadgetSite(actionId);
if (!gadgetSite) {
var gadgetUrl = registry.getUrl(actionId);
- var gadgetMetadata = registry.getGadgetMetadata(gadgetUrl);
pendingActions[actionId] = {
selection: container_.selection.getSelection()
};
- renderGadgetInContainer(gadgetUrl, gadgetMetadata);
+ var opt_params = {};
+ if (action.view) {
+ opt_params[osapi.container.actions.OptParam.VIEW] = action.view;
+ }
+ if (action.viewTarget) {
+ opt_params[osapi.container.actions.OptParam.VIEW_TARGET] =
action.viewTarget;
+ }
+ renderGadgetInContainer(gadgetUrl, opt_params);
} else {
runAction(actionId);
}
Added: shindig/trunk/features/src/main/javascript/features/actions/constants.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/actions/constants.js?rev=1157899&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/actions/constants.js
(added)
+++ shindig/trunk/features/src/main/javascript/features/actions/constants.js
Mon Aug 15 16:03:10 2011
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+/**
+ * @fileoverview Constants used throughout the container classes for
+ * actions.
+ */
+
+/**
+ * Actions namespace
+ * @type {Object}
+ */
+osapi.container.actions = {};
+
+/**
+ * Optional params for actions.
+ * @enum {string}
+ */
+osapi.container.actions.OptParam = {};
+osapi.container.actions.OptParam.VIEW = 'view';
+osapi.container.actions.OptParam.VIEW_TARGET = 'viewTarget';
Modified:
shindig/trunk/features/src/main/javascript/features/actions/feature.xml
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/actions/feature.xml?rev=1157899&r1=1157898&r2=1157899&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/actions/feature.xml
(original)
+++ shindig/trunk/features/src/main/javascript/features/actions/feature.xml Mon
Aug 15 16:03:10 2011
@@ -12,9 +12,12 @@
<exports type="js">gadgets.actions.removeAction</exports>
<exports type="js">gadgets.actions.getActionsByPath</exports>
<exports type="js">gadgets.actions.getActionsByDataType</exports>
+ <exports type="js">osapi.container.actions.OptParam.VIEW</exports>
+ <exports type="js">osapi.container.actions.OptParam.VIEW_TARGET</exports>
</api>
</gadget>
<container>
+ <script src="constants.js"/>
<script src="actions_container.js"/>
</container>
</feature>
\ No newline at end of file