You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/05/08 01:46:10 UTC

svn commit: r654329 - /incubator/shindig/trunk/features/core.io/io.js

Author: chabotc
Date: Wed May  7 16:46:09 2008
New Revision: 654329

URL: http://svn.apache.org/viewvc?rev=654329&view=rev
Log:
Adding ContentType.FEED support - core.io patch

Modified:
    incubator/shindig/trunk/features/core.io/io.js

Modified: incubator/shindig/trunk/features/core.io/io.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/core.io/io.js?rev=654329&r1=654328&r2=654329&view=diff
==============================================================================
--- incubator/shindig/trunk/features/core.io/io.js (original)
+++ incubator/shindig/trunk/features/core.io/io.js Wed May  7 16:46:09 2008
@@ -131,43 +131,50 @@
      approvalUrl: data.approvalUrl,
      errors: []
     };
-
-    if (resp.text) {
-      switch (params.CONTENT_TYPE) {
-        case "JSON":
-        case "FEED":
-          resp.data = gadgets.json.parse(resp.text);
-          if (!resp.data) {
-            resp.errors.push("failed to parse JSON");
-            resp.data = null;
+    switch (params.CONTENT_TYPE) {
+      case "JSON":
+        // Same as before, but specific to JSON (not FEED)
+        resp.data = gadgets.json.parse(resp.text);
+        if (!resp.data) {
+          resp.errors.push("failed to parse JSON");
+          resp.data = null;
+        }
+        break;
+      case "FEED":
+        if (!data.body) {
+          resp.errors.push("failed to parse JSON");
+          resp.data = null;
+        }
+        else {
+          // Straight into the Feed object - override usual resp structure
+          resp = data.body;
+        }
+        break;
+      case "DOM":
+        var dom;
+        if (window.ActiveXObject) {
+          dom = new ActiveXObject("Microsoft.XMLDOM");
+          dom.async = false;
+          dom.validateOnParse = false;
+          dom.resolveExternals = false;
+          if (!dom.loadXML(resp.text)) {
+            resp.errors.push("failed to parse XML");
+          } else {
+            resp.data = dom;
           }
-          break;
-        case "DOM":
-          var dom;
-          if (window.ActiveXObject) {
-            dom = new ActiveXObject("Microsoft.XMLDOM");
-            dom.async = false;
-            dom.validateOnParse = false;
-            dom.resolveExternals = false;
-            if (!dom.loadXML(resp.text)) {
-              resp.errors.push("failed to parse XML");
-            } else {
-              resp.data = dom;
-            }
+        } else {
+          var parser = new DOMParser();
+          dom = parser.parseFromString(resp.text, "text/xml");
+          if ("parsererror" === dom.documentElement.nodeName) {
+            resp.errors.push("failed to parse XML");
           } else {
-            var parser = new DOMParser();
-            dom = parser.parseFromString(resp.text, "text/xml");
-            if ("parsererror" === dom.documentElement.nodeName) {
-              resp.errors.push("failed to parse XML");
-            } else {
-              resp.data = dom;
-            }
+            resp.data = dom;
           }
-          break;
-        default:
-          resp.data = resp.text;
-          break;
-      }
+        }
+        break;
+      default:
+        resp.data = resp.text;
+        break;
     }
 
     return resp;
@@ -306,6 +313,9 @@
         oauthState : reqState || "",
         oauthService : oauthService || "",
         oauthToken : oauthToken || "",
+        contentType : params.CONTENT_TYPE || "TEXT",
+        numEntries : params.NUM_ENTRIES || "3",
+        getSummaries : !!params.GET_SUMMARIES,
         signOwner : signOwner || "true",
         signViewer : signViewer || "true"
       };



Re: svn commit: r654329 - /incubator/shindig/trunk/features/core.io/io.js

Posted by Gary Helmling <gh...@gmail.com>.
Yes, that's correct.


On Thu, May 8, 2008 at 9:41 AM, Chris Chabot <ch...@xs4all.nl> wrote:
> Ok just to make sure this would mean:
>
>  Index: io.js
>  ===================================================================
>  --- io.js       (revision 654521)
>  +++ io.js       (working copy)
>  @@ -144,11 +144,9 @@
>
>          if (!data.body) {
>            resp.errors.push("failed to parse JSON");
>            resp.data = null;
>  +        } else {
>  +          resp.data = data.body;
>
>          }
>  -        else {
>  -          // Straight into the Feed object - override usual resp structure
>  -          resp = data.body;
>  -        }
>          break;
>        case "DOM":
>          var dom;
>
>  Right?
>
>  If you can confirm i'll go ahead and commit it.
>
>         -- Chris
>
>
>
>  On May 8, 2008, at 3:33 PM, Gary Helmling wrote:
>
>
> > This section will break consistency in the response object returned by
> > gadgets.io.makeRequest(), and should be replaced with:
> >
> > } else {
> >  resp.data = data.body;
> > }
> >
> >
>
>

Re: svn commit: r654329 - /incubator/shindig/trunk/features/core.io/io.js

Posted by Chris Chabot <ch...@xs4all.nl>.
Ok just to make sure this would mean:

Index: io.js
===================================================================
--- io.js       (revision 654521)
+++ io.js       (working copy)
@@ -144,11 +144,9 @@
          if (!data.body) {
            resp.errors.push("failed to parse JSON");
            resp.data = null;
+        } else {
+          resp.data = data.body;
          }
-        else {
-          // Straight into the Feed object - override usual resp  
structure
-          resp = data.body;
-        }
          break;
        case "DOM":
          var dom;

Right?

If you can confirm i'll go ahead and commit it.

	-- Chris

On May 8, 2008, at 3:33 PM, Gary Helmling wrote:

> This section will break consistency in the response object returned by
> gadgets.io.makeRequest(), and should be replaced with:
>
> } else {
>  resp.data = data.body;
> }
>


Re: svn commit: r654329 - /incubator/shindig/trunk/features/core.io/io.js

Posted by Gary Helmling <gh...@gmail.com>.
On Wed, May 7, 2008 at 7:46 PM,  <ch...@apache.org> wrote:
> Author: chabotc
>  Date: Wed May  7 16:46:09 2008
>  New Revision: 654329
>
>  URL: http://svn.apache.org/viewvc?rev=654329&view=rev
>  Log:
>  Adding ContentType.FEED support - core.io patch
>
>  Modified:
>     incubator/shindig/trunk/features/core.io/io.js
>
...
>  +      case "FEED":
>  +        if (!data.body) {
>  +          resp.errors.push("failed to parse JSON");
>  +          resp.data = null;
>  +        }
>  +        else {
>  +          // Straight into the Feed object - override usual resp structure
>  +          resp = data.body;
>  +        }

This section will break consistency in the response object returned by
gadgets.io.makeRequest(), and should be replaced with:

} else {
  resp.data = data.body;
}


The applied io.js.patch file is from the first implementation of
SHINDIG-60, which I later updated (latest is
fix-SHINDIG-60-bug_rome2.patch, which patches io.js, ProxyHandler.java
and java/gadgets/pom.xml).

I believe the reason for this handling in the original patch was for
backwards compatibility with existing Google Gadgets, but I
implemented the compatibility layer separately in
fix-SHINDIG-60_legacy.patch -- which modifies just the
_IG_FetchFetchAsJSON() wrapper).