Permalink
Browse files

More progress on getting the tutorial ready.

  • Loading branch information...
1 parent 0f329aa commit d789ff6be0f48e04559fb9166206475e92e99b18 @Raynes committed May 17, 2010
Showing with 33 additions and 22 deletions.
  1. +9 −6 resources/public/javascript/tryclojure.js
  2. +5 −16 src/tryclojure/core.clj
  3. +19 −0 src/tryclojure/tutorial.clj
@@ -2,8 +2,10 @@ function setupLink(url) {
return function(e) { $.get(url, function(data) { $("#changer").html(data); }); }
}
-function getStep(n) { //TODO
+function getStep(n) {
+ $.get("tutorial", { step: n }, function(data) { $("#tuttext").html(data); });
}
+
$(document).ready(
function() {
$("#console").console({
@@ -30,11 +32,12 @@ $(document).ready(
$("#about").click(setupLink("about"));
$("#links").click(setupLink("links"));
-
- var step = 0;
- $("#tutorial").click(function(e) {
- $.get("tutorial", function(data) { $("#changer").html(data); });
+ $("#tutorial").click(function(e) {
+ var step = 1;
+ $.get("tutorial", {step: 1}, function(data) { $("#changer").html(data); });
$("#continue").click(function(e) {
- // TODO
+ step += 1;
+ getStep(step);
+ });
});
});
@@ -5,7 +5,8 @@
[hiccup core form-helpers page-helpers]
[ring.middleware reload stacktrace params file session]
net.cgrand.moustache
- [clojure.stacktrace :only [root-cause]])
+ [clojure.stacktrace :only [root-cause]]
+ tryclojure.tutorial)
(:import java.io.StringWriter
org.apache.commons.lang.StringEscapeUtils
java.util.concurrent.TimeoutException
@@ -53,18 +54,6 @@
"Huge thanks to " (link-to "http://www.bestinclass.dk/" "Lau Jensen")
" for lots of help with everything ranging from Gimp, to straight up CSS and HTML design tips."]))
-(def tutorial
- (html
- [:div#tuttext
- [:p.bottom
- "This tutorial is intended for people who have never used Clojure before but are familiar"
- " with at least one other programming language. It's not intended to be a comprehensive tutorial"
- ", but to get you started with Clojure, and interested enough to continue." [:br] [:br]
- "Above, you have your REPL. I expect you to try out the examples as we go along, and to experiment"
- " with stuff on your own. If you don't, you will promptly be IP banned from this website, and I will"
- " murder you in your sleep." [:br] [:br] "Please try the examples. Don't make me kill you."]]
- [:div.continue [:input#continue {:type "button" :value "Next"}]]))
-
(def fire-html
(html
(:html4 doctype)
@@ -107,14 +96,14 @@
:headers {"Content-Type" "text/html"}
:body links})
-(defn tutorial-handler [reg]
+(defn tutorial-handler [{querys :query-params}]
{:status 200
:headers {"Content-Type" "text/html"}
- :body tutorial})
+ :body (get-tutorial (querys "step"))})
(def clojureroutes
(app
- (wrap-reload '(tryclojure.core))
+ (wrap-reload '(tryclojure.core tryclojure.tutorial))
(wrap-file (System/getProperty "user.dir"))
(wrap-params)
(wrap-stacktrace)
@@ -0,0 +1,19 @@
+(ns tryclojure.tutorial
+ (:use hiccup.core))
+
+(def tutorial
+ (html
+ [:div#tuttext
+ [:p.bottom
+ "This tutorial is intended for people who have never used Clojure before but are familiar"
+ " with at least one other programming language. It's not intended to be a comprehensive tutorial"
+ ", but to get you started with Clojure, and interested enough to continue." [:br] [:br]
+ "Above, you have your REPL. I expect you to try out the examples as we go along, and to experiment"
+ " with stuff on your own. If you don't, you will promptly be IP banned from this website, and I will"
+ " murder you in your sleep." [:br] [:br] "Please try the examples. Don't make me kill you."]]
+ [:div.continue [:input#continue {:type "button" :value "Next"}]]))
+
+(defn get-tutorial [step]
+ (condp = step
+ "1" tutorial
+ "2" "wtf"))

0 comments on commit d789ff6

Please sign in to comment.