Permalink
Browse files

Merge branch 'release/2.0.0-alpha1'

  • Loading branch information...
2 parents b5c1f1b + 851fabb commit db9497ba87e7f895dd92453c01f1c4ea73eb15c2 @amalloy amalloy committed Jun 29, 2012
View
@@ -10,4 +10,5 @@ pom.xml
.DS_Store
.#*
.emacs-project
-.lein-failures
+.lein-failures
+target
View
@@ -1,26 +1,25 @@
-(defproject foreclojure "1.8.1"
+(defproject foreclojure "2.0.0-alpha1"
: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"]
- [innuendo "0.1.1"]
- [ring "0.3.7"]
- [clj-config "0.1.0"]
- [incanter/incanter-core "1.2.3"]
- [incanter/incanter-charts "1.2.3"]
+ [cheshire "4.0.0"]
+ [useful "0.8.3-alpha4"]
+ [amalloy/ring-gzip-middleware "0.1.2"]
+ [amalloy/mongo-session "0.0.2"]
+ [innuendo "0.1.6"]
+ [ring "1.1.1"]
+ [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"]]
+ [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
File renamed without changes.
@@ -1,10 +1,8 @@
(ns foreclojure.config
- (:use [clojure.java.io :only [file]]
- [clj-config.core :only [safely read-config]]))
+ (:require [clojure.java.io :refer [file]]
+ [useful.config :refer [load-config]]))
-(def config-file (file (System/getProperty "user.dir") "config.clj"))
-
-(def config (safely read-config config-file))
+(def config (load-config "config.clj"))
;; Defs both for convenience and compile-time verification of simple settings
(def repo-url (or (:repo-url config)
@@ -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))
@@ -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.
@@ -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")))))
@@ -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 "/"))))
Oops, something went wrong.

0 comments on commit db9497b

Please sign in to comment.