You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Martin Webb <ma...@gmail.com> on 2008/03/14 14:23:44 UTC

"parentRelayUrl" : "/gadgets/files/container/rpc_relay.html" from file based pages

I'm stuck - and its my lack of knowledge of how shindig's rpc relay is
supposed to work that is stumping me.

If I view http://localhost:8080/gadgets/files/container/sample2.html - then
the 2nd of the three sample widgets supports dynamicHeight perfectly.

If however I host just the sample2.html page from the file store (e.g.
file:///D:/workspace/shindig/javascript/container/sample2.html) *AND *change
all the references to point back to the gadget server then dynamicHeight
stops working.  What do I need to add to the following to get it to start
working again?

This is a small repeatable test case as I'm having problems with a container
separate from the gadget server.


<!DOCTYPE html>
<html>
<head>
<title>Sample: Dynamic Height</title>
<!-- default container look and feel -->
<link rel="stylesheet" href="
http://localhost:8080/gadgets/files/container/gadgets.css">
<script type="text/javascript" src="
http://localhost:8080/gadgets/js/rpc.js?c=1&debug=1"></script>
<script type="text/javascript" src="
http://localhost:8080/gadgets/files/container/cookies.js"></script>
<script type="text/javascript" src="
http://localhost:8080/gadgets/files/container/gadgets.js"></script>
<script type="text/javascript">
var my = {};

my.gadgetSpecUrls = [
  'http://www.google.com/ig/modules/horoscope.xml',
  'http://www.google.com/ig/modules/aue07otr.xml',
  'http://www.labpixies.com/campaigns/todo/todo.xml'
];


// This container lays out and renders gadgets itself.

my.LayoutManager = function() {
  gadgets.LayoutManager.call(this);
};

my.LayoutManager.inherits(gadgets.LayoutManager);

my.LayoutManager.prototype.getGadgetChrome = function(gadget) {
  var chromeId = 'gadget-chrome-' + gadget.id;
  return chromeId ? document.getElementById(chromeId) : null;
};

my.init = function() {
  gadgets.container.layoutManager = new my.LayoutManager();
  gadgets.container.setParentUrl('http://localhost:8080/');
};

my.renderGadgets = function() {
  for (var i = 0; i < my.gadgetSpecUrls.length; ++i) {
    var gadget = gadgets.container.createGadget(
        {specUrl: my.gadgetSpecUrls[i]});
    gadget.setServerBase('http://localhost:8080/gadgets/');

    gadgets.container.addGadget(gadget);
    gadgets.container.renderGadget(gadget);
  }
};
</script>
</head>
<body onLoad="my.init();my.renderGadgets()">
  <h2>Sample: Dynamic Height</h2>
  <div id="gadget-chrome-0" class="gadgets-gadget-chrome"></div>
  <div id="gadget-chrome-1" class="gadgets-gadget-chrome"></div>
  <div id="gadget-chrome-2" class="gadgets-gadget-chrome"></div>
</body>
</html>


Regards
Martin
-- 
Internet Related Technologies - http://www.irt.org

Re: Small patch for cache bug in latest version of GadgetSpecFetcher

Posted by Kevin Brown <et...@google.com>.
Thanks, I'll go ahead and apply this. I thought I had a test case covering
this but I guess I didn't.

On Fri, Mar 14, 2008 at 7:03 AM, Dan Lester <da...@danlester.com> wrote:

> OK, attachment was removed:
>
>
> Index: GadgetSpecFetcher.java
> ===================================================================
> --- GadgetSpecFetcher.java      (revision 637100)
> +++ GadgetSpecFetcher.java      (working copy)
> @@ -52,7 +52,7 @@
>   public GadgetSpec fetch(URI url, boolean forceReload) throws
> GadgetException {
>     GadgetSpec spec = null;
>     if (!forceReload) {
> -      cache.get(url);
> +      spec = cache.get(url);
>     }
>     if (spec == null) {
>       RemoteContentRequest request = new RemoteContentRequest(url);
>
>
> I said it was tiny!
>
> -----Original Message-----
> From: Dan Lester [mailto:dan@danlester.com]
> Sent: 14 March 2008 13:55
> To: shindig-dev@incubator.apache.org
> Subject: Small patch for cache bug in latest version of
> GadgetSpecFetcher
>
>
>
> I just noticed a problem where the latest GadgetSpecFetcher does not
> seem to load from cache. That's because it doesn't, due to a slight
> oversight:
>
> It was calling cache.get(url) without storing the return value anywhere,
> before checking (spec==null). The attatched one-liner patch just
> replaces it with spec = cache.get(url).
>
> Probably easier just to edit it manually, but I attached the patch for
> completeness.
>
> Thanks,
>
> Dan
>
>


-- 
~Kevin

RE: Small patch for cache bug in latest version of GadgetSpecFetcher

Posted by Dan Lester <da...@danlester.com>.
OK, attachment was removed:


Index: GadgetSpecFetcher.java
===================================================================
--- GadgetSpecFetcher.java	(revision 637100)
+++ GadgetSpecFetcher.java	(working copy)
@@ -52,7 +52,7 @@
   public GadgetSpec fetch(URI url, boolean forceReload) throws
GadgetException {
     GadgetSpec spec = null;
     if (!forceReload) {
-      cache.get(url);
+      spec = cache.get(url);
     }
     if (spec == null) {
       RemoteContentRequest request = new RemoteContentRequest(url);


I said it was tiny!

-----Original Message-----
From: Dan Lester [mailto:dan@danlester.com] 
Sent: 14 March 2008 13:55
To: shindig-dev@incubator.apache.org
Subject: Small patch for cache bug in latest version of
GadgetSpecFetcher



I just noticed a problem where the latest GadgetSpecFetcher does not
seem to load from cache. That's because it doesn't, due to a slight
oversight:

It was calling cache.get(url) without storing the return value anywhere,
before checking (spec==null). The attatched one-liner patch just
replaces it with spec = cache.get(url).

Probably easier just to edit it manually, but I attached the patch for
completeness.

Thanks,

Dan


Small patch for cache bug in latest version of GadgetSpecFetcher

Posted by Dan Lester <da...@danlester.com>.
I just noticed a problem where the latest GadgetSpecFetcher does not
seem to load from cache. That's because it doesn't, due to a slight
oversight:

It was calling cache.get(url) without storing the return value anywhere,
before checking (spec==null). The attatched one-liner patch just
replaces it with spec = cache.get(url).

Probably easier just to edit it manually, but I attached the patch for
completeness.

Thanks,

Dan

Re: "parentRelayUrl" : "/gadgets/files/container/rpc_relay.html" from file based pages

Posted by Cassie <do...@apache.org>.
I believe, but I am not positive, that it isn't working because it can't
find the rpc_relay.html file that needs to be hosted in a specific location.
It should be fairly easy to tell if this is the issue though if you have
firebug installed. Simply load the page, go to the "net" tab, clear all the
old entries, try to "refine the list" on gadget #2 and see what happens. It
should attempt to hit an rpc_relay.html file, if it can not find the file it
should show up in bright red.

If that isn't the right problem, using firebug will at least be a good place
to start to see if any of the other fetches throw errors. And I'm sure when
the west coast based people wake up they will be able to tell you for sure
if this is the problem. :)

- Cassie


On Fri, Mar 14, 2008 at 2:23 PM, Martin Webb <ma...@gmail.com>
wrote:

> I'm stuck - and its my lack of knowledge of how shindig's rpc relay is
> supposed to work that is stumping me.
>
> If I view http://localhost:8080/gadgets/files/container/sample2.html -
> then
> the 2nd of the three sample widgets supports dynamicHeight perfectly.
>
> If however I host just the sample2.html page from the file store (e.g.
> file:///D:/workspace/shindig/javascript/container/sample2.html) *AND
> *change
> all the references to point back to the gadget server then dynamicHeight
> stops working.  What do I need to add to the following to get it to start
> working again?
>
> This is a small repeatable test case as I'm having problems with a
> container
> separate from the gadget server.
>
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>Sample: Dynamic Height</title>
> <!-- default container look and feel -->
> <link rel="stylesheet" href="
> http://localhost:8080/gadgets/files/container/gadgets.css">
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/js/rpc.js?c=1&debug=1"></script>
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/files/container/cookies.js"></script>
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/files/container/gadgets.js"></script>
> <script type="text/javascript">
> var my = {};
>
> my.gadgetSpecUrls = [
>  'http://www.google.com/ig/modules/horoscope.xml',
>  'http://www.google.com/ig/modules/aue07otr.xml',
>  'http://www.labpixies.com/campaigns/todo/todo.xml'
> ];
>
>
> // This container lays out and renders gadgets itself.
>
> my.LayoutManager = function() {
>  gadgets.LayoutManager.call(this);
> };
>
> my.LayoutManager.inherits(gadgets.LayoutManager);
>
> my.LayoutManager.prototype.getGadgetChrome = function(gadget) {
>  var chromeId = 'gadget-chrome-' + gadget.id;
>  return chromeId ? document.getElementById(chromeId) : null;
> };
>
> my.init = function() {
>  gadgets.container.layoutManager = new my.LayoutManager();
>  gadgets.container.setParentUrl('http://localhost:8080/'<http://localhost:8080/%27>
> );
> };
>
> my.renderGadgets = function() {
>  for (var i = 0; i < my.gadgetSpecUrls.length; ++i) {
>    var gadget = gadgets.container.createGadget(
>        {specUrl: my.gadgetSpecUrls[i]});
>    gadget.setServerBase('http://localhost:8080/gadgets/'<http://localhost:8080/gadgets/%27>
> );
>
>    gadgets.container.addGadget(gadget);
>    gadgets.container.renderGadget(gadget);
>  }
> };
> </script>
> </head>
> <body onLoad="my.init();my.renderGadgets()">
>  <h2>Sample: Dynamic Height</h2>
>  <div id="gadget-chrome-0" class="gadgets-gadget-chrome"></div>
>  <div id="gadget-chrome-1" class="gadgets-gadget-chrome"></div>
>  <div id="gadget-chrome-2" class="gadgets-gadget-chrome"></div>
> </body>
> </html>
>
>
> Regards
> Martin
> --
> Internet Related Technologies - http://www.irt.org
>

Re: "parentRelayUrl" : "/gadgets/files/container/rpc_relay.html" from file based pages

Posted by Kevin Brown <et...@google.com>.
On Fri, Mar 14, 2008 at 6:55 PM, Martin Webb <ma...@gmail.com>
wrote:

> On Fri, Mar 14, 2008 at 6:42 PM, Kevin Brown <et...@google.com> wrote:
>
> >
> > All cross domain calls are blocked (in all browsers I'm aware of)
> between
> > your local file system and a web server -- that means that rpc will only
> > work when both the page you're viewing and the server rendering the
> gadget
> > are served from web servers.
> >
>
> Okay - but...
>
> As long as you always access both the parent page and the iframe page from
> a
> > web server it'll work.
> >
>
> I've found that FF version 2.0.0.12 on Windows XP does not.  I tried
> tracking it down in Firebug to no avail.  I have successfully tested
> FF 3.0bon Windows XP and it works perfectly.


FF3 isn't using ifpc, it's using HTML5's postMessage.

If you're running the parent page and the iframe renderer on separate
domains, you have to make sure that the parent parameter passed to the
iframe matches and that the rpc_relay.html file is available from that root.


>
> Test case - run this on any other server other than localhost:8080
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>Sample: Dynamic Height - fails on FF 2.0.0.12</title>
> <link rel="stylesheet" href="
> http://localhost:8080/gadgets/files/container/gadgets.css">
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/js/rpc.js?c=1&debug=1"></script>
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/files/container/cookies.js"></script>
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/files/container/gadgets.js"></script>
> <script type="text/javascript">
> var my = {};
>
> my.gadgetSpecUrls = [
>   'http://www.google.com/ig/modules/aue07otr.xml?debug=1'
> ];
>
> my.LayoutManager = function() {
>  gadgets.LayoutManager.call(this);
> };
>
> my.LayoutManager.inherits(gadgets.LayoutManager);
>
> my.LayoutManager.prototype.getGadgetChrome = function(gadget) {
>  var chromeId = 'gadget-chrome-' + gadget.id;
>  return chromeId ? document.getElementById(chromeId) : null;
> };
>
> my.init = function() {
>  gadgets.container.layoutManager = new my.LayoutManager();
>   gadgets.container.setParentUrl('http://localhost:8080'<http://localhost:8080%27>
> <http://localhost:8080%27>


Remove this line and you should be good. By default parentUrl is 'http://' +
document.location.host, which is exactly what you want.


> );
> };
>
> my.renderGadgets = function() {
>  for (var i = 0; i < my.gadgetSpecUrls.length; ++i) {
>    var gadget = gadgets.container.createGadget(
>        {specUrl: my.gadgetSpecUrls[i]});
>     gadget.setServerBase('http://localhost:8080/gadgets/'<http://localhost:8080/gadgets/%27>
> <http://localhost:8080/gadgets/%27>
>

This is what controls where iframes are rendered. To actually be secure this
value should always be a different host than the parent page. You don't want
third party content actually rendering on the same domain as the parent
page. "out of the box" we intentionally run everything on the same host to
make testing easier.


> );
>
>     gadgets.container.addGadget(gadget);
>    gadgets.container.renderGadget(gadget);
>  }
> };
> </script>
> </head>
> <body onLoad="my.init();my.renderGadgets()">
>  <h2>Sample: Dynamic Height</h2>
>  <div id="gadget-chrome-0" class="gadgets-gadget-chrome"></div>
> </body>
> </html>
>
> Regards
> Martin
> --
> Internet Related Technologies - http://www.irt.org
>



-- 
~Kevin

Re: "parentRelayUrl" : "/gadgets/files/container/rpc_relay.html" from file based pages

Posted by Martin Webb <ma...@gmail.com>.
>
> I've found that FF version 2.0.0.12 on Windows XP does not.  I tried
> tracking it down in Firebug to no avail.  I have successfully tested FF
> 3.0b on Windows XP and it works perfectly.
>

Also FF version 2.0.0.12 on Ubuntu gutsy also fails.

Regards
Martin

-- 
Internet Related Technologies - http://www.irt.org

Re: "parentRelayUrl" : "/gadgets/files/container/rpc_relay.html" from file based pages

Posted by Martin Webb <ma...@gmail.com>.
On Fri, Mar 14, 2008 at 6:42 PM, Kevin Brown <et...@google.com> wrote:

>
> All cross domain calls are blocked (in all browsers I'm aware of) between
> your local file system and a web server -- that means that rpc will only
> work when both the page you're viewing and the server rendering the gadget
> are served from web servers.
>

Okay - but...

As long as you always access both the parent page and the iframe page from a
> web server it'll work.
>

I've found that FF version 2.0.0.12 on Windows XP does not.  I tried
tracking it down in Firebug to no avail.  I have successfully tested
FF 3.0bon Windows XP and it works perfectly.

Test case - run this on any other server other than localhost:8080

<!DOCTYPE html>
<html>
<head>
<title>Sample: Dynamic Height - fails on FF 2.0.0.12</title>
<link rel="stylesheet" href="
http://localhost:8080/gadgets/files/container/gadgets.css">
<script type="text/javascript" src="
http://localhost:8080/gadgets/js/rpc.js?c=1&debug=1"></script>
<script type="text/javascript" src="
http://localhost:8080/gadgets/files/container/cookies.js"></script>
<script type="text/javascript" src="
http://localhost:8080/gadgets/files/container/gadgets.js"></script>
<script type="text/javascript">
var my = {};

my.gadgetSpecUrls = [
  'http://www.google.com/ig/modules/aue07otr.xml?debug=1'
];

my.LayoutManager = function() {
  gadgets.LayoutManager.call(this);
};

my.LayoutManager.inherits(gadgets.LayoutManager);

my.LayoutManager.prototype.getGadgetChrome = function(gadget) {
  var chromeId = 'gadget-chrome-' + gadget.id;
  return chromeId ? document.getElementById(chromeId) : null;
};

my.init = function() {
  gadgets.container.layoutManager = new my.LayoutManager();
  gadgets.container.setParentUrl('http://localhost:8080'<http://localhost:8080%27>
);
};

my.renderGadgets = function() {
  for (var i = 0; i < my.gadgetSpecUrls.length; ++i) {
    var gadget = gadgets.container.createGadget(
        {specUrl: my.gadgetSpecUrls[i]});
    gadget.setServerBase('http://localhost:8080/gadgets/'<http://localhost:8080/gadgets/%27>
);

    gadgets.container.addGadget(gadget);
    gadgets.container.renderGadget(gadget);
  }
};
</script>
</head>
<body onLoad="my.init();my.renderGadgets()">
  <h2>Sample: Dynamic Height</h2>
  <div id="gadget-chrome-0" class="gadgets-gadget-chrome"></div>
</body>
</html>

Regards
Martin
-- 
Internet Related Technologies - http://www.irt.org

Re: "parentRelayUrl" : "/gadgets/files/container/rpc_relay.html" from file based pages

Posted by Kevin Brown <et...@google.com>.
On Fri, Mar 14, 2008 at 6:23 AM, Martin Webb <ma...@gmail.com>
wrote:

> I'm stuck - and its my lack of knowledge of how shindig's rpc relay is
> supposed to work that is stumping me.
>
> If I view http://localhost:8080/gadgets/files/container/sample2.html -
> then
> the 2nd of the three sample widgets supports dynamicHeight perfectly.
>
> If however I host just the sample2.html page from the file store (e.g.
> file:///D:/workspace/shindig/javascript/container/sample2.html) *AND
> *change
> all the references to point back to the gadget server then dynamicHeight
> stops working.  What do I need to add to the following to get it to start
> working again?


All cross domain calls are blocked (in all browsers I'm aware of) between
your local file system and a web server -- that means that rpc will only
work when both the page you're viewing and the server rendering the gadget
are served from web servers.

As long as you always access both the parent page and the iframe page from a
web server it'll work.


>
>
> This is a small repeatable test case as I'm having problems with a
> container
> separate from the gadget server.
>
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>Sample: Dynamic Height</title>
> <!-- default container look and feel -->
> <link rel="stylesheet" href="
> http://localhost:8080/gadgets/files/container/gadgets.css">
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/js/rpc.js?c=1&debug=1"></script>
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/files/container/cookies.js"></script>
> <script type="text/javascript" src="
> http://localhost:8080/gadgets/files/container/gadgets.js"></script>
> <script type="text/javascript">
> var my = {};
>
> my.gadgetSpecUrls = [
>  'http://www.google.com/ig/modules/horoscope.xml',
>  'http://www.google.com/ig/modules/aue07otr.xml',
>  'http://www.labpixies.com/campaigns/todo/todo.xml'
> ];
>
>
> // This container lays out and renders gadgets itself.
>
> my.LayoutManager = function() {
>  gadgets.LayoutManager.call(this);
> };
>
> my.LayoutManager.inherits(gadgets.LayoutManager);
>
> my.LayoutManager.prototype.getGadgetChrome = function(gadget) {
>  var chromeId = 'gadget-chrome-' + gadget.id;
>  return chromeId ? document.getElementById(chromeId) : null;
> };
>
> my.init = function() {
>  gadgets.container.layoutManager = new my.LayoutManager();
>  gadgets.container.setParentUrl('http://localhost:8080/'<http://localhost:8080/%27>
> );
> };
>
> my.renderGadgets = function() {
>  for (var i = 0; i < my.gadgetSpecUrls.length; ++i) {
>    var gadget = gadgets.container.createGadget(
>        {specUrl: my.gadgetSpecUrls[i]});
>    gadget.setServerBase('http://localhost:8080/gadgets/'<http://localhost:8080/gadgets/%27>
> );
>
>    gadgets.container.addGadget(gadget);
>    gadgets.container.renderGadget(gadget);
>  }
> };
> </script>
> </head>
> <body onLoad="my.init();my.renderGadgets()">
>  <h2>Sample: Dynamic Height</h2>
>  <div id="gadget-chrome-0" class="gadgets-gadget-chrome"></div>
>  <div id="gadget-chrome-1" class="gadgets-gadget-chrome"></div>
>  <div id="gadget-chrome-2" class="gadgets-gadget-chrome"></div>
> </body>
> </html>
>
>
> Regards
> Martin
> --
> Internet Related Technologies - http://www.irt.org
>



-- 
~Kevin