Skip to content
This repository

Update to 1.4 and add some clojail stuff #218

Merged
merged 5 commits into from almost 2 years ago

2 participants

Anthony Grimes Alan Malloy
Anthony Grimes
Collaborator
Raynes commented June 28, 2012

No description provided.

Alan Malloy
Owner

Sexy shit, man. Thanks for being the one to finally get us off 1.2, and being off sandbar is a relief too. I'll call this 2.0-alpha1 and see if it floats.

Alan Malloy amalloy merged commit d7f45fe into from June 29, 2012
Alan Malloy amalloy closed this June 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 5 unique commits by 1 author.

Jun 28, 2012
Anthony Grimes Add target to .gitignore. 770309f
Anthony Grimes Upgrade dependencies and move to Clojure 1.4.
Use data.xml instead of clojure contrib and blanket blacklist a bunch of nasty
namespaces with the new version of Clojail.
5e6af1b
Anthony Grimes Update innuendo. 7dceac7
Jun 29, 2012
Anthony Grimes Use useful.config instead of clj-config (one less dependency). 9da4a90
Anthony Grimes Update innuendo. b927b8d
This page is out of date. Refresh to see the latest.
3  .gitignore
@@ -10,4 +10,5 @@ pom.xml
10 10
 .DS_Store
11 11
 .#*
12 12
 .emacs-project
13  
-.lein-failures
  13
+.lein-failures
  14
+target
39  project.clj
... ...
@@ -1,27 +1,26 @@
1 1
 (defproject foreclojure "1.8.1"
2 2
   :description "4clojure - a website for learning Clojure"
3  
-  :dependencies [[clojure "1.2.1"]
4  
-                 [clojure-contrib "1.2.0"]
5  
-                 [compojure "0.6.2"]
6  
-                 [hiccup "0.3.6"]
7  
-                 [clojail "0.5.1"]
8  
-                 [sandbar "0.4.0-SNAPSHOT"]
9  
-                 [org.clojars.christophermaier/congomongo "0.1.4-SNAPSHOT"]
  3
+  :dependencies [[org.clojure/clojure "1.4.0"]
  4
+                 [compojure "1.1.0"]
  5
+                 [hiccup "1.0.0"]
  6
+                 [clojail "0.6.0"]
  7
+                 [lib-noir "0.1.1"]
  8
+                 [congomongo "0.1.9"]
10 9
                  [org.jasypt/jasypt "1.7"]
11  
-                 [cheshire "2.0.2"]
12  
-                 [useful "0.7.0-beta5"]
13  
-                 [amalloy/ring-gzip-middleware "[0.1.0,)"]
14  
-                 [amalloy/mongo-session "0.0.1"]
15  
-                 [innuendo "0.1.1"]
16  
-                 [ring "0.3.7"]
17  
-                 [clj-config "0.1.0"]
18  
-                 [incanter/incanter-core "1.2.3"]
19  
-                 [incanter/incanter-charts "1.2.3"]
  10
+                 [cheshire "4.0.0"]
  11
+                 [useful "0.8.3-alpha4"]
  12
+                 [amalloy/ring-gzip-middleware "0.1.2"]
  13
+                 [amalloy/mongo-session "0.0.2"]
  14
+                 [innuendo "0.1.6"]
  15
+                 [ring "1.1.1"]
  16
+                 [incanter/incanter-core "1.3.0"]
  17
+                 [incanter/incanter-charts "1.3.0"]
20 18
                  [commons-lang "2.6"]
21  
-                 [org.apache.commons/commons-email "1.2"]]
22  
-  :dev-dependencies [[lein-ring "0.4.5"]
23  
-                     [midje "1.3.0"]]
24  
-  :checksum-deps true
  19
+                 [org.apache.commons/commons-email "1.2"]
  20
+                 [org.clojure/data.xml "0.0.5"]]
  21
+  :plugins [[lein-ring "0.7.1"]]
  22
+  :profiles {:dev {:dependencies [[midje "1.3.0" :exclusions [org.clojure/clojure]]]}}
  23
+  :checksum-deps true   
25 24
   :main foreclojure.core
26 25
   :ring {:handler foreclojure.core/app
27 26
          :init foreclojure.mongo/prepare-mongo})
