Skip to content

instant-pdf is at heroku #1

Merged
merged 2 commits into from May 14, 2012
View
1 Procfile
@@ -0,0 +1 @@
+web: lein trampoline run -m app.server
View
3 project.clj
@@ -7,6 +7,7 @@
[markdown-clj "0.7"]
[clj-pdf "0.7.5"]
[ring/ring-servlet "1.1.0"]
- [com.lowagie/itext "2.1.7"]]
+ [com.lowagie/itext "2.1.7"]
+ [ring/ring-jetty-adapter "1.1.0"]]
:dev-dependencies [[lein-ring "0.7.0"]]
:ring {:handler app.routes/app})
View
10 src/app/server.clj
@@ -0,0 +1,10 @@
+(ns app.server
+ (:require [app.routes :as routes]
+ [ring.adapter.jetty :as ring]))
+
+(defn start [port]
+ (ring/run-jetty #'routes/app {:port (or port 8080) :join? false}))
+
+(defn -main []
+ (let [port (Integer. (System/getenv "PORT"))]
+ (start port)))
View
10 src/app/views.clj
@@ -1,17 +1,21 @@
(ns app.views
(:use [hiccup core page form] clojure.data.json markdown)
(:require [clj-pdf.core :as pdf]
- [ring.util.response :as response])
+ [ring.util.response :as response]
+ [clojure.java.io :as io])
(:import [java.io File StringWriter]))
+
(defn- get-resource-stream [context resource]
(clojure.java.io/reader
- (.getResourceAsStream context
+ (if-not (nil? context)
+ (.getResourceAsStream context
(str File/separator
"WEB-INF" File/separator
"classes" File/separator
"public" File/separator
- resource))))
+ resource))
+ (io/resource (str "public/" resource)))))
(defn- read-help [context]
(with-open [in (get-resource-stream context "README.md")]
Something went wrong with that request. Please try again.