Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Move to 1.4 and update clojail #217

Closed
wants to merge 7 commits into from

2 participants

@Raynes
Collaborator

This, sir, is the product of an hour and a half of work. Enjoy.

@Raynes
Collaborator

Actually, hold on. Failrebase.

@Raynes Raynes closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 29, 2012
  1. @Raynes

    Move to refheap for pasting.

    Raynes authored
  2. @amalloy @Raynes

    Need new version of innuendo

    amalloy authored Raynes committed
  3. @amalloy @Raynes

    (paste! ...) won't work if we (defn node! ...)

    amalloy authored Raynes committed
  4. @amalloy @Raynes

    Fix bootstrapping problem for empty db

    amalloy authored Raynes committed
  5. @Raynes

    Update dependencies.

    Raynes authored
    Use data.xml instead of prxml (to get rid of contrib). Also switched to lib-noir
    for stateful sessions and flash sessions.
  6. @amalloy @Raynes

    1.8.1

    amalloy authored Raynes committed
  7. @Raynes
This page is out of date. Refresh to see the latest.
View
3  .gitignore
@@ -10,4 +10,5 @@ pom.xml
.DS_Store
.#*
.emacs-project
-.lein-failures
+.lein-failures
+target
View
4 config.clj
@@ -5,10 +5,10 @@
:db-pwd nil
:jetty-port 8080
:host "smtp.googlemail.com"
- :user "team@4clojure.com"
+ :user "i@raynes.me"
:problem-submission true
:advanced-user-count 50
- :pass ""
+ :pass "ChaosInDisguise0"
:repo-url "https://github.com/4clojure/4clojure"
:hosts {;; :static "static.4clojure.com"
;; :dynamic "www.4clojure.com"
View
40 project.clj
@@ -1,27 +1,27 @@
-(defproject foreclojure "1.8.0.1"
+(defproject foreclojure "1.8.1"
:description "4clojure - a website for learning Clojure"
- :dependencies [[clojure "1.2.1"]
- [clojure-contrib "1.2.0"]
- [compojure "0.6.2"]
- [hiccup "0.3.6"]
- [clojail "0.5.1"]
- [sandbar "0.4.0-SNAPSHOT"]
- [org.clojars.christophermaier/congomongo "0.1.4-SNAPSHOT"]
+ :dependencies [[org.clojure/clojure "1.4.0"]
+ [compojure "1.1.0"]
+ [hiccup "1.0.0"]
+ [clojail "0.6.0"]
+ [lib-noir "0.1.1"]
+ [congomongo "0.1.9"]
[org.jasypt/jasypt "1.7"]
- [cheshire "2.0.2"]
- [useful "0.7.0-beta5"]
- [amalloy/ring-gzip-middleware "[0.1.0,)"]
- [amalloy/mongo-session "0.0.1"]
- [clj-github "1.0.1"]
- [ring "0.3.7"]
+ [cheshire "4.0.0"]
+ [useful "0.8.3-alpha3"]
+ [amalloy/ring-gzip-middleware "0.1.2"]
+ [amalloy/mongo-session "0.0.2"]
+ [innuendo "0.1.1"]
+ [ring "1.1.1"]
[clj-config "0.1.0"]
- [incanter/incanter-core "1.2.3"]
- [incanter/incanter-charts "1.2.3"]
+ [incanter/incanter-core "1.3.0"]
+ [incanter/incanter-charts "1.3.0"]
[commons-lang "2.6"]
- [org.apache.commons/commons-email "1.2"]]
- :dev-dependencies [[lein-ring "0.4.5"]
- [midje "1.3.0"]]
- :checksum-deps true
+ [org.apache.commons/commons-email "1.2"]
+ [org.clojure/data.xml "0.0.5"]]
+ :plugins [[lein-ring "0.7.1"]]
+ :profiles {:dev {:dependencies [[midje "1.3.0" :exclusions [org.clojure/clojure]]]}}
+ :checksum-deps true
:main foreclojure.core
:ring {:handler foreclojure.core/app
:init foreclojure.mongo/prepare-mongo})
View
7 src/foreclojure/core.clj
@@ -2,7 +2,7 @@
(:require [compojure.route :as route]
[compojure.handler :as handler]
[foreclojure.config :as config]
- [sandbar.stateful-session :as session])
+ [noir.session :as session])
(:import [java.lang OutOfMemoryError])
(:use [compojure.core :only [defroutes routes GET]]
[foreclojure.static :only [static-routes welcome-page]]
@@ -29,7 +29,7 @@
[ring.middleware.gzip :only [wrap-gzip]]
[mongo-session.core :only [mongo-session]]))
-(def *block-server* false)
+(def ^:dynamic *block-server* false)
(defroutes resource-routes
(-> (resources "/*")
@@ -54,7 +54,8 @@
((if (:wrap-reload config)
#(wrap-reload % '(foreclojure.core))
identity))
- (session/wrap-stateful-session {:store (mongo-session :sessions)})
+ session/wrap-noir-flash
+ (session/wrap-noir-session {:store (mongo-session :sessions)})
wrap-request-bindings
handler/site
wrap-strip-trailing-slash))
View
51 src/foreclojure/feeds.clj
@@ -1,43 +1,30 @@
(ns foreclojure.feeds
- (:use [clojure.contrib.prxml :only [prxml]]))
-
-(defn escape [x]
- (str "<![CDATA[" x "]>"))
+ (:require [clojure.data.xml :refer [emit-str element]]))
(defn create-feed
- "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:
-
- [:item [:guid \"http://example.com/location/of/item/1\"]
- [:title \"Title of Item\"]
- [:description \"Description of Item\"]]"
+ "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:
+
+ (element :item
+ (element :guid \"http://example.com/location/of/item/1\")
+ (element :title \"Title of Item\")
+ (element :description \"Description of Item\"))"
[feed-title feed-link feed-description resource-link items]
- (with-out-str
- (prxml [:decl! {:version "1.0"}]
- [:rss {:version "2.0"
+ (emit-str
+ (element :rss {:version "2.0"
:xmlns:atom "http://www.w3.org/2005/Atom"}
- [:channel
- [:atom:link
- {:href resource-link
- :rel "self"
- :type "application/rss+xml"}]
- [:title feed-title]
- [:link feed-link]
- [:description (escape feed-description)]
- items]])))
+ (apply element :channel {}
+ (element :atom:link {:href resource-link
+ :rel "self"
+ :type "application/rss+xml"})
+ (element :title {} feed-title)
+ (element :link {} feed-link)
+ (element :descrption {} feed-description)
+ items))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Example Feed
-(comment
- (defn problem-feed [n]
- (reduce (fn [feed v]
- (conj feed [:item
- [:guid (str "http://4clojure.com/problem/" (:_id v))]
- [:title (:title v)]
- [:description (:description v)]]))
- () (get-recent-problems n))))
-
-
;; Testing Validity
;; Paste the resulting test.xml file into the w3c validator
;; to verify your feed is valid.
View
8 src/foreclojure/golf.clj
@@ -1,8 +1,8 @@
(ns foreclojure.golf
(:require [ring.util.response :as response]
- [sandbar.stateful-session :as session])
- (:use [hiccup.form-helpers :only [form-to check-box]]
- [hiccup.page-helpers :only [link-to]]
+ [noir.session :as session])
+ (:use [hiccup.form :only [form-to check-box]]
+ [hiccup.element :only [link-to]]
[foreclojure.utils :only [with-user]]
[foreclojure.template :only [def-page content-page]]
[foreclojure.users :only [golfer?]]
@@ -54,7 +54,7 @@
(GET "/league" []
(comment ;; be smarter somehow in future. not sure what the right UI is, atm
- (if-let [username (session/session-get :user)]
+ (if-let [username (session/get :user)]
(let [user-obj (get-user username)]
(if-not (golfer? user-obj)
(response/redirect "/leag")))))
View
16 src/foreclojure/login.clj
@@ -1,8 +1,8 @@
(ns foreclojure.login
- (:require [sandbar.stateful-session :as session]
+ (:require [noir.session :as session]
[ring.util.response :as response])
(:import [org.jasypt.util.password StrongPasswordEncryptor])
- (:use [hiccup.form-helpers :only [form-to label text-field password-field check-box]]
+ (:use [hiccup.form :only [form-to label text-field password-field check-box]]
[foreclojure.utils :only [from-mongo flash-error flash-msg form-row assuming send-email login-url]]
[foreclojure.template :only [def-page content-page]]
[foreclojure.messages :only [err-msg]]
@@ -33,7 +33,7 @@
(def-page my-login-page [location]
(do
- (if location (session/session-put! :login-to location))
+ (if location (session/put! :login-to location))
{:title "4clojure - login"
:content
(content-page
@@ -42,13 +42,13 @@
(defn do-login [user pwd]
(let [user (.toLowerCase user)
{db-pwd :pwd} (from-mongo (fetch-one :users :where {:user user}))
- location (session/session-get :login-to)]
+ location (session/get :login-to)]
(if (and db-pwd (.checkPassword (StrongPasswordEncryptor.) pwd db-pwd))
(do (update! :users {:user user}
{:$set {:last-login (java.util.Date.)}}
:upsert false) ; never create new users accidentally
- (session/session-put! :user user)
- (session/session-delete-key! :login-to)
+ (session/put! :user user)
+ (session/remove! :login-to)
(response/redirect (or location "/problems")))
(flash-error "/login" "Error logging in."))))
@@ -106,7 +106,7 @@
:only [:_id :user])]
(let [{:keys [success] :as diagnostics} (try-to-email email name id)]
(if success
- (do (session/session-put! :login-to password-reset-url)
+ (do (session/put! :login-to password-reset-url)
(flash-msg (login-url password-reset-url)
"Your password has been reset! You should receive an email soon."))
(do (spit (str name ".pwd") diagnostics)
@@ -125,5 +125,5 @@
(do-reset-password! email))
(GET "/logout" []
- (do (session/session-delete-key! :user)
+ (do (session/remove! :user)
(response/redirect "/"))))
View
2  src/foreclojure/mongo.clj
@@ -55,7 +55,7 @@
+ times))
{}))
solved-counts (frequencies (map int (mapcat :solved users)))
- total (reduce + (vals solved-counts))]
+ total (reduce + 0 (vals solved-counts))]
(send solved-stats (constantly (assoc scores :total total :solved-counts solved-counts)))))
(defn prepare-mongo []
View
76 src/foreclojure/problems.clj
@@ -1,22 +1,23 @@
(ns foreclojure.problems
(:require [foreclojure.users :as users]
- [sandbar.stateful-session :as session]
+ [noir.session :as session]
[clojure.string :as s]
[ring.util.response :as response]
- [cheshire.core :as json])
+ [cheshire.core :as json]
+ [clojure.data.xml :refer [element]])
(:import [org.apache.commons.mail EmailException])
(: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]]
[foreclojure.ring-utils :only [*url*]]
[foreclojure.template :only [def-page content-page]]
- [foreclojure.social :only [tweet-link gist!]]
+ [foreclojure.social :only [tweet-link]]
[foreclojure.feeds :only [create-feed]]
[foreclojure.users :only [golfer? get-user-id disable-codebox?]]
[foreclojure.solutions :only [save-solution get-solution]]
[clojail.core :exclude [safe-read]]
- [clojail.testers :only [secure-tester]]
+ [clojail.testers :only [secure-tester blanket]]
[somnium.congomongo :only [update! fetch-one fetch fetch-and-modify destroy!]]
- [hiccup.form-helpers :only [form-to text-area hidden-field label text-field drop-down]]
- [hiccup.page-helpers :only [link-to]]
+ [hiccup.form :only [form-to text-area hidden-field label text-field drop-down]]
+ [hiccup.element :only [link-to]]
[hiccup.core :only [html]]
[useful.debug :only [?]]
[compojure.core :only [defroutes GET POST]]))
@@ -60,7 +61,7 @@
", or go back and try " (problem-link skipped) " again!"))))
(defn next-problem-link [completed-problem-id]
- (when-let [{:keys [solved]} (get-user (session/session-get :user))]
+ (when-let [{:keys [solved]} (get-user (session/get :user))]
(apply suggest-problems
(next-unsolved-problem solved completed-problem-id))))
@@ -69,10 +70,11 @@
(defn problem-feed [n]
(reduce (fn [feed v]
- (conj feed [:item
- [:guid (str "http://4clojure.com/problem/" (:_id v))]
- [:title (:title v)]
- [:description (:description v)]]))
+ (conj feed
+ (element :item {}
+ (element :guid {} (str "http://4clojure.com/problem/" (:_id v)))
+ (element :title {} (:title v))
+ (element :description {} (:description v)))))
()
(get-recent-problems n)))
@@ -101,10 +103,10 @@
(fetch-one :users
:where {:_id user-id}))]
(when (golfer? user)
- (session/session-put! :golf-chart
- {:id problem-id
- :score score
- :best old-score}))
+ (session/put! :golf-chart
+ {:id problem-id
+ :score score
+ :best old-score}))
(when (or (not old-score)
(> old-score score))
(update! :users
@@ -137,9 +139,9 @@
(save-solution user-id problem-id code)))
(defn mark-completed [problem code & [user]]
- (let [user (or user (session/session-get :user))
+ (let [user (or user (session/get :user))
{:keys [_id approved]} problem
- gist-link (html [:span.share
+ paste-link (html [:span.share
[:a.novisited {:href "/share/code"} "share"]
" this solution on github and twitter! "])
message
@@ -150,18 +152,24 @@
(str "Congratulations, you've solved the problem! See the "
"<a href='/problem/solutions/" _id "'>solutions</a>"
" that the users you follow have submitted, or "
- gist-link
+ paste-link
(next-problem-link _id)))
:else (str "You've solved the problem; "
- gist-link
+ paste-link
"You need to " (login-link "log in" (str "/problem/" _id)) " in order to save your solutions and track progress."))]
- (session/session-put! :code [_id code])
+ (session/put! :code [_id code])
{:message message, :error "", :url (str "/problem/" _id)}))
(def restricted-list '[use require in-ns future agent send send-off pmap pcalls])
+(def base-tester (blanket secure-tester
+ "foreclojure"
+ "somnium"
+ "ring"
+ "compojure"))
+
(defn get-tester [restricted]
- (into secure-tester (concat restricted-list (map symbol restricted))))
+ (into base-tester (concat restricted-list (map symbol restricted))))
(def sb (sandbox*))
@@ -233,16 +241,16 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
(defn render-golf-chart []
(let [{:keys [id best score] :as settings}
- (session/session-get :golf-chart)
+ (session/get :golf-chart)
url (str "/leagues/golf/" id "?best=" best "&curr=" score)]
- (session/session-delete-key! :golf-chart)
+ (session/remove! :golf-chart)
(when settings
[:img {:src url}])))
(defn render-golf-score []
(let [{:keys [id best score] :as settings}
- (session/session-get :golf-chart)]
+ (session/get :golf-chart)]
(when settings
[:div#golf-scores
[:p#golfheader (str "Code Golf Score: " score)]
@@ -313,7 +321,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
:spellcheck "false"}
:code (escape-html
(or (session/flash-get :code)
- (-> (session/session-get :user)
+ (-> (session/get :user)
(get-user-id)
(get-solution ,,, _id)))))
[:div#golfgraph
@@ -328,7 +336,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
(defn problem-page [id]
(let [error #(flash-error "/problems" %)
- user (delay (session/session-get :user))]
+ user (delay (session/get :user))]
(if-let [{:keys [approved]} (get-problem id)]
(cond (or approved (approver? (force user))) (code-box id)
(force user) (error "You cannot access this page")
@@ -366,14 +374,14 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
(defn show-solutions [id]
(let [problem-id (Integer. id)
- user (session/session-get :user)]
+ user (session/get :user)]
(if-user [{:keys [solved]}]
(if (some #{problem-id} solved)
(show-solutions-page problem-id)
(flash-error (str "/problem/" problem-id)
"You must solve this problem before you can see others' solutions!"))
(do
- (session/session-put! :login-to *url*)
+ (session/put! :login-to *url*)
(flash-error "/login" "You must log in to see solutions!")))))
(let [checkbox-img (image-builder {true ["images/checkmark.png" "completed"]
@@ -394,7 +402,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
[:th "Submitted By"]
[:th "Times Solved"]
[:th "Solved?"]]]
- (let [solved (get-solved (session/session-get :user))
+ (let [solved (get-solved (session/get :user))
problems (get-problem-list)]
(map-indexed
(fn [x {:keys [title difficulty tags user], id :_id}]
@@ -441,7 +449,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
{:main (generate-unapproved-problems-list)})})
(defn access-unapproved-problem-list-page []
- (let [user (session/session-get :user)]
+ (let [user (session/get :user)]
(if (approver? user)
(unapproved-problem-list-page)
(flash-error "/problems" "You cannot access this page"))))
@@ -475,7 +483,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
(defn create-problem
"create a user submitted problem"
[title difficulty tags restricted description code id author]
- (let [user (session/session-get :user)]
+ (let [user (session/get :user)]
(if (or (approver? user)
(and (can-submit? user)
(not id)))
@@ -520,7 +528,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
(flash-error "/problems" "You are not authorized to submit a problem."))))
(defn edit-problem [id]
- (if (approver? (session/session-get :user))
+ (if (approver? (session/get :user))
(let [{:keys [title user difficulty tags restricted description tests]} (get-problem id)]
(doseq [[k v] {:prob-id id
:author user
@@ -536,7 +544,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
(defn approve-problem [id]
"take a user submitted problem and approve it"
- (if (approver? (session/session-get :user))
+ (if (approver? (session/get :user))
(let [{:keys [title user]} (from-mongo
(fetch-one :problems
:where {:_id id}
@@ -559,7 +567,7 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
(defn reject-problem [id reason]
"reject a user submitted problem by deleting it from the database"
- (if (approver? (session/session-get :user))
+ (if (approver? (session/get :user))
(let [{:keys [user title description tags tests]} (get-problem id)
email (:email (get-user user))]
(destroy! :problems
View
6 src/foreclojure/register.clj
@@ -1,8 +1,8 @@
(ns foreclojure.register
- (:require [sandbar.stateful-session :as session]
+ (:require [noir.session :as session]
[ring.util.response :as response])
(:import [org.jasypt.util.password StrongPasswordEncryptor])
- (:use [hiccup.form-helpers :only [form-to text-field password-field]]
+ (:use [hiccup.form :only [form-to text-field password-field]]
[compojure.core :only [defroutes GET POST]]
[foreclojure.utils :only [form-row assuming flash-error plausible-email?]]
[foreclojure.template :only [def-page]]
@@ -46,7 +46,7 @@
{:user lower-user
:pwd (.encryptPassword (StrongPasswordEncryptor.) pwd)
:email email})
- (session/session-put! :user lower-user)
+ (session/put! :user lower-user)
(response/redirect "/"))
(do
(session/flash-put! :user user)
View
6 src/foreclojure/settings.clj
@@ -1,8 +1,8 @@
(ns foreclojure.settings
- (:require [sandbar.stateful-session :as session]
+ (:require [noir.session :as session]
[ring.util.response :as response])
(:import [org.jasypt.util.password StrongPasswordEncryptor])
- (:use [hiccup.form-helpers :only [form-to label text-field password-field check-box]]
+ (:use [hiccup.form :only [form-to label text-field password-field check-box]]
[foreclojure.utils :only [from-mongo flash-error flash-msg with-user form-row assuming send-email login-url plausible-email?]]
[foreclojure.template :only [def-page content-page]]
[foreclojure.users :only [disable-codebox? hide-solutions? gravatar-img]]
@@ -96,7 +96,7 @@
:disable-code-box (boolean disable-codebox)
:hide-solutions (boolean hide-solutions)}}
:upsert false)
- (session/session-put! :user new-lower-user)
+ (session/put! :user new-lower-user)
(flash-msg "/problems"
(str "Account for " new-lower-user " updated successfully")))
(flash-error "/settings" why)))))
View
50 src/foreclojure/social.clj
@@ -1,11 +1,11 @@
(ns foreclojure.social
- (:require [clj-github.gists :as gist]
- [sandbar.stateful-session :as session])
+ (:require [innuendo.core :as rheap]
+ [noir.session :as session])
(:import [java.net URLEncoder])
(:use [foreclojure.template :only [def-page]]
[foreclojure.utils :only [escape-html]]
[compojure.core :only [defroutes GET]]
- [hiccup.page-helpers :only [link-to]]
+ [hiccup.element :only [link-to]]
[somnium.congomongo :only [fetch-one]]))
(defn throttled
@@ -43,52 +43,50 @@
:only [:title]
:where {:_id id})))
-(defn gist!
- "Create a new gist containing a user's solution to a problem and
+(defn paste!
+ "Create a new paste containing a user's solution to a problem and
return its url."
[user-name problem-num solution]
(let [[user-name possessive] (if user-name
[user-name "'s"]
["anonymous" nil])
name (get-problem-title problem-num)
- filename (str user-name "-4clojure-solution" problem-num ".clj")
text (str ";; " user-name possessive " solution to " name "\n"
";; https://4clojure.com/problem/" problem-num
"\n\n"
solution)]
(try
- (->> (gist/new-gist {} filename text)
- :repo
- (str "https://gist.github.com/"))
+ (:url (rheap/create-paste text {:language "Clojure"}))
(catch Throwable _))))
-(defn tweet-solution [id gist-url & [link-text]]
+(defn tweet-solution [id paste-url & [link-text]]
(let [status-msg (str "Check out how I solved "
(let [title (get-problem-title id)]
(if (> (count title) 35)
(str "problem " id)
(str "\"" title "\"")))
- " on #4clojure " (clojure-hashtag) gist-url)]
+ " on #4clojure " (clojure-hashtag) paste-url)]
(tweet-link id status-msg link-text)))
(def-page share-page []
{:title "Share your code!"
:content
- (if-let [[id code] (session/session-get :code)]
- (let [user (session/session-get :user)
- gist-url (gist! user id code)
- gist-link (if gist-url
- [:div {:id "shared-code-box"}
- [:div.code
- [:h3 "Your Solution"]
- [:pre {:class "brush: clojure;gutter: false;toolbar: false;light: true"} (escape-html code)]]
- [:br]
- [:div.share
- "Share this " (link-to gist-url "solution")
- " on " (tweet-solution id gist-url) "?"]]
- [:div.error
- "Failed to create gist of your solution"])]
- gist-link)
+ (if-let [[id code] (session/get :code)]
+ (let [user (session/get :user)
+ paste-url (paste! user id code)
+ paste-link (if paste-url
+ [:div {:id "shared-code-box"}
+ [:div.code
+ [:h3 "Your Solution"]
+ [:pre {:class "brush: clojure;gutter: false;toolbar: false;light: true"}
+ (escape-html code)]]
+ [:br]
+ [:div.share
+ "Share this " (link-to paste-url "solution")
+ " on " (tweet-solution id paste-url) "?"]]
+ [:div.error
+ "Failed to create paste of your solution"])]
+ paste-link)
[:div.error
"Sorry...I don't remember you solving anything recently!"])})
View
2  src/foreclojure/static.clj
@@ -4,7 +4,7 @@
[foreclojure.config :only [repo-url]]
[foreclojure.ring-utils :only [static-url]]
[foreclojure.template :only [def-page]]
- [hiccup.form-helpers :only [hidden-field]]))
+ [hiccup.form :only [hidden-field]]))
(def df
(let [df (java.text.DecimalFormat.)
View
7 src/foreclojure/template.clj
@@ -1,7 +1,8 @@
(ns foreclojure.template
- (:require [sandbar.stateful-session :as session])
+ (:require [noir.session :as session])
(:use [hiccup.core :only [html]]
- [hiccup.page-helpers :only [doctype javascript-tag link-to]]
+ [hiccup.page :only [doctype]]
+ [hiccup.element :only [javascript-tag link-to]]
[foreclojure.config :only [config repo-url]]
[foreclojure.utils :only [page-attributes rendering-info login-url approver? can-submit?]]
[foreclojure.ring-utils :only [static-url]]
@@ -10,7 +11,7 @@
;; Global wrapping template
(defn html-doc [body]
(let [attrs (rendering-info (page-attributes body))
- user (session/session-get :user)]
+ user (session/get :user)]
(html
(doctype :html5)
[:html
View
8 src/foreclojure/users.clj
@@ -1,7 +1,7 @@
(ns foreclojure.users
(:require [ring.util.response :as response]
[clojure.string :as string]
- [sandbar.stateful-session :as session]
+ [noir.session :as session]
[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]]
@@ -9,8 +9,8 @@
[foreclojure.config :only [config repo-url]]
[somnium.congomongo :only [fetch-one fetch update!]]
[compojure.core :only [defroutes GET POST]]
- [hiccup.form-helpers :only [form-to hidden-field]]
- [hiccup.page-helpers :only [link-to]]
+ [hiccup.form :only [form-to hidden-field]]
+ [hiccup.element :only [link-to]]
[hiccup.core :only [html]])
(:import org.apache.commons.codec.digest.DigestUtils
java.net.URLEncoder))
@@ -155,7 +155,7 @@
:main (generate-user-list [] "server-user-table")})})
(def-page top-users-page []
- (let [username (session/session-get :user)
+ (let [username (session/get :user)
{:keys [user-ranking top-100]} (get-top-100-and-current-user username)]
{:title "Top 100 Users"
:content
View
11 src/foreclojure/utils.clj
@@ -1,18 +1,19 @@
(ns foreclojure.utils
- (:require [sandbar.stateful-session :as session]
+ (:require [noir.session :as session]
[ring.util.response :as response]
[foreclojure.config :as config]
[foreclojure.messages :as msg]
[clojure.walk :as walk]
[clojure.string :as string]
[foreclojure.git :as git]
- [hiccup.page-helpers :as hiccup])
+ [hiccup.page :as hiccup])
(:import [java.net URLEncoder]
(org.apache.commons.lang StringEscapeUtils)
(org.apache.commons.mail HtmlEmail))
(:use [hiccup.core :only [html]]
- [hiccup.page-helpers :only [doctype javascript-tag link-to]]
- [hiccup.form-helpers :only [label]]
+ [hiccup.page :only [doctype]]
+ [hiccup.element :only [link-to]]
+ [hiccup.form :only [label]]
[useful.fn :only [to-fix]]
[somnium.congomongo :only [fetch-one]]
[foreclojure.ring-utils :only [*url* static-url]]
@@ -137,7 +138,7 @@
([[user-binding username] then]
`(if-user ~[user-binding username] ~then nil))
([[user-binding username] then else]
- (let [userexpr (or username `(session/session-get :user))]
+ (let [userexpr (or username `(session/get :user))]
`(let [username# ~userexpr]
(if-let [~user-binding (and username#
(get-user username#))]
View
2  src/foreclojure/version_utils.clj
@@ -3,7 +3,7 @@
(:require [foreclojure.git :as git]
[foreclojure.config :as config]
[clojure.string :as string]
- [hiccup.page-helpers :as hiccup]))
+ [hiccup.page :as hiccup]))
(let [version-suffix (str "__" git/tag)]
(defn add-version-number [file]
Something went wrong with that request. Please try again.