Permalink
Browse files

DB connection details moved to config, links page removed

  • Loading branch information...
1 parent 2834694 commit 3d90bd77deafb3b3a4b25c6a183054feecfba059 @dbyrne dbyrne committed Apr 22, 2011
Showing with 14 additions and 4 deletions.
  1. +4 −1 config.clj
  2. +10 −2 src/foreclojure/core.clj
  3. +0 −1 src/foreclojure/static.clj
View
@@ -1 +1,4 @@
-{:wrap-reload false}
+{:wrap-reload false
+ :db-host "localhost"
+ :db-user nil
+ :db-pwd nil}
View
@@ -10,8 +10,18 @@
[sandbar.stateful-session :as session]
[ring.util.response :as response]))
+(def config-file (file (System/getProperty "user.dir") "config.clj"))
+
(mongo!
+ :host (if-let [host (safely get-key config-file :db-host)]
+ host
+ "localhost")
:db "mydb")
+
+(if-let [db-user (safely get-key config-file :db-user)]
+ (if-let [db-pwd (safely get-key config-file :db-pwd)]
+ (authenticate db-user db-pwd)))
+
(add-index! :users [:user] :unique true)
(add-index! :users [[:solved -1]])
@@ -25,8 +35,6 @@
(route/resources "/")
(route/not-found "Page not found"))
-(def config-file (file (System/getProperty "user.dir") "config.clj"))
-
(def app
(handler/site
(session/wrap-stateful-session
@@ -64,5 +64,4 @@
"You should now be ready to start solving problems. Happy coding!"])
(defroutes static-routes
- (GET "/links" [] (links-page))
(GET "/directions" [] (getting-started-page)))

0 comments on commit 3d90bd7

Please sign in to comment.