* Links and Modular Apps
@ 2010-10-22 4:53 andyl
2010-10-22 6:19 ` Sylvain Desvé
0 siblings, 1 reply; 4+ messages in thread
From: andyl @ 2010-10-22 4:53 UTC (permalink / raw)
To: Rack Development
I would like to use Rack to mount modular apps.
Using the 'map' statement in config.ru, I can mount an app just fine.
But - the links in my sub-apps don't work.
If I mount App1 on '/app1', and App1 has a link <a href='/page'>,
it needs to render '/app1/page' instead of '/page'.
How do people get around this problem??
Thanks, Andy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Links and Modular Apps
2010-10-22 4:53 Links and Modular Apps andyl
@ 2010-10-22 6:19 ` Sylvain Desvé
2010-10-23 0:13 ` andyl
0 siblings, 1 reply; 4+ messages in thread
From: Sylvain Desvé @ 2010-10-22 6:19 UTC (permalink / raw)
To: rack-devel
[-- Attachment #1: Type: text/plain, Size: 693 bytes --]
The Rack URLMap changes the env so that '/app1' is moved from PATH_INFO to
SCRIPT_NAME.
You need a helper in your Sinatra application to reconstruct paths :
helpers do
def path_to(path)
request.script_name + path
en
end
and then use it in your templates :
<a href='#{path_to('/page')}'>
2010/10/22 andyl <akleak@gmail.com>
> I would like to use Rack to mount modular apps.
>
> Using the 'map' statement in config.ru, I can mount an app just fine.
>
> But - the links in my sub-apps don't work.
>
> If I mount App1 on '/app1', and App1 has a link <a href='/page'>,
> it needs to render '/app1/page' instead of '/page'.
>
> How do people get around this problem??
>
> Thanks, Andy
[-- Attachment #2: Type: text/html, Size: 1638 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Links and Modular Apps
2010-10-22 6:19 ` Sylvain Desvé
@ 2010-10-23 0:13 ` andyl
2010-10-23 2:29 ` Yehuda Katz
0 siblings, 1 reply; 4+ messages in thread
From: andyl @ 2010-10-23 0:13 UTC (permalink / raw)
To: Rack Development
Thanks - your approach worked !!
I think I'm going to create a link-rewriting middleware, so I can use
unmodified Sinatra apps - but this is a nice intermediate step.
- Andy
On Oct 21, 11:19 pm, Sylvain Desvé <sylvain.de...@gmail.com> wrote:
> The Rack URLMap changes the env so that '/app1' is moved from PATH_INFO to
> SCRIPT_NAME.
>
> You need a helper in your Sinatra application to reconstruct paths :
>
> helpers do
> def path_to(path)
> request.script_name + path
> en
> end
>
> and then use it in your templates :
>
> <a href='#{path_to('/page')}'>
>
> 2010/10/22 andyl <akl...@gmail.com>
>
> > I would like to use Rack to mount modular apps.
>
> > Using the 'map' statement in config.ru, I can mount an app just fine.
>
> > But - the links in my sub-apps don't work.
>
> > If I mount App1 on '/app1', and App1 has a link <a href='/page'>,
> > it needs to render '/app1/page' instead of '/page'.
>
> > How do people get around this problem??
>
> > Thanks, Andy
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Links and Modular Apps
2010-10-23 0:13 ` andyl
@ 2010-10-23 2:29 ` Yehuda Katz
0 siblings, 0 replies; 4+ messages in thread
From: Yehuda Katz @ 2010-10-23 2:29 UTC (permalink / raw)
To: rack-devel@googlegroups.com
this is something that Rails 3.1's engines do automatically (and rails
itself will do if you mount the main Rails app in a URLMap).
In my opinion, this makes more sense as a Sinatra helper than an
output modifying middleware (which is extremely expensive and
potentially error-prone)
Sent from my iPhone
On Oct 22, 2010, at 5:13 PM, andyl <akleak@gmail.com> wrote:
> Thanks - your approach worked !!
>
> I think I'm going to create a link-rewriting middleware, so I can use
> unmodified Sinatra apps - but this is a nice intermediate step.
>
> - Andy
>
> On Oct 21, 11:19 pm, Sylvain Desvé <sylvain.de...@gmail.com> wrote:
>> The Rack URLMap changes the env so that '/app1' is moved from PATH_INFO to
>> SCRIPT_NAME.
>>
>> You need a helper in your Sinatra application to reconstruct paths :
>>
>> helpers do
>> def path_to(path)
>> request.script_name + path
>> en
>> end
>>
>> and then use it in your templates :
>>
>> <a href='#{path_to('/page')}'>
>>
>> 2010/10/22 andyl <akl...@gmail.com>
>>
>>> I would like to use Rack to mount modular apps.
>>
>>> Using the 'map' statement in config.ru, I can mount an app just fine.
>>
>>> But - the links in my sub-apps don't work.
>>
>>> If I mount App1 on '/app1', and App1 has a link <a href='/page'>,
>>> it needs to render '/app1/page' instead of '/page'.
>>
>>> How do people get around this problem??
>>
>>> Thanks, Andy
>>
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-23 2:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-22 4:53 Links and Modular Apps andyl
2010-10-22 6:19 ` Sylvain Desvé
2010-10-23 0:13 ` andyl
2010-10-23 2:29 ` Yehuda Katz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).