You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@shindig.apache.org by Mohamed IBN ELAZZOUZI <mo...@gmail.com> on 2011/03/09 21:52:11 UTC

Shindig Content/URLs rewrite

Hi all,
I'm trying to add my own content rewriter with shindig.
My use case is :
rewrite web content urls before rendering it.
with relatives path like <script type="text/javascript"
language="JavaScript" src="javascript/common.js"></script> i want to
get <script
type="text/javascript" language="JavaScript" src="http://myhost:
/toto/javascript/common.js"></script>
and the base url (http://myhost:/toto) is the url attribute of my gadget
content in the gadget.xml
In my code, i can retrieve it, nice, but the problem is when i want to get
my url (http://myhost:/toto/javascript/common.js) the (/toto) is deleted.
I found the problem in the org.apache.shindig.common.uri.Uri class when i
call the org.apache.shindig.common.uri.Uri.resolve(Uri) method :
 String basePath = path != null ? path : "/";
 int endindex = basePath.lastIndexOf('/') + 1;
 result.setPath(normalizePath(basePath.substring(0, endindex) +
relativePath));
So the path (/toto) is replaced by the new path (javascript/common.js)
Should i keep these instructions or is it a bug?
Thank you for advance.
Mohamed.

Re: Shindig Content/URLs rewrite

Posted by Mohamed IBN ELAZZOUZI <mo...@gmail.com>.
I found the solution,
i replaced http://myhost/toto by http://myhost/toto/ and all works fine.
Regards.

2011/3/9 Mohamed IBN ELAZZOUZI <mo...@gmail.com>

> Hi all,
> I'm trying to add my own content rewriter with shindig.
> My use case is :
> rewrite web content urls before rendering it.
> with relatives path like <script type="text/javascript"
> language="JavaScript" src="javascript/common.js"></script> i want to get <script
> type="text/javascript" language="JavaScript" src="http://myhost:
> /toto/javascript/common.js"></script>
> and the base url (http://myhost:/toto) is the url attribute of my gadget
> content in the gadget.xml
> In my code, i can retrieve it, nice, but the problem is when i want to get
> my url (http://myhost:/toto/javascript/common.js) the (/toto) is deleted.
> I found the problem in the org.apache.shindig.common.uri.Uri class when i
> call the org.apache.shindig.common.uri.Uri.resolve(Uri) method :
>  String basePath = path != null ? path : "/";
>  int endindex = basePath.lastIndexOf('/') + 1;
>  result.setPath(normalizePath(basePath.substring(0, endindex) +
> relativePath));
> So the path (/toto) is replaced by the new path (javascript/common.js)
> Should i keep these instructions or is it a bug?
> Thank you for advance.
> Mohamed.
>