$(my) gadget URL

97 views
Skip to first unread message

Troy A. Griffitts

unread,
Jul 4, 2012, 12:07:10 PM7/4/12
to opensocial-an...@googlegroups.com
I have had a tough time with relative URLs when building gadgets.

Is there a standard, supplied way, in the OS spec, which allows me to
determine $(my) URL?

Example scenario:

I have a gadget and service which live at:

http://gadgetserver.org/gadgets/mygadget/
http://gadgetserver.org/gadgets/mygadget/service/

I can't simply use 'service/' as the URL in my makeRequest call, as
this never resolves appropriately.

Can I construct this service URL somehow (some imaginary method like:
constructURLFromRelativePath('service/')), such that if this gadget is
relocated, I won't have to change my code?

Troy

Troy A. Griffitts

unread,
Jul 4, 2012, 3:36:42 PM7/4/12
to opensocial-an...@googlegroups.com
I guess I could have asked this more concisely:

In my gadget javascript, does the current OpenSocial specification
provide a way for me to call makeRequest with a URL relative to my
gadget URL (not my portal URL)?

e.g.,

gadgets.io.makeRequest('service/', function(o) {
// do something
}, params);

'service/' is the problem. 'service/' hypothetically lives at a
location relative to my gadget URL-- this seems the natural use case,
and is certainly for us: all of our supporting service URLs are
relative to our Gadget URLs, NOT our container URL. They don't
live/run in the OpenSocial container running my gadget.

If there is nothing in the spec. Can I propose something be added for
the OpenSocial Gadget to build URLs relative to itself?

Troy

James M Snell

unread,
Jul 4, 2012, 3:44:16 PM7/4/12
to opensocial-an...@googlegroups.com

In theory relative urls in the gadget are supposed to resolve relative to the gadget url but in practice this part is very underspecified and not well implemented. I have proposed adding support for xml:base in OS 3.0 which will help to a degree but more needs to be done. You'll be better off avoiding the use of relative urls for now.

--
You received this message because you are subscribed to the Google Groups "OpenSocial and Gadgets Specification Discussion" group.
To post to this group, send email to opensocial-an...@googlegroups.com.
To unsubscribe from this group, send email to opensocial-and-gadg...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.

Troy A. Griffitts

unread,
Jul 4, 2012, 5:28:40 PM7/4/12
to opensocial-an...@googlegroups.com
James, do you have an alternative?
We are developing a suite of gadgets which will be installed at a
number of different universities.
Each university will need their installed suite of gadgets to talk
back to its corresponding set of services
Is there a way for a gadget to obtain 'my' URL? i.e., the URL from
where the gadget source was loaded? This seems very fundamental. How
can any gadget be deployed at multiple sites for multiple purposes
without knowing how to call support services corresponding to its
install?

Ryan Baxter

unread,
Jul 5, 2012, 4:13:42 PM7/5/12
to opensocial-an...@googlegroups.com, Henry Saputra, Mark Weitzel
Actually the spec only defines how relative URLs work in XML attributes...

Containers MUST interpret any relative URLs found in XML attributes or values as relative to the gadget spec's URL.
 
It says nothing about relative URLs used in the JS APIs.

I think "aliasing" [1] could help in this case, but I am not sure it was ever implemented anywhere...Henry and / or Mark was this implemented?


>> To unsubscribe from this group, send email to
>> For more options, visit this group at
>> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSocial and Gadgets Specification Discussion" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to

Henry Saputra

unread,
Jul 5, 2012, 4:51:21 PM7/5/12
to Ryan Baxter, opensocial-an...@googlegroups.com, Mark Weitzel
Its not fully implemented yet. I have added parsing for the
ExternalService tag but havent added code to parse the alias and the
backend model to register the services.

- Henry
>> >> opensocial-an...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> opensocial-and-gadg...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "OpenSocial and Gadgets Specification Discussion" group.
>> > To post to this group, send email to
>> > opensocial-an...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > opensocial-and-gadg...@googlegroups.com.

Troy A. Griffitts

unread,
Jul 5, 2012, 5:31:17 PM7/5/12
to opensocial-an...@googlegroups.com, Ryan Baxter, Mark Weitzel
OK, forget relative URLs. I can build them myself if I have a method
which can obtain my gadget spec URL. Is there such a method provided
in the OpenSocial spec?