0  config.clj → resources/config.clj
File renamed without changes
8  src/foreclojure/config.clj
... ...
@@ -1,10 +1,8 @@
1 1
 (ns foreclojure.config
2  
-  (:use [clojure.java.io :only [file]]
3  
-        [clj-config.core :only [safely read-config]]))
  2
+  (:require [clojure.java.io :refer [file]]
  3
+            [useful.config :refer [load-config]]))
4 4
 
5  
-(def config-file (file (System/getProperty "user.dir") "config.clj"))
6  
-
7  
-(def config (safely read-config config-file))
  5
+(def config (load-config "config.clj"))
8 6
 
9 7
 ;; Defs both for convenience and compile-time verification of simple settings
10 8
 (def repo-url (or (:repo-url config)
7  src/foreclojure/core.clj
@@ -2,7 +2,7 @@
2 2
   (:require [compojure.route            :as   route]
3 3
             [compojure.handler          :as   handler]
4 4
             [foreclojure.config         :as   config]
5  
-            [sandbar.stateful-session   :as   session])
  5
+            [noir.session               :as   session])
6 6
   (:import  [java.lang                  OutOfMemoryError])
7 7
   (:use     [compojure.core             :only [defroutes routes GET]]
8 8
             [foreclojure.static         :only [static-routes welcome-page]]
@@ -29,7 +29,7 @@
29 29
             [ring.middleware.gzip       :only [wrap-gzip]]
30 30
             [mongo-session.core         :only [mongo-session]]))
31 31
 
32  
-(def *block-server* false)
  32
+(def ^:dynamic *block-server* false)
33 33
 
34 34
 (defroutes resource-routes
35 35
   (-> (resources "/*")
@@ -54,7 +54,8 @@
54 54
       ((if (:wrap-reload config)
55 55
          #(wrap-reload % '(foreclojure.core))
56 56
          identity))
57  
-      (session/wrap-stateful-session {:store (mongo-session :sessions)})
  57
+      session/wrap-noir-flash
  58
+      (session/wrap-noir-session {:store (mongo-session :sessions)})
58 59
       wrap-request-bindings
59 60
       handler/site
60 61
       wrap-strip-trailing-slash))
51  src/foreclojure/feeds.clj
... ...
@@ -1,43 +1,30 @@
1 1
 (ns foreclojure.feeds
2  
-  (:use [clojure.contrib.prxml :only [prxml]]))
3  
-
4  
-(defn escape [x]
5  
-  (str "<![CDATA[" x "]>"))
  2
+  (:require [clojure.data.xml :refer [emit-str element]]))
6 3
 
