Yes, that's exactly why we need to add the logic CoreUtilConfigContributor
.
In the feature opensocial-template, it read the template url from the
glabal vairable gadgets.features using "var params =
gadgets.util.getFeatureParameters(opensocial-templates')", which is
initialized by the data pushed by CoreUtilConfigContributor.
You can find the code in feature opensocial-template, container.js:
os.Container.processGadget = function() {
if (!window['gadgets']) {
return;
}
var params = gadgets.util.getFeatureParameters(opensocial-templates');
if (!params) {
return;
....
// Honor the "requireLibrary" feature param(s).
if (params.requireLibrary) {
if (typeof params.requireLibrary == 'string') {
os.Container.addRequiredLibrary(params.requireLibrary);
----------------------------------------------
ERiK (Zheng BI) PMP
IBM Project Vulcan
China Development Lab, IBM Shanghai
TEL:(86-21)60922769
Internet ID: [email protected]
Addr: 5F, Building 10, No 399, Ke Yuan Road, Zhang Jiang High Tech Park,
201203, Shanghai, China
------------------------------------------------
From: "Henry Saputra" <[email protected]>
To: "Dan Dumont" <[email protected]>, "Stanton Sievers"
<[email protected]>, "Ryan Baxter" <[email protected]>
Cc: "Henry Saputra" <[email protected]>, "shindig"
<[email protected]>, Zheng Bi/China/IBM@IBMCN
Date: 2012/04/26 04:43
Subject: Re: Review Request: Shindig does not accept relative URLs
for template libraries
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/4818/#review7243
-----------------------------------------------------------
http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/config/CoreUtilConfigContributor.java
<https://reviews.apache.org/r/4818/#comment15976>
This seems the wrong approach for me. Each ConfigContributor
responsible to add additional config from server.
In this case the CoreUtilConfigContributor is used to add additional
logic to push config to init function in the core.util feature.
Not sure how the opensocial-templates JS code could read this new
rewritten requireLibrary param.
- Henry
On 2012-04-25 02:27:27, Erik Bi wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/4818/
> -----------------------------------------------------------
>
> (Updated 2012-04-25 02:27:27)
>
>
> Review request for shindig, Ryan Baxter, Dan Dumont, and Stanton
Sievers.
>
>
> Summary
> -------
>
> per spec, Gadget should be able to use relative URL to define the
template-libray, but right now when it uses this approach, client side
will end up making a /gadgets/makeRequest call and passes in the relative
URL value and fails with an HTTP status of 400.
>
> Solution:
> At client side, the opensocial-template feature will get the
template-library URL value from global variable "features", so in this
patch it updates the process of generating the init JS which will be
passed back to client side to init the "features" variable(in Class
"org.apache.shindig.gadgets.config.CoreUtilConfigContributor"), adds some
specific logic to handle "template-library" parameter, convert the
relative url to an absolute one.
>
>
> This addresses bug shindig-1548.
> https://issues.apache.org/jira/browse/shindig-1548
>
>
> Diffs
> -----
>
>
http://svn.apache.org/repos/asf/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/config/CoreUtilConfigContributor.java
1327432
>
> Diff: https://reviews.apache.org/r/4818/diff
>
>
> Testing
> -------
>
>
> Thanks,
>
> Erik
>
>