e.g., var myURL = getMyGadgetSpecURL();

Henry Saputra

unread,
Jul 5, 2012, 6:00:44 PM7/5/12
to opensocial-an...@googlegroups.com
AFAIK not directly, but there is a JS function to get the URL
parameters "gadgets.util.getUrlParameters" and then you can get the
gadget URL by getting the "url" param.

Then you can use shindig.uri.resolve to resolve your target path
relative to the base location of your gadget.xml file.

Hope this helps.

- Henry

Ryan Baxter

unread,
Jul 6, 2012, 11:40:48 AM7/6/12
to opensocial-an...@googlegroups.com
Keep in mind these are Shindig specific and not part of the OpenSocial spec.
>>>> >> opensocial-and-gadgets-spec@googlegroups.com.
>>>> >> To unsubscribe from this group, send email to
>>>> >> opensocial-and-gadgets-spec+unsub...@googlegroups.com.
>>>> >> For more options, visit this group at
>>>> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>>>> >>
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> > Groups
>>>> > "OpenSocial and Gadgets Specification Discussion" group.
>>>> > To post to this group, send email to
>>>> > opensocial-and-gadgets-spec@googlegroups.com.
>>>> > To unsubscribe from this group, send email to
>>>> > opensocial-and-gadgets-spec+unsub...@googlegroups.com.
>>>> > For more options, visit this group at
>>>> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "OpenSocial and Gadgets Specification Discussion" group.
>> To post to this group, send email to opensocial-and-gadgets-spec@googlegroups.com.
>> To unsubscribe from this group, send email to opensocial-and-gadgets-spec+unsub...@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "OpenSocial and Gadgets Specification Discussion" group.
> To post to this group, send email to opensocial-and-gadgets-spec@googlegroups.com.
> To unsubscribe from this group, send email to opensocial-and-gadgets-spec+unsub...@googlegroups.com.

Troy A. Griffitts

unread,
Jul 21, 2012, 5:17:42 PM7/21/12
to opensocial-an...@googlegroups.com
Henry and Ryan,

Henry, thank you for the suggestion. I have just gotten around to
changing all of our service calls to use relative URLs based on your
suggestion:

gadgets.util.getUrlParameters()['url'];

which get's my own gadget's URL. It works great. Thank you so much
for taking the time to post the solution.

Ryan, you say 'these are shindig specific'. Does this mean the above
call is also shindig specific or just the second part of Henry's
suggestion:

shindig.uri.resolve

I didn't use this, but instead a simple javascript URL utility from
here: http://medialize.github.com/URI.js

Thanks for all the help,

Troy
>> >>>> >> opensocial-an...@googlegroups.com.
>> >>>> >> To unsubscribe from this group, send email to
>> >>>> >> opensocial-and-gadg...@googlegroups.com.
>> >>>> >> For more options, visit this group at
>> >>>> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >>>> >>
>> >>>> > --
>> >>>> > You received this message because you are subscribed to the Google
>> >>>> > Groups
>> >>>> > "OpenSocial and Gadgets Specification Discussion" group.
>> >>>> > To post to this group, send email to
>> >>>> > opensocial-an...@googlegroups.com.
>> >>>> > To unsubscribe from this group, send email to
>> >>>> > opensocial-and-gadg...@googlegroups.com.
>> >>>> > For more options, visit this group at
>> >>>> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups "OpenSocial and Gadgets Specification Discussion" group.
>> >> To post to this group, send email to
>> >> opensocial-an...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> opensocial-and-gadg...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "OpenSocial and Gadgets Specification Discussion" group.
>> > To post to this group, send email to
>> > opensocial-an...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > opensocial-and-gadg...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSocial and Gadgets Specification Discussion" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/2nKpGm7exv4J.
>
> To post to this group, send email to
> opensocial-an...@googlegroups.com.
> To unsubscribe from this group, send email to
> opensocial-and-gadg...@googlegroups.com.

Ryan Baxter

