Browse Source

notehub gets uberjar ready

master
Christian Müller 11 years ago
parent
commit
155e8b670e
  1. 17
      project.clj
  2. 27
      src/notehub/handler.clj

17
project.clj

@ -1,18 +1,21 @@
(defproject NoteHub "2.0.0" (defproject NoteHub "2.0.0"
:description "A free and anonymous hosting for markdown pages." :description "A free and anonymous hosting for markdown pages."
:dependencies [[org.clojure/clojure "1.6.0"] :dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/core.cache "0.6.3"] [org.clojure/core.cache "0.6.4"]
[hiccup "1.0.0"] [hiccup "1.0.5"]
[zeus "0.1.0"] [zeus "0.1.0"]
[org.pegdown/pegdown "1.4.2"] [org.pegdown/pegdown "1.4.2"]
[iokv "0.1.1"] [iokv "0.1.1"]
[cheshire "5.3.1"] [cheshire "5.3.1"]
[ring/ring-core "1.2.0"] [ring "1.3.1"]
[com.taoensso/carmine "2.4.4"] [com.taoensso/carmine "2.7.0" :exclusions [org.clojure/clojure]]
[compojure "1.1.6"]] [compojure "1.2.0"]]
:main notehub.handler
:min-lein-version "2.0.0" :min-lein-version "2.0.0"
:plugins [[lein-ring "0.8.10"]] :plugins [[lein-ring "0.8.10"]]
:ring {:handler notehub.handler/app} :ring {:handler notehub.handler/app}
:profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"] :profiles {:uberjar {:aot :all}
[ring-mock "0.1.5"]]}} :dev {:dependencies
[[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]]}}
:jvm-opts ["-Dfile.encoding=utf-8"]) :jvm-opts ["-Dfile.encoding=utf-8"])

27
src/notehub/handler.clj

@ -5,13 +5,15 @@
notehub.views notehub.views
[clojure.string :rename {replace sreplace} :only [replace]]) [clojure.string :rename {replace sreplace} :only [replace]])
(:require (:require
[ring.adapter.jetty :as jetty]
[clojure.core.cache :as cache] [clojure.core.cache :as cache]
[hiccup.util :as util] [hiccup.util :as util]
[compojure.handler :as handler] [compojure.handler :as handler]
[compojure.route :as route] [compojure.route :as route]
[notehub.api :as api] [notehub.api :as api]
[notehub.storage :as storage] [notehub.storage :as storage]
[cheshire.core :refer :all])) [cheshire.core :refer :all])
(:gen-class))
(defn current-timestamp [] (defn current-timestamp []
(quot (System/currentTimeMillis) 100000000)) (quot (System/currentTimeMillis) 100000000))
@ -50,7 +52,7 @@
(defroutes app-routes (defroutes app-routes
(GET "/api" [] (layout :no-js (get-message :api-title) (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" [] (context "/api" []
#(ring.util.response/content-type (api-routes %) "application/json")) #(ring.util.response/content-type (api-routes %) "application/json"))
@ -138,11 +140,16 @@
(def app (def app
(let [handler (handler/site app-routes)] (let [handler (handler/site app-routes)]
(fn [request] (fn [request]
(if (get-setting :dev-mode) (if (get-setting :dev-mode)
(handler request) (handler request)
(try (handler request) (try (handler request)
(catch Exception e (catch Exception e
(do (do
;TODO (log e) ;TODO (log e)
(response 500)))))))) (response 500))))))))
(defn -main [& [port]]
(jetty/run-jetty #'app
{:port (if port (Integer/parseInt port) 8080)}))

Loading…
Cancel
Save