You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ken Gerrard <ke...@gmail.com> on 2007/08/30 16:42:41 UTC

URL translations/rewriting

Hello. I've been using Cocoon for a few years and I love it! I'm using
2.1.10 on Windows, MacOS X, and SuSE linux.

A web services interface has been written at my work, a public transit
provider. I find some of the URLs distasteful (queries when they
should be resources) and would like to create aliases on top of them
that translate invisibly to the underlying URLs.

For instance:

/stops/10064/schedule
|
-> /schedules?stopNumber=10064

/stops/(49.856,-97.149),(49.870,-97.112)
|
-> /stops?lat1=49.856&lon1=-97.149&lat2=49.870&lon2=-97.112

I have tried to solve this several ways. The first attempt, for the
second URL, looked like this:
    		<match pattern="stops/(*,*),(*,*)">
    			<redirect-to
uri="cocoon:/stops?lat1={1}&amp;lon1={2}&amp;lat2={3}&amp;lon2={4}"/>
    		</match>

That didn't work; the URL parameters don't seem to survive into the
cocoon protocol.

I've also tried CInclude, but since that uses the same cocoon
protocol, it doesn't work either.

It works with http://, of course, but that requires me to know the
host I'm on and the directory I'm in.

I've poked around in the CInclude transformer. Might I have to do
something with the SourceResolver? It accepts parameters, but the
SitemapSource that comes out never has them.

I hope this question hasn't been asked. I searched various places, but
the term "URL rewriting" has a different meaning than I expect.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: URL translations/rewriting

Posted by Ken Gerrard <ke...@gmail.com>.
On 8/30/07, warrell harries <wa...@googlemail.com> wrote:
> Can you use the {request-param:lon1} input module?
>
> e.g.
> <redirect-touri="cocoon:/stops?lat1={request-param:lat1}&amp;lon1={request-param:lon1}&amp;lat2={request-param:lat2}&amp;lon2={request-param:lon2}"/>

That won't work because in the original (alias) URL, the parameters
are not named by anything other than position:
<match pattern="stops/(*,*),(*,*)">

It might be more clear to expand on the other example. I'd like to be
able to do this:
<match pattern="stops/*/schedule">
  <redirect-to uri="cocoon:/schedules?stopNumber={1}"/>
</match>

Making it even more complicated is something I forgot about: the URLs
have optional parameters, too, that need to be passed on in the
underlying request. Example:
stops/10064/schedule?time=2007-09-03
|
-> schedules?stopNumber=10064&time=2007-09-03

I could easily do that if CInclude worked the way I expect. Is there a
way to get the parameters of a cocoon: protocol URI to go through?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: URL translations/rewriting

Posted by warrell harries <wa...@googlemail.com>.
Can you use the {request-param:lon1} input module?

e.g.
<redirect-touri="cocoon:/stops?lat1={request-param:lat1}&amp;lon1={request-param:lon1}&amp;lat2={request-param:lat2}&amp;lon2={request-param:lon2}"/>


On 30/08/2007, Ken Gerrard <ke...@gmail.com> wrote:
>
> Hello. I've been using Cocoon for a few years and I love it! I'm using
> 2.1.10 on Windows, MacOS X, and SuSE linux.
>
> A web services interface has been written at my work, a public transit
> provider. I find some of the URLs distasteful (queries when they
> should be resources) and would like to create aliases on top of them
> that translate invisibly to the underlying URLs.
>
> For instance:
>
> /stops/10064/schedule
> |
> -> /schedules?stopNumber=10064
>
> /stops/(49.856,-97.149),(49.870,-97.112)
> |
> -> /stops?lat1=49.856&lon1=-97.149&lat2=49.870&lon2=-97.112
>
> I have tried to solve this several ways. The first attempt, for the
> second URL, looked like this:
>                 <match pattern="stops/(*,*),(*,*)">
>                         <redirect-to
> uri="cocoon:/stops?lat1={1}&amp;lon1={2}&amp;lat2={3}&amp;lon2={4}"/>
>                 </match>
>
> That didn't work; the URL parameters don't seem to survive into the
> cocoon protocol.
>
> I've also tried CInclude, but since that uses the same cocoon
> protocol, it doesn't work either.
>
> It works with http://, of course, but that requires me to know the
> host I'm on and the directory I'm in.
>
> I've poked around in the CInclude transformer. Might I have to do
> something with the SourceResolver? It accepts parameters, but the
> SitemapSource that comes out never has them.
>
> I hope this question hasn't been asked. I searched various places, but
> the term "URL rewriting" has a different meaning than I expect.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: URL translations/rewriting

Posted by Ken Gerrard <ke...@gmail.com>.
On 8/30/07, Grzegorz Kossakowski <gk...@apache.org> wrote:
[...]
> I'm not really sure what do you want to achieve. Do you have poorly written pipelines (matches) in
> your sitemap and you want to create "alias" matches? Or do you have an external service and you want
> to create aliases internally so you can use that external service in more convenient way?

The former. The pipelines have been created in a very restrictive way
that I don't have the prerogative to change. I want to have alias URLs
that simply resolve to the uglier, ?-and-&-infested URLs. It's all
inside Cocoon.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: URL translations/rewriting

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Ken Gerrard pisze:
> Hello. I've been using Cocoon for a few years and I love it! I'm using
> 2.1.10 on Windows, MacOS X, and SuSE linux.
> 
> A web services interface has been written at my work, a public transit
> provider. I find some of the URLs distasteful (queries when they
> should be resources) and would like to create aliases on top of them
> that translate invisibly to the underlying URLs.
> 
> For instance:
> 
> /stops/10064/schedule
> |
> -> /schedules?stopNumber=10064
> 
> /stops/(49.856,-97.149),(49.870,-97.112)
> |
> -> /stops?lat1=49.856&lon1=-97.149&lat2=49.870&lon2=-97.112
> 
> I have tried to solve this several ways. The first attempt, for the
> second URL, looked like this:
>     		<match pattern="stops/(*,*),(*,*)">
>     			<redirect-to
> uri="cocoon:/stops?lat1={1}&amp;lon1={2}&amp;lat2={3}&amp;lon2={4}"/>
>     		</match>
> 
> That didn't work; the URL parameters don't seem to survive into the
> cocoon protocol.

The cocoon protocol should work well with any parameters that are given in the url. Can you show
what exactly does not work?

> I've also tried CInclude, but since that uses the same cocoon
> protocol, it doesn't work either.
> 
> It works with http://, of course, but that requires me to know the
> host I'm on and the directory I'm in.
> 
> I've poked around in the CInclude transformer. Might I have to do
> something with the SourceResolver? It accepts parameters, but the
> SitemapSource that comes out never has them.
> 
> I hope this question hasn't been asked. I searched various places, but
> the term "URL rewriting" has a different meaning than I expect.

I'm not really sure what do you want to achieve. Do you have poorly written pipelines (matches) in
your sitemap and you want to create "alias" matches? Or do you have an external service and you want
to create aliases internally so you can use that external service in more convenient way?

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org