You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Grzegorz Kossakowski <gr...@tuffmail.com> on 2007/02/02 00:13:29 UTC

Rewriting links in js files

Hi,

Yes, it's me n-th time ;)

I would like to discuss link rewriting in js files and other text
resources (css for example). Obviosuly, soon or later, there will be
need (actually it already is, in Forms) to store some paths in JS files.
That means that we have to take care of rewriting links in this kind of
resources.

My proposal is to introduce new reader for this task. It would scan
whole content of file for valid URLs to rewrite, and do the job. I
think, it could be easily achieved by use of some regexps. Of course,
this new reader would implement caching because rewriting of some big
files would be quite time-consuming.

I haven't looked into the code of LinkRewritingTransformer so I'm not
sure if it's code could be reused. Even if I had to write it from
scratch I'm enough motivated but need to be sure that my work is not
waste of time.

Do you have any thoughts? Other options?

-- 
Grzegorz Kossakowski

Re: Rewriting links in js files

Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Grzegorz Kossakowski skrev:

...
> I don't understand, I was asking about reader for rewriting links in js
> files. There is no room for transformer and there are no attributes thus
> we have to use regexps, right?
>
> Writing specialized link rewriting transformer only for servlet: links
> would make sense, but now my priority is to make all these refactorings
> usable. Then we could polish details.
>   
Seem like I wrote something other than I intended. I meant:

I agree with that we need a rewriting reader. For the actual
implementation I don't think there is much to reuse from the
LinkRewritingTransformer. There is a large difference in scanning SAX
and a stream, for attributes. Furthermore I would propose making it
specialized for rewriting the servlet protocol, so that the only
configuration parameter is what attributes to rewrite.

/Daniel


Re: Rewriting links in js files

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Daniel Fagerstrom napisaƂ(a):
> Grzegorz Kossakowski skrev:
>> Hi,
>>
>> Yes, it's me n-th time ;)
>>
>> I would like to discuss link rewriting in js files and other text
>> resources (css for example). Obviosuly, soon or later, there will be
>> need (actually it already is, in Forms) to store some paths in JS files.
>> That means that we have to take care of rewriting links in this kind of
>> resources.
>>
>> My proposal is to introduce new reader for this task. It would scan
>> whole content of file for valid URLs to rewrite, and do the job. I
>> think, it could be easily achieved by use of some regexps. Of course,
>> this new reader would implement caching because rewriting of some big
>> files would be quite time-consuming.
>>
>> I haven't looked into the code of LinkRewritingTransformer so I'm not
>> sure if it's code could be reused. Even if I had to write it from
>> scratch I'm enough motivated but need to be sure that my work is not
>> waste of time.
>>
>> Do you have any thoughts? Other options?
>>   
> I agree with that we need a rewriting transformer. For the actual
> implementation I don't think there is much to reuse from the
> LinkRewritingTransformer. There is a large difference in scanning SAX
> and a stream, for attributes. Furthermore I would propose making it
> specialized for rewriting the servlet protocol, so that the only
> configuration parameter is what attributes to rewrite.
I don't understand, I was asking about reader for rewriting links in js
files. There is no room for transformer and there are no attributes thus
we have to use regexps, right?

Writing specialized link rewriting transformer only for servlet: links
would make sense, but now my priority is to make all these refactorings
usable. Then we could polish details.

-- 
Grzegorz Kossakowski

Re: Rewriting links in js files

Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Grzegorz Kossakowski skrev:
> Hi,
>
> Yes, it's me n-th time ;)
>
> I would like to discuss link rewriting in js files and other text
> resources (css for example). Obviosuly, soon or later, there will be
> need (actually it already is, in Forms) to store some paths in JS files.
> That means that we have to take care of rewriting links in this kind of
> resources.
>
> My proposal is to introduce new reader for this task. It would scan
> whole content of file for valid URLs to rewrite, and do the job. I
> think, it could be easily achieved by use of some regexps. Of course,
> this new reader would implement caching because rewriting of some big
> files would be quite time-consuming.
>
> I haven't looked into the code of LinkRewritingTransformer so I'm not
> sure if it's code could be reused. Even if I had to write it from
> scratch I'm enough motivated but need to be sure that my work is not
> waste of time.
>
> Do you have any thoughts? Other options?
>   
I agree with that we need a rewriting transformer. For the actual 
implementation I don't think there is much to reuse from the 
LinkRewritingTransformer. There is a large difference in scanning SAX 
and a stream, for attributes. Furthermore I would propose making it 
specialized for rewriting the servlet protocol, so that the only 
configuration parameter is what attributes to rewrite.

/Daniel


Re: Rewriting links in js files

Posted by Jeremy Quinn <je...@apache.org>.
HI

If you are using Dojo, it can already do this on the client.

for instance :

	templatePath: dojo.uri.dojoUri("../viewr/templates/HtmlStory.html"),

Gives you a url relative to where Dojo loaded from.

HTH

regards Jeremy


On 1 Feb 2007, at 23:13, Grzegorz Kossakowski wrote:

> Hi,
>
> Yes, it's me n-th time ;)
>
> I would like to discuss link rewriting in js files and other text
> resources (css for example). Obviosuly, soon or later, there will be
> need (actually it already is, in Forms) to store some paths in JS  
> files.
> That means that we have to take care of rewriting links in this  
> kind of
> resources.
>
> My proposal is to introduce new reader for this task. It would scan
> whole content of file for valid URLs to rewrite, and do the job. I
> think, it could be easily achieved by use of some regexps. Of course,
> this new reader would implement caching because rewriting of some big
> files would be quite time-consuming.
>
> I haven't looked into the code of LinkRewritingTransformer so I'm not
> sure if it's code could be reused. Even if I had to write it from
> scratch I'm enough motivated but need to be sure that my work is not
> waste of time.
>
> Do you have any thoughts? Other options?
>
> -- 
> Grzegorz Kossakowski