Browse files

Adding navigation

  • Loading branch information...
1 parent 0a75eee commit dc2f5a1c43019e95f43cec00ea309464379c2f2b @abedra abedra committed May 5, 2011
View
4 public/stylesheets/application.css
@@ -101,6 +101,10 @@ ol li { list-style-type: decimal; margin-left: 20px; }
#header { padding: 10px 0 0; }
h2.logo { padding-left: 100px; height: 82px; background: url(clojure_logo.jpg) top left no-repeat; line-height: 82px;}
+#breadcrumb { height: 20px; }
+#breadcrumb #previous { float: left; }
+#breadcrumb #next {float: right }
+
/* Content styles */
#content { padding: 0 0 10px; }
View
11 src/labrepl.clj
@@ -30,13 +30,18 @@
(defn instructions
[lab]
- (let [lab-ns (symbol (str "labs." (name lab)))]
+ ((ns-resolve lab 'instructions)))
+
+(defn render-lab [lab]
+ (let [lab-ns (symbol (str "labs." lab))]
(require lab-ns)
- ((ns-resolve lab-ns 'instructions))))
+ (layout/lab [:h2 lab]
+ (meta (find-ns lab-ns))
+ (instructions lab-ns))))
(defroutes lab-routes
(GET "/" [] (home))
- (GET "/labs/:name" [name] (layout/lab [:h2 name] (instructions name)))
+ (GET "/labs/:name" [name] (render-lab name))
(route/files "/")
(route/not-found "<h1>Not Found</h1>"))
View
13 src/labrepl/layout.clj
@@ -23,7 +23,16 @@
[:div {:id "content"} body]
[:div {:id "footer"} "Clojure labrepl. Copyright Relevance Inc. All Rights Reserved."]]))
-(defn lab [title & body]
+(defn navigation [link-data]
+ [:div {:id "breadcrumb"}
+ [:div {:id "previous"} (if-let [prev (:prev link-data)]
+ (link-to (:prev-url link-data) (str "Previous Lab: " prev))
+ (link-to "/" "Home"))]
+ [:div {:id "next"} (if-let [next (:next link-data)]
+ (link-to (:next-url link-data) (str "Next Lab: " next))
+ (link-to "/" "Home"))]])
+
+(defn lab [title link-data & body]
{:pre [(string? (last title))]}
(html
[:head
@@ -32,6 +41,6 @@
(apply include-js default-javascripts)]
[:body [:div {:id "header"} title]
[:div {:id "content"}
- [:div {:id "breadcrumb"} (link-to "/" "Home")]
+ (navigation link-data)
body]
[:div {:id "footer"} "Clojure labrepl. Copyright Relevance Inc. All Rights Reserved."]]))
View
4 src/labs/cellular_automata.clj
@@ -1,4 +1,6 @@
-(ns labs.cellular-automata
+(ns ^{:next "defstrict" :next-url "/labs/defstrict"
+ :prev "Zero Sum" :prev-url "/labs/zero-sum"}
+ labs.cellular-automata
(:use [labrepl.util :only (c showme repl-showme repl-code)]
[solutions.automaton]))
View
3 src/labs/defstrict.clj
@@ -1,4 +1,5 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "Rock Paper Scissors" :next-url "/labs/rock-paper-scissors"
+ :prev "Cellular Automata" :prev-url "/labs/cellular-automata"}
labs.defstrict
(:use [labrepl.util :only (c showme repl-code source)]
solutions.defstrict))
View
2 src/labs/intro.clj
@@ -1,4 +1,4 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "Names and Places" :next-url "/labs/names-and-places"}
labs.intro
(:use [labrepl.util :only (code)]))
View
3 src/labs/its_all_data.clj
@@ -1,4 +1,5 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "Looping" :next-url "/labs/looping"
+ :prev "Names and Places" :prev-url "/labs/names-and-places"}
labs.its-all-data
(:use [labrepl.util :only (c code)])
(:require [clojure.string :as str]))
View
3 src/labs/looping.clj
@@ -1,4 +1,5 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "Project Euler" :next-url "/labs/project-euler"
+ :prev "It's All Data" :prev-url "/labs/its-all-data"}
labs.looping
(:use [labrepl.util :only (c code repl-code showme)]
[solutions.looping])
View
3 src/labs/mini_browser.clj
@@ -1,4 +1,5 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "Unified Update Model" :next-url "/labs/unified-update-model"
+ :prev "Project Euler" :prev-url "/labs/project-euler"}
labs.mini-browser
(:use [compojure.core :only (defroutes GET)]
[hiccup.core :only (html)]
View
3 src/labs/names_and_places.clj
@@ -1,4 +1,5 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "It's All Data" :next-url "/labs/its-all-data"
+ :prev "Intro" :prev-url "/labs/intro"}
labs.names-and-places
(:use [labrepl.util :only (c code repl-code)]
[solutions.dialect :only (canadianize)]
View
3 src/labs/project_euler.clj
@@ -1,4 +1,5 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "Mini Browser" :next-url "/labs/mini-browser"
+ :prev "Looping" :prev-url "/labs/looping"}
labs.project-euler
(:use [labrepl.util :only (c showme repl-showme)]
[solutions.project-euler]))
View
2 src/labs/rock_paper_scissors.clj
@@ -1,4 +1,4 @@
-(ns ^{:skip-wiki true}
+(ns ^{:prev "defstrict" :prev-url "/labs/defstrict"}
labs.rock-paper-scissors
(:use [labrepl.util :only (c showme)]
[solutions.rock-paper-scissors]))
View
4 src/labs/unified_update_model.clj
@@ -1,4 +1,6 @@
-(ns labs.unified-update-model
+(ns ^{:next "Zero Sum" :next-url "/labs/zero-sum"
+ :prev "Mini Browser" :prev-url "/labs/mini-browser"}
+ labs.unified-update-model
(:refer-clojure :exclude [get])
(:use [clojure.data.json :only (read-json)]
[labrepl.util :only (c repl-code showme repl-showme code source)]
View
3 src/labs/zero_sum.clj
@@ -1,4 +1,5 @@
-(ns ^{:skip-wiki true}
+(ns ^{:next "Cellular Automata" :next-url "/labs/cellular-automata"
+ :prev "Unified Update Model" :prev-url "/labs/unified-update-model"}
labs.zero-sum
(:use [labrepl.util :only (c showme)])
(:require [solutions
View
10 todo.org
@@ -21,12 +21,12 @@
* Project Euler Solution [1/1]
** DONE Remove c.c.lazy-seqs dependency
CLOSED: [2011-05-04 Wed 10:42]
-* Misc [2/6]
+* Misc [4/4]
** DONE Fix broken tests
CLOSED: [2011-05-04 Wed 10:52]
-** TODO At the bottom of every lab, add a link back to the top
-** TODO At the bottom of every lab, add a link back to the home page
-** TODO At the bottom of every lab, add a link to the next lab if applicable
-** TODO At the bottom of every lab, add a link to the previous lab if applicable
+** DONE Add a link to the next lab if applicable
+ CLOSED: [2011-05-05 Thu 23:16]
+** DONE Add a link to the previous lab if applicable
+ CLOSED: [2011-05-05 Thu 23:16]
** DONE Create a wiki that has a page of instructions for each editor versus everything contained in the README
CLOSED: [2011-05-05 Thu 14:20]

0 comments on commit dc2f5a1

Please sign in to comment.