7 4
 (defn create-feed
8  
-  "Creates a feed with title, link, description, a link to the location of the feed itself, and is populated with a collection of items in the following format:
9  
-
10  
-  [:item [:guid \"http://example.com/location/of/item/1\"]
11  
-         [:title \"Title of Item\"]
12  
-         [:description \"Description of Item\"]]"
  5
+  "Creates a feed with title, link, description, a link to the location
  6
+   of the feed itself, and is populated with a collection of items in the
  7
+   following format:
  8
+
  9
+   (element :item
  10
+     (element :guid \"http://example.com/location/of/item/1\")
  11
+     (element :title \"Title of Item\")
  12
+     (element :description \"Description of Item\"))"
13 13
   [feed-title feed-link feed-description resource-link items]
14  
-  (with-out-str
15  
-    (prxml [:decl! {:version "1.0"}]
16  
-           [:rss {:version "2.0"
  14
+  (emit-str
  15
+   (element :rss {:version "2.0"
17 16
                   :xmlns:atom "http://www.w3.org/2005/Atom"}
18  
-            [:channel
19  
-             [:atom:link
20  
-              {:href resource-link
21  
-               :rel "self"
22  
-               :type "application/rss+xml"}]
23  
-             [:title feed-title]
24  
-             [:link feed-link]
25  
-             [:description (escape feed-description)]
26  
-             items]])))
  17
+     (apply element :channel {}
  18
+       (element :atom:link {:href resource-link
  19
+                            :rel "self"
  20
+                            :type "application/rss+xml"})
  21
+       (element :title {} feed-title)
  22
+       (element :link {} feed-link)
  23
+       (element :descrption {} feed-description)
  24
+       items))))
27 25
 
28 26
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29 27
 
30  
-;; Example Feed
31  
-(comment
32  
-  (defn problem-feed [n]
33  
-    (reduce (fn [feed v]
34  
-              (conj feed [:item
35  
-                          [:guid (str "http://4clojure.com/problem/" (:_id v))]
36  
-                          [:title (:title v)]
37  
-                          [:description (:description v)]]))
38  
-            () (get-recent-problems n))))
39  
-
40  
-
41 28
 ;; Testing Validity
42 29
 ;; Paste the resulting test.xml file into the w3c validator
43 30
 ;; to verify your feed is valid.
8  src/foreclojure/golf.clj
... ...
@@ -1,8 +1,8 @@
1 1
 (ns foreclojure.golf
2 2
   (:require [ring.util.response       :as   response]
3  
-            [sandbar.stateful-session :as   session])
4  
-  (:use     [hiccup.form-helpers      :only [form-to check-box]]
5  
-            [hiccup.page-helpers      :only [link-to]]
  3
+            [noir.session             :as   session])
  4
+  (:use     [hiccup.form              :only [form-to check-box]]
  5
+            [hiccup.element           :only [link-to]]
6 6
             [foreclojure.utils        :only [with-user]]
7 7
             [foreclojure.template     :only [def-page content-page]]
8 8
             [foreclojure.users        :only [golfer?]]
@@ -54,7 +54,7 @@
54 54
 
55 55
   (GET "/league" []
56 56
     (comment ;; be smarter somehow in future. not sure what the right UI is, atm
57  
-     (if-let [username (session/session-get :user)]
  57
+     (if-let [username (session/get :user)]
58 58
        (let [user-obj (get-user username)]
59 59
          (if-not (golfer? user-obj)
60 60
            (response/redirect "/leag")))))
16  src/foreclojure/login.clj
... ...
@@ -1,8 +1,8 @@
1 1
 (ns foreclojure.login
2  
-  (:require [sandbar.stateful-session :as   session]
  2
+  (:require [noir.session             :as   session]
3 3
             [ring.util.response       :as   response])
4 4
   (:import  [org.jasypt.util.password StrongPasswordEncryptor])
5  
-  (:use     [hiccup.form-helpers      :only [form-to label text-field password-field check-box]]
  5
+  (:use     [hiccup.form              :only [form-to label text-field password-field check-box]]
6 6
             [foreclojure.utils        :only [from-mongo flash-error flash-msg form-row assuming send-email login-url]]
7 7
             [foreclojure.template     :only [def-page content-page]]
8 8
             [foreclojure.messages     :only [err-msg]]
@@ -33,7 +33,7 @@
33 33
 
34 34
 (def-page my-login-page [location]
35 35
   (do
36  
-    (if location (session/session-put! :login-to location))
  36
+    (if location (session/put! :login-to location))
37 37
     {:title "4clojure - login"
38 38
      :content
39 39
      (content-page
@@ -42,13 +42,13 @@
42 42
 (defn do-login [user pwd]
43 43
   (let [user (.toLowerCase user)
44 44
         {db-pwd :pwd} (from-mongo (fetch-one :users :where {:user user}))
45  
-        location (session/session-get :login-to)]
  45
+        location (session/get :login-to)]
46 46
     (if (and db-pwd (.checkPassword (StrongPasswordEncryptor.) pwd db-pwd))
47 47
       (do (update! :users {:user user}
48 48
                    {:$set {:last-login (java.util.Date.)}}
49 49
                    :upsert false) ; never create new users accidentally
50  
-          (session/session-put! :user user)
51  
-          (session/session-delete-key! :login-to)
  50
+          (session/put! :user user)
  51
+          (session/remove! :login-to)
52 52
           (response/redirect (or location "/problems")))
53 53
       (flash-error "/login" "Error logging in."))))
54 54
 
@@ -106,7 +106,7 @@
106 106
                                             :only [:_id :user])]
107 107
     (let [{:keys [success] :as diagnostics} (try-to-email email name id)]
108 108
       (if success
109  
-        (do (session/session-put! :login-to password-reset-url)
  109
+        (do (session/put! :login-to password-reset-url)
110 110
             (flash-msg (login-url password-reset-url)
111 111
               "Your password has been reset! You should receive an email soon."))
112 112
         (do (spit (str name ".pwd") diagnostics)
@@ -125,5 +125,5 @@
125 125
     (do-reset-password! email))
126 126
 
127 127
   (GET "/logout" []
128  
-    (do (session/session-delete-key! :user)
  128
+    (do (session/remove! :user)
129 129
         (response/redirect "/"))))
68  src/foreclojure/problems.clj
... ...
@@ -1,9 +1,10 @@
1 1
 (ns foreclojure.problems
2 2
   (:require [foreclojure.users        :as      users]
3  
-            [sandbar.stateful-session :as      session]
  3
+            [noir.session             :as      session]
4 4
             [clojure.string           :as      s]
5 5
             [ring.util.response       :as      response]
6  
-            [cheshire.core            :as      json])
  6
+            [cheshire.core            :as      json]
  7
+            [clojure.data.xml         :refer   [element]])
7 8
   (:import  [org.apache.commons.mail  EmailException])
8 9
   (:use     [foreclojure.utils        :only    [from-mongo get-user get-solved login-link flash-msg flash-error row-class approver? can-submit? send-email image-builder if-user with-user as-int maybe-update escape-html]]
9 10
             [foreclojure.ring-utils   :only    [*url*]]
@@ -13,10 +14,10 @@
13 14
             [foreclojure.users        :only    [golfer? get-user-id disable-codebox?]]
14 15
             [foreclojure.solutions    :only    [save-solution get-solution]]
15 16
             [clojail.core             :exclude [safe-read]]
16  
-            [clojail.testers          :only    [secure-tester]]
  17
+            [clojail.testers          :only    [secure-tester blanket]]
17 18
             [somnium.congomongo       :only    [update! fetch-one fetch fetch-and-modify destroy!]]
18  
-            [hiccup.form-helpers      :only    [form-to text-area hidden-field label text-field drop-down]]
19  
-            [hiccup.page-helpers      :only    [link-to]]
  19
+            [hiccup.form              :only    [form-to text-area hidden-field label text-field drop-down]]
  20
+            [hiccup.element           :only    [link-to]]
20 21
             [hiccup.core              :only    [html]]
21 22
             [useful.debug             :only    [?]]
22 23
             [compojure.core           :only    [defroutes GET POST]]))
@@ -60,7 +61,7 @@
60 61
            ", or go back and try " (problem-link skipped) " again!"))))
61 62
 
62 63
 (defn next-problem-link [completed-problem-id]
63  
-  (when-let [{:keys [solved]} (get-user (session/session-get :user))]
  64
+  (when-let [{:keys [solved]} (get-user (session/get :user))]
64 65
     (apply suggest-problems
65 66
            (next-unsolved-problem solved completed-problem-id))))
66 67
 
@@ -69,10 +70,11 @@
69 70
 
70 71
 (defn problem-feed [n]
71 72
   (reduce (fn [feed v]
72  
-            (conj feed [:item
73  
-                        [:guid (str "http://4clojure.com/problem/" (:_id v))]
74  
-                        [:title (:title v)]
75  
-                        [:description (:description v)]]))
  73
+            (conj feed
  74
+                  (element :item {}
  75
+                    (element :guid {} (str "http://4clojure.com/problem/" (:_id v)))
  76
+                    (element :title {} (:title v))
  77
+                    (element :description {} (:description v)))))
76 78
           ()
77 79
           (get-recent-problems n)))
78 80
 
@@ -101,10 +103,10 @@
101 103
               (fetch-one :users
102 104
                          :where {:_id user-id}))]
103 105
     (when (golfer? user)
104  
-      (session/session-put! :golf-chart
105  
-                            {:id problem-id
106  
-                             :score score
107  
-                             :best old-score}))
  106
+      (session/put! :golf-chart
  107
+                    {:id problem-id
  108
+                     :score score
  109
+                     :best old-score}))
108 110
     (when (or (not old-score)
109 111
               (> old-score score))
110 112
       (update! :users
@@ -137,7 +139,7 @@
137 139
     (save-solution user-id problem-id code)))
138 140
 
139 141
 (defn mark-completed [problem code & [user]]
140  
-  (let [user (or user (session/session-get :user))
  142
+  (let [user (or user (session/get :user))
141 143
         {:keys [_id approved]} problem
142 144
         paste-link (html [:span.share
143 145
                          [:a.novisited {:href "/share/code"} "share"]
@@ -155,13 +157,19 @@
155 157
          :else (str "You've solved the problem; "
156 158
                     paste-link
157 159
                     "You need to " (login-link "log in" (str "/problem/" _id)) " in order to save your solutions and track progress."))]
158  
-    (session/session-put! :code [_id code])
  160
+    (session/put! :code [_id code])
159 161
     {:message message, :error "",  :url (str "/problem/" _id)}))
160 162
 
161 163
 (def restricted-list '[use require in-ns future agent send send-off pmap pcalls])
162 164
 
  165
+(def base-tester (blanket secure-tester
  166
+                          "foreclojure"
  167
+                          "somnium"
  168
+                          "ring"
  169
+                          "compojure"))
  170
+
163 171
 (defn get-tester [restricted]
164  
-  (into secure-tester (concat restricted-list (map symbol restricted))))
  172
+  (into base-tester (concat restricted-list (map symbol restricted))))
165 173
 
166 174
 (def sb (sandbox*))
167 175
 
@@ -233,16 +241,16 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
233 241
 
234 242
 (defn render-golf-chart []
235 243
   (let [{:keys [id best score] :as settings}
236  
-        (session/session-get :golf-chart)
  244
+        (session/get :golf-chart)
237 245
 
238 246
         url (str "/leagues/golf/" id "?best=" best "&curr=" score)]
239  
-    (session/session-delete-key! :golf-chart)
  247
+    (session/remove! :golf-chart)
240 248
     (when settings
241 249
       [:img {:src url}])))
242 250
 
243 251
 (defn render-golf-score []
244 252
   (let [{:keys [id best score] :as settings}
245  
-        (session/session-get :golf-chart)]
  253
+        (session/get :golf-chart)]
246 254
     (when settings
247 255
       [:div#golf-scores
248 256
        [:p#golfheader (str "Code Golf Score: " score)]
@@ -313,7 +321,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
313 321
                     :spellcheck "false"}
314 322
                    :code (escape-html
315 323
                           (or (session/flash-get :code)
316  
-                              (-> (session/session-get :user)
  324
+                              (-> (session/get :user)
317 325
                                   (get-user-id)
318 326
                                   (get-solution ,,, _id)))))
319 327
         [:div#golfgraph
@@ -328,7 +336,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
328 336
 
329 337
 (defn problem-page [id]
330 338
   (let [error #(flash-error "/problems" %)
331  
-        user (delay (session/session-get :user))]
  339
+        user (delay (session/get :user))]
332 340
     (if-let [{:keys [approved]} (get-problem id)]
333 341
       (cond (or approved (approver? (force user))) (code-box id)
334 342
             (force user) (error "You cannot access this page")
@@ -366,14 +374,14 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
366 374
 
367 375
 (defn show-solutions [id]
368 376
   (let [problem-id (Integer. id)
369  
-        user (session/session-get :user)]
  377
+        user (session/get :user)]
370 378
     (if-user [{:keys [solved]}]
371 379
       (if (some #{problem-id} solved)
372 380
         (show-solutions-page problem-id)
373 381
         (flash-error (str "/problem/" problem-id)
374 382
           "You must solve this problem before you can see others' solutions!"))
375 383
       (do
376  
-        (session/session-put! :login-to *url*)
  384
+        (session/put! :login-to *url*)
377 385
         (flash-error "/login" "You must log in to see solutions!")))))
378 386
 
379 387
 (let [checkbox-img (image-builder {true ["images/checkmark.png" "completed"]
@@ -394,7 +402,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
394 402
          [:th "Submitted By"]
395 403
          [:th "Times Solved"]
396 404
          [:th "Solved?"]]]
397  
-       (let [solved (get-solved (session/session-get :user))
  405
+       (let [solved (get-solved (session/get :user))
398 406
              problems (get-problem-list)]
399 407
          (map-indexed
400 408
           (fn [x {:keys [title difficulty tags user], id :_id}]
@@ -441,7 +449,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
441 449
     {:main (generate-unapproved-problems-list)})})
442 450
 
443 451
 (defn access-unapproved-problem-list-page []
444  
-  (let [user (session/session-get :user)]
  452
+  (let [user (session/get :user)]
445 453
     (if (approver? user)
446 454
       (unapproved-problem-list-page)
447 455
       (flash-error "/problems" "You cannot access this page"))))
@@ -475,7 +483,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
475 483
 (defn create-problem
476 484
   "create a user submitted problem"
477 485
   [title difficulty tags restricted description code id author]
478  
-  (let [user (session/session-get :user)]
  486
+  (let [user (session/get :user)]
479 487
     (if (or (approver? user)
480 488
             (and (can-submit? user)
481 489
                  (not id)))
@@ -520,7 +528,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
520 528
       (flash-error "/problems" "You are not authorized to submit a problem."))))
521 529
 
522 530
 (defn edit-problem [id]
523  
-  (if (approver? (session/session-get :user))
  531
+  (if (approver? (session/get :user))
524 532
     (let [{:keys [title user difficulty tags restricted description tests]} (get-problem id)]
525 533
       (doseq [[k v] {:prob-id id
526 534
                      :author user
@@ -536,7 +544,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
536 544
 
537 545
 (defn approve-problem [id]
538 546
   "take a user submitted problem and approve it"
539  
-  (if (approver? (session/session-get :user))
  547
+  (if (approver? (session/get :user))
540 548
     (let [{:keys [title user]} (from-mongo
541 549
                                 (fetch-one :problems
542 550
                                            :where {:_id id}
@@ -559,7 +567,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
559 567
 
560 568
 (defn reject-problem [id reason]
561 569
   "reject a user submitted problem by deleting it from the database"
562  
-  (if (approver? (session/session-get :user))
  570
+  (if (approver? (session/get :user))
563 571
     (let [{:keys [user title description tags tests]} (get-problem id)
564 572
           email (:email (get-user user))]
565 573
       (destroy! :problems
6  src/foreclojure/register.clj
... ...
@@ -1,8 +1,8 @@
1 1
 (ns foreclojure.register
2  
-  (:require [sandbar.stateful-session :as   session]
  2
+  (:require [noir.session             :as   session]
3 3
             [ring.util.response       :as   response])
4 4
   (:import  [org.jasypt.util.password StrongPasswordEncryptor])
5  
-  (:use     [hiccup.form-helpers      :only [form-to text-field password-field]]
  5
+  (:use     [hiccup.form              :only [form-to text-field password-field]]
6 6
             [compojure.core           :only [defroutes GET POST]]
7 7
             [foreclojure.utils        :only [form-row assuming flash-error plausible-email?]]
8 8
             [foreclojure.template     :only [def-page]]
@@ -46,7 +46,7 @@
46 46
                  {:user lower-user
47 47
                   :pwd (.encryptPassword (StrongPasswordEncryptor.) pwd)
48 48
                   :email email})
49  
-        (session/session-put! :user lower-user)
  49
+        (session/put! :user lower-user)
50 50
         (response/redirect "/"))
51 51
       (do
52 52
         (session/flash-put! :user user)
6  src/foreclojure/settings.clj
... ...
@@ -1,8 +1,8 @@
1 1
 (ns foreclojure.settings
2  
-  (:require [sandbar.stateful-session :as   session]
  2
+  (:require [noir.session             :as   session]
3 3
             [ring.util.response       :as   response])
4 4
   (:import  [org.jasypt.util.password StrongPasswordEncryptor])
5  
-  (:use     [hiccup.form-helpers      :only [form-to label text-field password-field check-box]]
  5
+  (:use     [hiccup.form              :only [form-to label text-field password-field check-box]]
6 6
             [foreclojure.utils        :only [from-mongo flash-error flash-msg with-user form-row assuming send-email login-url plausible-email?]]
7 7
             [foreclojure.template     :only [def-page content-page]]
8 8
             [foreclojure.users        :only [disable-codebox? hide-solutions? gravatar-img]]
@@ -96,7 +96,7 @@
96 96
                              :disable-code-box (boolean disable-codebox)
97 97
                              :hide-solutions (boolean hide-solutions)}}
98 98
                      :upsert false)
99  
-            (session/session-put! :user new-lower-user)
  99
+            (session/put! :user new-lower-user)
100 100
             (flash-msg "/problems"
101 101
               (str "Account for " new-lower-user " updated successfully")))
102 102
           (flash-error "/settings" why)))))
10  src/foreclojure/social.clj
... ...
@@ -1,11 +1,11 @@
1 1
 (ns foreclojure.social
2  
-  (:require [innuendo.core            :as rheap]
3  
-            [sandbar.stateful-session :as   session])
  2
+  (:require [innuendo.core            :as   rheap]
  3
+            [noir.session             :as   session])
4 4
   (:import  [java.net                 URLEncoder])
5 5
   (:use     [foreclojure.template     :only [def-page]]
6 6
             [foreclojure.utils        :only [escape-html]]
7 7
             [compojure.core           :only [defroutes GET]]
8  
-            [hiccup.page-helpers      :only [link-to]]
  8
+            [hiccup.element           :only [link-to]]
9 9
             [somnium.congomongo       :only [fetch-one]]))
10 10
 
11 11
 (defn throttled
@@ -71,8 +71,8 @@
71 71
 (def-page share-page []
72 72
   {:title "Share your code!"
73 73
    :content
74  
-   (if-let [[id code] (session/session-get :code)]
75  
-     (let [user (session/session-get :user)
  74
+   (if-let [[id code] (session/get :code)]
  75
+     (let [user (session/get :user)
76 76
            paste-url (paste! user id code)
77 77
            paste-link (if paste-url
78 78
                         [:div {:id "shared-code-box"}
2  src/foreclojure/static.clj
@@ -4,7 +4,7 @@
4 4
         [foreclojure.config        :only [repo-url]]
5 5
         [foreclojure.ring-utils    :only [static-url]]
6 6
         [foreclojure.template      :only [def-page]]
7  
-        [hiccup.form-helpers       :only [hidden-field]]))
  7
+        [hiccup.form               :only [hidden-field]]))
8 8
 
9 9
 (def df
10 10
   (let [df (java.text.DecimalFormat.)
7  src/foreclojure/template.clj
... ...
@@ -1,7 +1,8 @@
1 1
 (ns foreclojure.template
2  
-  (:require [sandbar.stateful-session  :as   session])
  2
+  (:require [noir.session              :as   session])
3 3
   (:use     [hiccup.core               :only [html]]
4  
-            [hiccup.page-helpers       :only [doctype javascript-tag link-to]]
  4
+            [hiccup.page               :only [doctype]]
  5
+            [hiccup.element            :only [javascript-tag link-to]]
5 6
             [foreclojure.config        :only [config repo-url]]
6 7
             [foreclojure.utils         :only [page-attributes rendering-info login-url approver? can-submit?]]
7 8
             [foreclojure.ring-utils    :only [static-url]]
@@ -10,7 +11,7 @@
10 11
 ;; Global wrapping template
11 12
 (defn html-doc [body]
12 13
   (let [attrs (rendering-info (page-attributes body))
13  
-        user (session/session-get :user)]
  14
+        user (session/get :user)]
14 15
     (html
15 16
      (doctype :html5)
16 17
      [:html
8  src/foreclojure/users.clj
... ...
@@ -1,7 +1,7 @@
1 1
 (ns foreclojure.users
2 2
   (:require [ring.util.response       :as response]
3 3
             [clojure.string           :as string]
4  
-            [sandbar.stateful-session :as session]
  4
+            [noir.session             :as session]
5 5
             [cheshire.core            :as json])
6 6
   (:use     [foreclojure.utils        :only [from-mongo row-class rank-class get-user if-user with-user]]
7 7
             [foreclojure.template     :only [def-page content-page]]
@@ -9,8 +9,8 @@
9 9
             [foreclojure.config       :only [config repo-url]]
10 10
             [somnium.congomongo       :only [fetch-one fetch update!]]
11 11
             [compojure.core           :only [defroutes GET POST]]
12  
-            [hiccup.form-helpers      :only [form-to hidden-field]]
13  
-            [hiccup.page-helpers      :only [link-to]]
  12
+            [hiccup.form              :only [form-to hidden-field]]
  13
+            [hiccup.element           :only [link-to]]
14 14
             [hiccup.core              :only [html]])
15 15
   (:import org.apache.commons.codec.digest.DigestUtils
16 16
            java.net.URLEncoder))
@@ -155,7 +155,7 @@
155 155
      :main (generate-user-list [] "server-user-table")})})
156 156
 
157 157
 (def-page top-users-page []
158  
-  (let [username (session/session-get :user)
  158
+  (let [username (session/get :user)
159 159
         {:keys [user-ranking top-100]} (get-top-100-and-current-user username)]
160 160
     {:title "Top 100 Users"
161 161
      :content
11  src/foreclojure/utils.clj
... ...
@@ -1,18 +1,19 @@
1 1
 (ns foreclojure.utils
2  
-  (:require [sandbar.stateful-session :as   session]
  2
+  (:require [noir.session             :as   session]
3 3
             [ring.util.response       :as   response]
4 4
             [foreclojure.config       :as   config]
5 5
             [foreclojure.messages     :as   msg]
6 6
             [clojure.walk             :as   walk]
7 7
             [clojure.string           :as   string]
8 8
             [foreclojure.git          :as   git]
9  
-            [hiccup.page-helpers      :as   hiccup])
  9
+            [hiccup.page              :as   hiccup])
10 10
   (:import  [java.net                 URLEncoder]
11 11
             (org.apache.commons.lang  StringEscapeUtils)
12 12
             (org.apache.commons.mail  HtmlEmail))
13 13
   (:use     [hiccup.core              :only [html]]
14  
-            [hiccup.page-helpers      :only [doctype javascript-tag link-to]]
15  
-            [hiccup.form-helpers      :only [label]]
  14
+            [hiccup.page              :only [doctype]]
  15
+            [hiccup.element           :only [link-to]]
  16
+            [hiccup.form              :only [label]]
16 17
             [useful.fn                :only [to-fix]]
17 18
             [somnium.congomongo       :only [fetch-one]]
18 19
             [foreclojure.ring-utils   :only [*url* static-url]]
@@ -137,7 +138,7 @@
137 138
   ([[user-binding username] then]
138 139
      `(if-user ~[user-binding username] ~then nil))
139 140
   ([[user-binding username] then else]
140  
-     (let [userexpr (or username `(session/session-get :user))]
  141
+     (let [userexpr (or username `(session/get :user))]
141 142
        `(let [username# ~userexpr]
142 143
           (if-let [~user-binding (and username#
143 144
                                       (get-user username#))]
2  src/foreclojure/version_utils.clj
@@ -3,7 +3,7 @@
3 3
   (:require [foreclojure.git        :as   git]
4 4
             [foreclojure.config     :as   config]
5 5
             [clojure.string         :as   string]
6  
-            [hiccup.page-helpers    :as   hiccup]))
  6
+            [hiccup.page            :as   hiccup]))
7 7
 
8 8
 (let [version-suffix (str "__" git/tag)]
9 9
   (defn add-version-number [file]
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.