diff --git a/project.clj b/project.clj index 082ef88..1c9fcde 100644 --- a/project.clj +++ b/project.clj @@ -1,18 +1,21 @@ (defproject NoteHub "2.0.0" :description "A free and anonymous hosting for markdown pages." :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/core.cache "0.6.3"] - [hiccup "1.0.0"] + [org.clojure/core.cache "0.6.4"] + [hiccup "1.0.5"] [zeus "0.1.0"] [org.pegdown/pegdown "1.4.2"] [iokv "0.1.1"] [cheshire "5.3.1"] - [ring/ring-core "1.2.0"] - [com.taoensso/carmine "2.4.4"] - [compojure "1.1.6"]] + [ring "1.3.1"] + [com.taoensso/carmine "2.7.0" :exclusions [org.clojure/clojure]] + [compojure "1.2.0"]] + :main notehub.handler :min-lein-version "2.0.0" :plugins [[lein-ring "0.8.10"]] :ring {:handler notehub.handler/app} - :profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"] - [ring-mock "0.1.5"]]}} + :profiles {:uberjar {:aot :all} + :dev {:dependencies + [[javax.servlet/servlet-api "2.5"] + [ring-mock "0.1.5"]]}} :jvm-opts ["-Dfile.encoding=utf-8"]) diff --git a/src/notehub/handler.clj b/src/notehub/handler.clj index f1290d1..f8ce87a 100644 --- a/src/notehub/handler.clj +++ b/src/notehub/handler.clj @@ -5,13 +5,15 @@ notehub.views [clojure.string :rename {replace sreplace} :only [replace]]) (:require + [ring.adapter.jetty :as jetty] [clojure.core.cache :as cache] [hiccup.util :as util] [compojure.handler :as handler] [compojure.route :as route] [notehub.api :as api] [notehub.storage :as storage] - [cheshire.core :refer :all])) + [cheshire.core :refer :all]) + (:gen-class)) (defn current-timestamp [] (quot (System/currentTimeMillis) 100000000)) @@ -50,7 +52,7 @@ (defroutes app-routes (GET "/api" [] (layout :no-js (get-message :api-title) - [:article (md-to-html (slurp "API.md"))])) + [:article (md-to-html (slurp "API.md"))])) (context "/api" [] #(ring.util.response/content-type (api-routes %) "application/json")) @@ -138,11 +140,16 @@ (def app (let [handler (handler/site app-routes)] - (fn [request] - (if (get-setting :dev-mode) - (handler request) - (try (handler request) - (catch Exception e - (do - ;TODO (log e) - (response 500)))))))) + (fn [request] + (if (get-setting :dev-mode) + (handler request) + (try (handler request) + (catch Exception e + (do + ;TODO (log e) + (response 500)))))))) + +(defn -main [& [port]] + (jetty/run-jetty #'app + {:port (if port (Integer/parseInt port) 8080)})) +