Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Organize labs for April 2011 training.

  • Loading branch information...
commit cad05b443843ce0d72ce8469c586795a12f059a9 1 parent 3ffe768
@trptcolin authored
Showing with 32 additions and 12 deletions.
  1. +1 −0  project.clj
  2. +21 −9 src/labrepl.clj
  3. +10 −3 src/labrepl/lab.clj
View
1  project.clj
@@ -2,6 +2,7 @@
:description "Clojure exercises, with integrated repl and webapp"
:dependencies [[org.clojure/clojure "1.2.1"]
[compojure "0.6.2"]
+ [ring/ring-devel "0.2.5"]
[ring/ring-jetty-adapter "0.3.7"]
[hiccup "0.3.4"]
[postgresql "9.0-801.jdbc4"]
View
30 src/labrepl.clj
@@ -6,9 +6,10 @@
hiccup.core
hiccup.page-helpers
ring.adapter.jetty
+ [ring.middleware.reload :only [wrap-reload]]
clojure.contrib.logging)
(:require [compojure.route :as route]
- [labrepl.lab :as lab]
+ [labrepl.lab :as lab] :reload
[solutions.mini-browser :as mini-browser]))
(defn with-logging [handler]
@@ -23,13 +24,22 @@
response))))
(defroutes lab-routes
- (GET "/" [] (html
- (lab/layout
- [:h2.logo "Clojure Labs"]
- [:ul
- (map
- (fn [lab] [:li (lab/make-url lab)])
- (lab/all))])))
+ (GET "/" [] (let [show-labs (fn [labs]
+ (map (fn [lab] [:li (lab/make-url lab)])
+ labs))]
+ (html
+ (lab/layout
+ [:h2.logo "Clojure Labs"]
+ [:h3 "Core labs"]
+ [:ul
+ (show-labs (lab/all))]
+ [:h3 "Choose your own adventure"]
+ [:ul
+ (show-labs (lab/optional))]
+ [:h3 "Extras (mostly review)"]
+ [:ul
+ (show-labs (lab/review))]
+ ))))
(GET "/labs/:name" [name] (html
(lab/layout
[:h2 name]
@@ -39,7 +49,9 @@
(route/files "/")
(route/not-found "<h1>Not Found</h1>"))
-(def full-routes (-> lab-routes with-logging))
+(def full-routes (-> lab-routes
+ (wrap-reload '[labrepl])
+ with-logging))
(defroutes app
(routes full-routes static-routes))
View
13 src/labrepl/lab.clj
@@ -5,9 +5,16 @@
(defn all
[]
- [:intro :names-and-places :its-all-data :looping :project-euler
- :mini-browser :unified-update-model :zero-sum :cellular-automata
- :defstrict :rock-paper-scissors])
+ [:names-and-places :looping :rock-paper-scissors
+ :project-euler :unified-update-model])
+
+(defn review
+ []
+ [:intro :its-all-data])
+
+(defn optional
+ []
+ [:mini-browser :zero-sum :cellular-automata :defstrict])
(defn lab-url
[lab-name]
Please sign in to comment.
Something went wrong with that request. Please try again.