You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by do...@apache.org on 2008/01/30 03:15:05 UTC
svn commit: r616591 - /incubator/shindig/trunk/javascript/opensocial6to7.js
Author: doll
Date: Tue Jan 29 18:15:04 2008
New Revision: 616591
URL: http://svn.apache.org/viewvc?rev=616591&view=rev
Log:
Added a first stab at a file which allows gadgets built using 0.6 to run in 0.7 containers. I do not have a good environment for testing this code because I do not have a fully working 0.7 container anywhere. Hopefully someone who does have a 0.7 container can help me find the bugs in this file and we can iterate on it together.
The idea for shindig would be to include an opensocial-0.7 feature which provides the latest container apis and an opensocial-0.6 feature which depends on 0.7 and includes this magic translation file. Once we verify the code I have written (and we make the opensocial-0.7 feature) we can proceed with that change and fix the jira issue that was filed)
(We can also version the sample container if people want that.)
Added:
incubator/shindig/trunk/javascript/opensocial6to7.js
Added: incubator/shindig/trunk/javascript/opensocial6to7.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial6to7.js?rev=616591&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial6to7.js (added)
+++ incubator/shindig/trunk/javascript/opensocial6to7.js Tue Jan 29 18:15:04 2008
@@ -0,0 +1,85 @@
+// If a gadget was written for the opensocial 0.6 apis and it wants to run in a
+// container that only supports 0.7, including this file should allow the gadget
+// to run without making any changes.
+
+opensocial.requestNavigateTo = gadgets.views.requestNavigateTo;
+
+// If using enums, gadgets are ok.
+// TODO: Translate hardcoded string params to the new gadgets values
+opensocial.makeRequest = gadgets.io.makeRequest;
+
+opensocial.ContentRequestParameters = {
+ METHOD : gadgets.io.RequestParameters.METHOD,
+ CONTENT_TYPE : gadgets.io.RequestParameters.CONTENT_TYPE,
+ AUTHENTICATION : gadgets.io.RequestParameters.AUTHORIZATION,
+ NUM_ENTRIES : gadgets.io.RequestParameters.NUM_ENTRIES,
+ GET_SUMMARIES : gadgets.io.RequestParameters.GET_SUMMARIES
+};
+
+opensocial.ContentRequestParameters.MethodType = {
+ GET : gadgets.io.MethodType.GET,
+ POST : gadgets.io.MethodType.POST
+};
+
+opensocial.ContentRequestParameters.ContentType = {
+ HTML : gadgets.io.ContentType.TEXT,
+ XML : gadgets.io.ContentType.DOM,
+ FEED : gadgets.io.ContentType.JSON
+};
+
+opensocial.ContentRequestParameters.AuthenticationType = {
+ NONE : gadgets.io.AuthorizationType.NONE,
+ SIGNED : gadgets.io.AuthorizationType.SIGNED,
+ AUTHENTICATED : gadgets.io.AuthorizationType.AUTHENTICATED
+};
+
+opensocial.newActivityOld = opensocial.newActivity;
+opensocial.newActivity = function(title, opt_params) {
+ opt_params['title'] = title;
+ opensocial.newActivityOld(opt_params);
+};
+
+opensocial.DataRequest.prototype.newFetchGlobalAppDataRequest = function(keys) {
+ // This should be a no-op. This call never fetched anything relavant because
+ // you couldn't set any global app data.
+ // However, we don't want containers to crash, so we will just fetch person
+ // app data. This seems the best we can do for now.
+ return this.newFetchPersonAppDataRequest(keys);
+};
+
+opensocial.DataRequest.prototype.newFetchInstanceAppDataRequest =
+ function(keys) {
+ var moduleId = new gadgets.Prefs().getModuleId();
+ if (opensocial.Container.isArray(keys)) {
+ for (var i = 0; i < keys.length; i++) {
+ keys[i] = moduleId + keys[i];
+ }
+ } else {
+ keys = moduleId + keys;
+ }
+
+ return this.newFetchPersonAppDataRequest('OWNER', keys);
+};
+
+opensocial.DataRequest.prototype.newUpdateInstanceAppDataRequest = function(key,
+ value) {
+ var moduleId = new gadgets.Prefs().getModuleId();
+ return this.newUpdatePersonAppDataRequest('OWNER', moduleId + key);
+};
+
+// The surface object is gone, but the user never directly knew about the object
+// (ie they couldn't construct it) so we will just make the methods look the
+// same.
+gadgets.views.View.prototype.isPrimaryContent = function() {
+ return this.isOnlyVisibleGadget();
+}
+
+// Note: The names of views may have changed in a container between 0.6 and 0.7
+// but that is container specific
+
+opensocial.Environment.prototype.getSurface = gadgets.views.getCurrentView;
+opensocial.Environment.prototype.getSupportedSurfaces
+ = gadgets.views.getSupportedViews;
+opensocial.Environment.prototype.getParams = gadgets.views.getParams;
+
+opensocial.Environment.prototype.hasCapability = gadgets.util.hasFeature;