forked from hlship/cascade
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Reorganize cascade.request/initialize to take a handler function for …
…HTML routes as a parameter Change deftemplate to return a Ring response map Allow '-' inside implicit id and class attribute defined from a keyword Implement CSS asset importing
- Loading branch information
Showing
7 changed files
with
115 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
(ns main | ||
(:use compojure.core cascade cascade.asset ring.adapter.jetty) | ||
(:use compojure.core cascade cascade.asset cascade.import ring.adapter.jetty) | ||
(:require | ||
[cascade.request :as cr] | ||
[compojure.route :as route] | ||
[compojure.handler :as handler])) | ||
|
||
(set! *warn-on-reflection* true) | ||
|
||
(defview hello-world [request] | ||
:html | ||
[:head [:title ["Cascade Hello World"] | ||
(stylesheet (file-asset "css/bootstrap.css")) | ||
(stylesheet (classpath-asset "cascade/cascade.css"))] | ||
:body [ | ||
:h1 ["Hello World"] | ||
:p [ | ||
"The page rendered at " | ||
:em [(str (java.util.Date.))] | ||
"." | ||
] | ||
:p [ | ||
:a {:href "/hello"} ["click to refresh"] | ||
(defn layout [req title body] | ||
(import-stylesheet req (file-asset "css/bootstrap.css")) | ||
(import-stylesheet req (classpath-asset "cascade/cascade.css")) | ||
(template | ||
:html [ | ||
:head [:title [title]] | ||
:body [ | ||
:div.container [ | ||
:h1 [title] | ||
body | ||
:hr | ||
:© " 2011 Howard M. Lewis Ship" | ||
]]])) | ||
|
||
(defview hello-world [req] | ||
(layout req "Cascade Hello World" | ||
(template | ||
:div.alert-message.success [ | ||
:p ["This page rendered at " | ||
:strong [(str (java.util.Date.))] | ||
"." | ||
] | ||
] | ||
]]) | ||
:p [ | ||
:a.btn.primary.large {:href "/hello"} ["Refresh"] | ||
]))) | ||
|
||
(defroutes html-routes | ||
(GET "/hello" [] hello-world)) | ||
|
||
(defroutes main-routes | ||
(defroutes master-routes | ||
; Temporary: eventually we'll pass a couple of routes | ||
;; into cr/initialize | ||
(GET "/hello" [] (cr/wrap-html hello-world)) | ||
(cr/initialize "1.0" :public-folder "src/test/webapp") | ||
(cr/initialize "1.0" | ||
:public-folder "src/test/webapp" | ||
:html-routes html-routes) | ||
(route/not-found "Cascade Demo: No such resource")) | ||
|
||
(def app | ||
(handler/site main-routes)) | ||
(handler/site master-routes)) | ||
|
||
(run-jetty app {:port 8080}) |