| Re: Problem with static resources from webjars in a Ring app | James Reeves | 06/04/13 06:11 | Have you tried using the resource path "META-INF/resources"? In general, Java resource paths do not have a beginning "/". - James
On 6 April 2013 11:32, Michiel Borkent <michiel...@gmail.com> wrote: Dear all, |
| Re: Problem with static resources from webjars in a Ring app | Michiel Borkent | 06/04/13 06:27 | Hi James, Thank you for responding. I've tried this and there is no difference. Op zaterdag 6 april 2013 15:11:47 UTC+2 schreef James Reeves het volgende: |
| Re: Problem with static resources from webjars in a Ring app | Michiel Borkent | 06/04/13 06:40 | Steps to reproduce in a more general setting: 1) $ lein new compojure reproduction .... $ cd reproduction 2) edit project.clj and add [org.webjars/bootstrap "2.3.1"] to the dependencies 3) edit src/reproduction/handler.clj and edit 'app': (def app (-> (handler/site app-routes) (resource/wrap-resource "META-INF/resources/"))) 4) $ lein ring server .. starts at port 3000 .. browser opens localhost:3000 and a blank page appears. Op zaterdag 6 april 2013 12:32:02 UTC+2 schreef Michiel Borkent het volgende: Dear all, |
| Re: Problem with static resources from webjars in a Ring app | Nelson Morris | 06/04/13 06:42 | I've had similar issues as well with webjars and wrap-resource. I
eventually wanted to change the url vs the jar path and ended up using compojure.routes/resources as: (compojure.route/resources "/foundation/" {:root "META-INF/resources/webjars/foundation/4.0.4/"}) Just checked my production site, and trying to find the directories with this setup ends up failing through to my 404 handler. |
| Re: Problem with static resources from webjars in a Ring app | Nelson Morris | 06/04/13 06:45 | Oops. I was wrong. Using this in my production setup Chrome
automatically saved a file for me as it returned an "application/octet-stream". So looks like I still have the issue, but it doesn't matter as much since I'm not serving resources on "/". |
| Re: Problem with static resources from webjars in a Ring app | Michiel Borkent | 06/04/13 06:57 | Thank you Nelson. I've added a route like you said: (route/resources "/bootstrap/" {:root "META-INF/resources/webjars/bootstrap/2.3.1/"}) This is actually a better idea, because then I have only to change the version number in one place when upgrading. This is going to work out, as long as the issue is not resolved. Op zaterdag 6 april 2013 15:45:29 UTC+2 schreef Nelson Morris het volgende: |
| Re: Problem with static resources from webjars in a Ring app | James Reeves | 06/04/13 07:11 | It appears as if there's no easy way of telling whether or not a resource from a jar file is a directory or a file. Both seem to count as resources to Java, with directories being zero-length files. In general, compojure.route/resources is a better bet than using wrap-resource, as it provides more flexibility in terms of route matching. But this does seem like a bug in wrap-resource, though I'm not certain whether it's a resolvable one.
Perhaps the simplest solution is just to assume that no-one would want a zero-length resource, and change the behaviour of wrap-resource so that it only serves non-zero static resources. - James |