Permalink
Browse files

ditched compojure 0.6.0 in favor of noir as in tryclj

  • Loading branch information...
1 parent c59b0a2 commit 6e108aa07fd48176dfe79c3a5ea5f99d486d3496 @goranjovic committed Jan 7, 2012
Showing with 19 additions and 24 deletions.
  1. +1 −2 project.clj
  2. +1 −1 src/chromeclojure/{ → models}/eval.clj
  3. +7 −21 src/chromeclojure/server.clj
  4. +10 −0 src/chromeclojure/views/eval.clj
View
@@ -2,9 +2,8 @@
:description "A Clojure Plugin for Google Chrome."
:dependencies [[org.clojure/clojure "1.3.0"]
[commons-lang/commons-lang "2.5"]
- [org.clojure/data.json "0.1.1"]
- [compojure "0.6.0"]
[ring/ring-jetty-adapter "0.3.7"]
+ [noir "1.2.1"]
[clojail "0.5.1"]]
:jvm-opts ["-Djava.security.policy=example.policy""-Xmx80M"]
:main chromeclojure.server)
@@ -1,4 +1,4 @@
-(ns chromeclojure.eval
+(ns chromeclojure.models.eval
(:use [clojail.testers :only [secure-tester-without-def]]
[clojail.core :only [sandbox]]
[clojure.stacktrace :only [root-cause]])
@@ -1,32 +1,18 @@
(ns chromeclojure.server
- (:use [clojure.data.json :only [json-str]])
- (:use [ring.util.servlet :only [defservice]])
- (:use [compojure.core :only [defroutes GET POST ANY wrap!]])
- (:require [compojure.route :as route])
- (:use [ring.middleware params keyword-params nested-params])
- (:use [ring.adapter.jetty :only [run-jetty] :as jetty])
- (:use [ring.util.response :only [redirect]])
- (:use chromeclojure.eval))
+ (:use [ring.middleware.file :only [wrap-file]])
+ (:require [noir.server :as server]))
-(defroutes routes
- (ANY "/eval" [source] (json-str (eval-request source)))
- (route/resources "/")
- (route/not-found "Not Found!"))
-
-(defn api [routes]
- (-> routes
- wrap-keyword-params
- wrap-nested-params
- wrap-params))
+(server/add-middleware wrap-file (System/getProperty "user.dir"))
+(server/load-views "src/chromeclojure/views")
(defn to-port [s]
(when-let [port s] (Long. port)))
(defn start [& [port]]
- (jetty/run-jetty (api routes)
- {:port (or (to-port port)
+ (server/start
+ (or (to-port port)
(to-port (System/getenv "PORT")) ;; For deploying to Heroku
8081)
- :join? false}))
+ {:session-cookie-attrs {:max-age 600}}))
(defn -main [& args] (start (first args)))
@@ -0,0 +1,10 @@
+(ns chromeclojure.views.eval
+ (:use [noir.core :only [defpage]]
+ [chromeclojure.models.eval :only [eval-request]])
+ (:require [noir.response :as resp]))
+
+(defpage [:post "/eval"] {:keys [source jsonp]}
+ (let [data (eval-request source)]
+ (if jsonp
+ (resp/jsonp jsonp data)
+ (resp/json data))))

0 comments on commit 6e108aa

Please sign in to comment.