Once again, fixed tests so they pass, although they don't actually

test anything useful.
This commit is contained in:
Simon Brooke 2014-07-07 19:55:14 +01:00
parent 257d306d5d
commit c0e5729c81
7 changed files with 75 additions and 34 deletions

View file

@ -18,11 +18,14 @@
[statekey]
(format "img/tiles/%s.png" (format-css-class statekey)))
(defn format-mouseover [cell]
(str "State " (:state cell) "; altitude: " (:altitude cell) "; fertility: " (:fertility cell)))
(defn render-cell
"Render this world cell as a Hiccup table cell."
[cell]
(let [state (:state cell)]
[:td {:class (format-css-class state)}
[:td {:class (format-css-class state) :title (format-mouseover cell)}
[:img {:alt (world/format-cell cell) :src (format-image-path state)}]]))
(defn render-world-row
@ -46,10 +49,11 @@
(session/put! :world w2)
(session/put! :generation generation)
[:div {:class "world"}
[:p (str "Generation " generation)]
(apply vector
(cons :table
(map render-world-row w2)))]))
(map render-world-row w2)))
[:p (str "Generation " generation)]]))
(defn render-world
"Render the world implied by the session as a complete HTML page."

View file

@ -7,24 +7,27 @@
[noir.session :as session]))
(defn home-page []
(layout/render
"home.html" {:title "Welcome to MicroWorld" :content (util/md->html "/md/docs.md")}))
(defn about-page []
(layout/render "about.html" {:title "About MicroWorld" :content (util/md->html "/md/about.md")}))
(defn world-page []
(layout/render "world.html" {:title "Watch your world grow"
:content (html (world/render-world-table))
:seconds (or (session/get :seconds) 5)
:maybe-refresh "refresh"}))
(defn about-page []
(layout/render "about.html" {:title "About MicroWorld" :content (util/md->html "/md/about.md")}))
(defn list-states []
(sort
(filter #(not (nil? %))
(map #(first (rest (re-matches #"([0-9a-z-]+).png" (.getName %))))
(file-seq (clojure.java.io/file "resources/public/img/tiles"))))))
(defn docs-page []
(layout/render "docs.html" {:title "Documentation"
:parser (util/md->html "/md/parser.md")
:states (list-states)
:components ["mw-engine" "mw-parser" "mw-ui"]}))
(defroutes home-routes
(GET "/" [] (home-page))
(GET "/about" [] (about-page))
(GET "/world" [] (world-page))
(GET "/docs" [] (docs-page)))