Permalink
Browse files

Merge branch 'hotfix/1.6.2'

  • Loading branch information...
2 parents 25fbe42 + 5aa276a commit 3655456ed7920dc83ce6f26febffccbce64717dd @amalloy amalloy committed Nov 22, 2011
View
@@ -1,4 +1,4 @@
-(defproject foreclojure "1.6.1"
+(defproject foreclojure "1.6.2"
:description "4clojure - a website for learning Clojure"
:dependencies [[clojure "1.2.1"]
[clojure-contrib "1.2.0"]
@@ -22,7 +22,8 @@ var CodeBox = {
this.setupEditor();
}
- this.submitButtons.live("click", $.proxy(this.run, this));
+ $("#run-button").live("click", $.proxy(this.run, this));
+ $("#submission-button").live("click", $.proxy(this.submitProblem, this));
},
setupEditor: function() {
@@ -58,6 +59,12 @@ var CodeBox = {
$("#code-div").toggle('fast');
},
+ submitProblem: function(e) {
+ e.preventDefault();
+ $("#code-box").val(this.getCode());
+ $("#code-box").closest("form").submit();
+ },
+
run: function(e) {
e.preventDefault();
@@ -14,4 +14,5 @@
(get-in config [:hosts key]))]
(def static-host (host :static))
(def dynamic-host (host :dynamic))
- (def redirect-hosts (host :redirects)))
+ (def redirect-hosts (host :redirects))
+ (def canonical-host (or dynamic-host "www.4clojure.com")))
View
@@ -57,18 +57,17 @@
handler/site
wrap-strip-trailing-slash))
-(let [canonical-host (or config/dynamic-host "www.4clojure.com")]
- (defn redirect-routes [request]
- (let [{:keys [scheme uri]} request
- proper-uri (str (name scheme)
- "://"
- canonical-host
- uri)]
- {:status 302
- :headers {"Location" proper-uri}
- :body (str "<a href='" proper-uri "'>"
- proper-uri
- "</a>")})))
+(defn redirect-routes [request]
+ (let [{:keys [scheme uri]} request
+ proper-uri (str (name scheme)
+ "://"
+ config/canonical-host
+ uri)]
+ {:status 302
+ :headers {"Location" proper-uri}
+ :body (str "<a href='" proper-uri "'>"
+ proper-uri
+ "</a>")}))
(def host-handlers (reduce into
{:default (routes dynamic-routes resource-routes)}
@@ -19,7 +19,6 @@
[hiccup.page-helpers :only [link-to]]
[hiccup.core :only [html]]
[useful.debug :only [?]]
- [amalloy.utils :only [defcomp]]
[compojure.core :only [defroutes GET POST]]))
(def solved-stats (agent {:total 0}))
@@ -305,6 +304,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
[:p#instruct "Code which fills in the blank: "]
(when (wants-no-javascript-codebox?) [:span#disable-javascript-codebox])
(text-area {:id "code-box"
+ :name "code"
:spellcheck "false"}
:code (escape-html
(or (session/flash-get :code)
@@ -11,10 +11,13 @@
(defn wrap-request-bindings [handler]
(fn [req]
(binding [*url* (:uri req)
- *host* (or (get-host req) "www.4clojure.com")
+ *host* (or (get-host req) config/canonical-host)
*http-scheme* (:scheme req)]
(handler req))))
-(def static-url (if-let [host config/static-host]
- #(str (name (or *http-scheme* :http)) "://" host "/" %)
- #(str "/" %)))
+(letfn [(url-fn [host]
+ (if host
+ #(str (name (or *http-scheme* :http)) "://" host "/" %)
+ #(str "/" %)))]
+ (def universal-url (url-fn (or config/static-host config/canonical-host)))
+ (def static-url (url-fn config/static-host)))
@@ -5,7 +5,7 @@
[cheshire.core :as json])
(:use [foreclojure.utils :only [from-mongo row-class rank-class get-user if-user with-user]]
[foreclojure.template :only [def-page content-page]]
- [foreclojure.ring-utils :only [*http-scheme* static-url]]
+ [foreclojure.ring-utils :only [*http-scheme* universal-url]]
[foreclojure.config :only [config repo-url]]
[somnium.congomongo :only [fetch-one fetch update!]]
[compojure.core :only [defroutes GET POST]]
@@ -73,7 +73,7 @@
(let [canonical-email (comp string/trim string/lower-case)
md5 #(DigestUtils/md5Hex %)
- as-url #(URLEncoder/encode (static-url %))
+ as-url #(URLEncoder/encode (universal-url %))
no-gravatar-url (as-url "images/no-gravatar.png")]
(defn gravatar-img [{:keys [email size class default] :or {size 24}}]
(let [hash (if email

0 comments on commit 3655456

Please sign in to comment.