Apologies for the short answer/wild guess, but perhaps try
(include-css "/css/test-app.css")
Notice the leading / so that the path is always from the
root instead of relative, which might explain why you were
having problems with routes that had a path deeper than 1.
Cheers,
Fred
On Wed, Apr 10, 2013, at 12:11 AM, Matt Anderson wrote:
I'm new here and have appreciated the archived answers as I learn by
working on a compojure application. I apologize if this is a newby
question, but after several hours of experimentation, I can't figure
out why resources are being served with reference to
resources/public on some routes, but not others, when the routes are
being wrapped at the same time.
These are dummy routes for now. I'm trying to make sure I have the
pieces wired up and working before going further.
I've defined two sets of routes, common-routes and group-routes to
understand how compojure routes are handled..
(defroutes common-routes
(GET "/" {:keys [uri request-method] :as req}
(test-page req))
(GET "/profile" {:keys [uri] :as req}
(profile req))
(GET "/profile/:id" {:keys [uri request-method id] :as req}
(profile-form id req)))
(defroutes group-admin-routes
(GET "/admin/groups" [req]
(groups-index req))
(GET "/admin/groups/create" [req]
(groups-create req))
(POST "/admin/groups/create" [m] (""))
(GET "/admin/groups/edit/:id" [id]
(layout [:h1 "Edit Group"])))
The handler functions all call the same layout function.
(defn base-layout [{:keys [title css js] :as attr-map :or {}} & body]
(html5
[:head
[:title "Test App")]
(include-css "css/test-app.css") –
[:body body]))
The routes are referenced in the route stack:
(def app
(-> (routes group-admin-routes
common-routes
(route/resources "/")
(route/not-found "404: Not Found"))
#_(wrap-file "resources/public")
(wrap-reload '(test-app.views.common)
'(test-app.views.groups))
(handler/site)
(wrap-strip-trailing-slash)))
When I run the app (using jetty, ring-serve, or deployed to cloudbees),
some pages pull in the css file, while others do not. Specifically,
given a URI of "/" or "/profile", the request for /css… is rerouted to
resources/public/css and the layout is styled. For all the group routes
and "/profile/:id" in common-routes, the css reference is not rerouted
and browser inspection of the http request shows that it's taken as
relative to the URL. The HTML for css inclusion and the links created
by the layout function are identical for each page. I've tried
"wrap-file", making the root specific with either "public" or
"resources/public" in the route/resources call, and other experiments
without success.
Do you have any idea what the problem might be?
Thanks in advance for your patience and help …
--
You received this message because you are subscribed to the Google
Groups "Compojure" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to
compojure+...@googlegroups.com.
To post to this group, send email to
comp...@googlegroups.com.
Visit this group at
[1]
http://groups.google.com/group/compojure?hl=en.
For more options, visit [2]
https://groups.google.com/groups/opt_out.
References
1.
http://groups.google.com/group/compojure?hl=en
2.
https://groups.google.com/groups/opt_out