unread,
Jul 22, 2012, 7:22:24 PM7/22/12
to opensocial-an...@googlegroups.com
gadgets.util.getUrlParameters is not part of the core gadget spec, so yes it is Shindig specific.
>> >>>> >> To unsubscribe from this group, send email to
>> >>>> >> For more options, visit this group at
>> >>>> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >>>> >>
>> >>>> > --
>> >>>> > You received this message because you are subscribed to the Google
>> >>>> > Groups
>> >>>> > "OpenSocial and Gadgets Specification Discussion" group.
>> >>>> > To post to this group, send email to
>> >>>> > To unsubscribe from this group, send email to
>> >>>> > For more options, visit this group at
>> >>>> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups "OpenSocial and Gadgets Specification Discussion" group.
>> >> To post to this group, send email to
>> >> To unsubscribe from this group, send email to
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "OpenSocial and Gadgets Specification Discussion" group.
>> > To post to this group, send email to
>> > To unsubscribe from this group, send email to
>> > For more options, visit this group at
>> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSocial and Gadgets Specification Discussion" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/2nKpGm7exv4J.
>
> To post to this group, send email to
> To unsubscribe from this group, send email to

Troy A. Griffitts

unread,
Jul 24, 2012, 5:31:18 PM7/24/12
to opensocial-an...@googlegroups.com
Can it be made part of the core gadget spec.

How else am I supposed to determine my own URL?

I realize there are many great things happening with the OS spec, but
these simple things are really important to a basic javascript gadget
developer.

Without this, our gadgets cannot find their services which are located
relative to their position on whatever server they are installed.

Thank you for considering,

Troy
>> >> >>>> >> opensocial-an...@googlegroups.com.
>> >> >>>> >> To unsubscribe from this group, send email to
>> >> >>>> >> opensocial-and-gadg...@googlegroups.com.
>> >> >>>> >> For more options, visit this group at
>> >> >>>> >>
>> >> >>>> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >> >>>> >>
>> >> >>>> > --
>> >> >>>> > You received this message because you are subscribed to the
>> >> >>>> > Google
>> >> >>>> > Groups
>> >> >>>> > "OpenSocial and Gadgets Specification Discussion" group.
>> >> >>>> > To post to this group, send email to
>> >> >>>> > opensocial-an...@googlegroups.com.
>> >> >>>> > To unsubscribe from this group, send email to
>> >> >>>> > opensocial-and-gadg...@googlegroups.com.
>> >> >>>> > For more options, visit this group at
>> >> >>>> >
>> >> >>>> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >> >>
>> >> >> --
>> >> >> You received this message because you are subscribed to the Google
>> >> >> Groups "OpenSocial and Gadgets Specification Discussion" group.
>> >> >> To post to this group, send email to
>> >> >> opensocial-an...@googlegroups.com.
>> >> >> To unsubscribe from this group, send email to
>> >> >> opensocial-and-gadg...@googlegroups.com.
>> >> >> For more options, visit this group at
>> >> >> http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >> >>
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups "OpenSocial and Gadgets Specification Discussion" group.
>> >> > To post to this group, send email to
>> >> > opensocial-an...@googlegroups.com.
>> >> > To unsubscribe from this group, send email to
>> >> > opensocial-and-gadg...@googlegroups.com.
>> >> > For more options, visit this group at
>> >> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>> >> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "OpenSocial and Gadgets Specification Discussion" group.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/2nKpGm7exv4J.
>> >
>> > To post to this group, send email to
>> > opensocial-an...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > opensocial-and-gadg...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSocial and Gadgets Specification Discussion" group.
> To post to this group, send email to
> opensocial-an...@googlegroups.com.
> To unsubscribe from this group, send email to
> opensocial-and-gadg...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/opensocial-and-gadgets-spec/-/Q6vkV_VWuncJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Henry Saputra

unread,
Jul 24, 2012, 5:55:16 PM7/24/12
to opensocial-an...@googlegroups.com
Yeah agree that this is a good idea.
I didnt find usefulness to get the full gadget url before but looks
like more and more gadgets need this info to get relative URL to their
gadget.

Need to add API to get the actual gadget URL to the gadgets.util
namespace I suppose.

Troy, have you ever try to open an issue with the spec in
http://code.google.com/p/opensocial-resources/issues ?

It would be a good idea to try open an issue against the specs community.

- Henry
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Troy A. Griffitts

unread,
Jul 25, 2012, 12:22:31 PM7/25/12
to opensocial-an...@googlegroups.com

Henry Saputra

unread,
Jul 25, 2012, 2:04:18 PM7/25/12
to opensocial-an...@googlegroups.com
Cool, thanks for opening an issue for it.

Thanks,

Henry
Reply all
Reply to author
Forward
0 new messages