On Wed, Sep 28, 2011 at 1:22 PM, Brian E. Lozier
<brian@massassi.com> wrote:
On Wed, Sep 28, 2011 at 1:17 PM, Assaf Gordon
<gordon@cshl.edu> wrote:
Brian E. Lozier wrote, On 09/28/2011 04:14 PM:
>
>
> On Wed, Sep 28, 2011 at 1:07 PM, Assaf Gordon <
gordon@cshl.edu <mailto:
gordon@cshl.edu>> wrote:
>
> Has anyone been able to deploy a Dancer application *not* under the server's root URL,
> without changing code/templates in the Dancer application itself ?
>
> The only thing I can think of is to rewrite the html on the way out such that all calls to /images/ get the prefix. The problem is that all your templates are hard coding a path to a resource on the server. You're telling the browser what resource to request and you're giving it an "absolute" path. You could also give them "relative" paths such as:
>
> <img src="images/foo.png">
>
> Which will work fine as long as you don't have any routes that are deeper.
>
> Why don't you just have a configuration parameter in your config file that says "path" and then use that instead of "[% request.uri_base %]"? I don't quite get why you're using uri_base anyway. All you have to do is say:
This configuration parameter is exactly what started this thread (The app-wide "prefix" setting - in the subject line) :)
And I keep learning that it's a bad idea, but haven't yet understood how to do it without such parameter.
I'm suggesting creating a new config variable for your apps, not reusing the prefix one. Although I'm not sure why you wouldn't want to use the prefix one, I'll go back and read the beginnings of the thread.
I read the thread, you said:
"Obviously, one can edit every template file to make sure the URL has the application's prefix.
But it's an ugly hard-coded solution, and requires synchronization
between the perl code's "prefix" and the template's hardocded URLs.
I want an application-wide "prefix" setting (in the config file, or similar), that would affect every part of the application."
I think your best option is to either make your own config variable and put that in every template. You don't have to synchronize the templates and prefix setting, you only have to synchronize the new config variable you make and the prefix setting.