Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to mount Jingo on a URL path #124

Closed
claudioc opened this issue Dec 14, 2015 · 7 comments
Closed

Add the ability to mount Jingo on a URL path #124

claudioc opened this issue Dec 14, 2015 · 7 comments

Comments

@claudioc
Copy link
Owner

There are use cases where Jingo lives behind a reverse proxy for a single path, like in mywebsite.com/wiki and wiki is proxy_passed by nginx to jingo. At the moment it seems impossible (as for the example goes) to instruct jingo to use /wiki as its "base" so that its assets are relative to that one (like /wiki/style.css).

It would be probably possible to hack something similar to what WordPress does with its WP_SITEURL configuration directive

@claudioc claudioc changed the title Add the ability mount Jingo on a URL path Add the ability to mount Jingo on a URL path Dec 14, 2015
@creynold
Copy link

I can't think of a way of doing this other than prefixing all URLs in the templates with a #{mountpath} and defining this mountpath in the config file. This seems rather ugly. Is there some way to prefix all urls in Jade?

@claudioc
Copy link
Owner Author

I see two solutions:

  1. Verify if passing the mount point to express.static (in lib/app.js) would solve this issue right away (see http://expressjs.com/en/starter/static-files.html)
  2. Create a cssAsset and jsAsset mixins which will create a link or a script jade tag taking care of the mountpath.

So, instead of

    link(rel="stylesheet", href="/css/ionicons.min.css")
    link(rel="stylesheet", href="/css/shCoreDefault.css")

one could write

    cssAsset("onicons.min.css")
    cssAsset("shCoreDefault.css")

@creynold
Copy link

Solution 1 wouldn't work, unfortunately, (at least as-is) because the assets linked on the layout.jade file point to for example href="/css/style.css". This root-relative url still needs to be prepended with the application mount-point.

I'm working on solution 2 as we speak.

@claudioc
Copy link
Owner Author

I see.

What about asset('onicons.min', 'css'), or even sniffing the extension? (cssAsset is a bit lame :P)

@creynold
Copy link

Yeah, I agree. I can change that

@creynold
Copy link

Ok I pushed a mixin called asset which sniffs the extension and renders the appropriate tag.

@claudioc
Copy link
Owner Author

Released with 1.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants