Permalink
Browse files

Merge commit 'v0.3.1'

  • Loading branch information...
2 parents 2735985 + 20e5cc2 commit 1ca94b56b23da2f226839aed72368d1e5a55d479 @dbyrne dbyrne committed May 17, 2011
Showing with 14 additions and 10 deletions.
  1. +1 −1 project.clj
  2. +13 −9 src/foreclojure/problems.clj
View
2 project.clj
@@ -1,4 +1,4 @@
-(defproject foreclojure "0.3.0"
+(defproject foreclojure "0.3.1"
:description "4clojure - a website for lisp beginners"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.2.0"]
View
22 src/foreclojure/problems.clj
@@ -285,26 +285,28 @@
(def-page problem-submission-page []
[:div.instructions
- [:p "Thanks for choosing to submit a problem. Please make sure that you own the rights to the code you are submitting and that you wouldn't mind having us use the code as a 4clojure problem."]]
+ [:p "Thanks for choosing to submit a problem. Please make sure that you own the rights to the code you are submitting and that you wouldn't mind having us use the code as a 4clojure problem. Once you've submitted your problem, it won't appear on the site until someone from the 4clojure team has had a chance to review it."]]
(form-to {:id "problem-submission"} [:post "/problems/submit"]
(hidden-field :author (session/flash-get :author))
(hidden-field :prob-id (session/flash-get :prob-id))
(label :title "Problem Title")
(text-field :title (session/flash-get :title))
(label :tags "Tags (space separated)")
(text-field :tags (session/flash-get :tags))
+ (label :restricted "Restricted Functions (space separated)")
+ (text-field :restricted (session/flash-get :restricted))
(label :description "Problem Description")
(text-area {:id "problem-description"} :description (session/flash-get :description))
[:br]
- (label :code-box "Problem test cases. Use two underscores (__) for user input. Multiple tests ought to be on one line each.")
+ (label :code-box "Problem test cases. Use two underscores (__) for user input. Individual tests can span multiple lines, but each test should be separated by a totally blank line.")
(text-area {:id "code-box" :spellcheck "false"}
:code (session/flash-get :tests))
[:p
[:button.large {:id "run-button" :type "submit"} "Submit"]]))
(defn create-problem
"create a user submitted problem"
- [title tags description code id author]
+ [title tags restricted description code id author]
(let [user (session/session-get :user)]
(if (can-submit? user)
(let [prob-id (or id
@@ -319,21 +321,23 @@
:title title
:times-solved 0
:description description
- :tags (s/split tags #"\s+")
- :tests (s/split-lines code)
+ :tags (re-seq #"\S+" tags)
+ :restricted (re-seq #"\S+" restricted)
+ :tests (s/split code #"\r\n\r\n")
:user (if (empty? author) user author)
:approved false})
(flash-msg "Thank you for submitting a problem! Be sure to check back to see it posted." "/problems"))
(flash-error "You are not authorized to submit a problem." "/problems"))))
(defn edit-problem [id]
- (let [{:keys [title user tags description tests]} (get-problem id)]
+ (let [{:keys [title user tags restricted description tests]} (get-problem id)]
(doseq [[k v] {:prob-id id
:author user
:title title
:tags (s/join " " tags)
+ :restricted (s/join " " restricted)
:description description
- :tests (s/join "\n" tests)}]
+ :tests (s/join "\r\n\r\n" tests)}]
(session/flash-put! k v))
(response/redirect "/problems/submit")))
@@ -373,8 +377,8 @@
(GET "/problems" [] (problem-page))
(GET "/problem/:id" [id] (code-box id))
(GET "/problems/submit" [] (problem-submission-page))
- (POST "/problems/submit" [prob-id author title tags description code]
- (create-problem title tags description code (when (not= "" prob-id) (Integer. prob-id)) author))
+ (POST "/problems/submit" [prob-id author title tags restricted description code]
+ (create-problem title tags restricted description code (when (not= "" prob-id) (Integer. prob-id)) author))
(GET "/problems/unapproved" [] (unapproved-problems))
(POST "/problem/edit" [id]
(edit-problem (Integer. id)))

0 comments on commit 1ca94b5

Please sign in to comment.