diff options
author | Morgan <m@morganastra.me> | 2015-03-03 08:27:23 +0000 |
---|---|---|
committer | Morgan <m@morganastra.me> | 2015-03-03 08:27:23 +0000 |
commit | 745314c13d48063c47bb4f8887ca099b976e01b8 (patch) | |
tree | 15c714cb46c2f246fdfa4b51741c4737b69d2caa |
initialize repo
-rw-r--r-- | Procfile | 1 | ||||
-rw-r--r-- | project.clj | 18 | ||||
-rw-r--r-- | resources/404.html | 21 | ||||
-rw-r--r-- | resources/500.html | 20 | ||||
-rw-r--r-- | src/pronouns/web.clj | 42 |
5 files changed, 102 insertions, 0 deletions
diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..e696eee --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: java $JVM_OPTS -cp target/pronouns-standalone.jar clojure.main -m pronouns.web diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..ea671fd --- /dev/null +++ b/project.clj @@ -0,0 +1,18 @@ +(defproject pronouns "1.0.0-SNAPSHOT" + :description "FIXME: write description" + :url "http://pronouns.herokuapp.com" + :license {:name "FIXME: choose" + :url "http://example.com/FIXME"} + :dependencies [[org.clojure/clojure "1.6.0"] + [compojure "1.1.8"] + [ring/ring-jetty-adapter "1.2.2"] + [ring.middleware.logger "0.5.0"] + [ring/ring-devel "1.2.2"] + [ring-basic-authentication "1.0.5"] + [environ "0.5.0"] + [com.cemerick/drawbridge "0.0.6"]] + :min-lein-version "2.0.0" + :plugins [[environ/environ.lein "0.2.1"]] + :hooks [environ.leiningen.hooks] + :uberjar-name "pronouns-standalone.jar" + :profiles {:production {:env {:production true}}}) diff --git a/resources/404.html b/resources/404.html new file mode 100644 index 0000000..01b164c --- /dev/null +++ b/resources/404.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <title>Page Not Found</title> + <style type="text/css"> + body { + font-family: "Ubuntu Light", helvetica, sans-serif; + width: 960px; + margin: 3em auto; + } + </style> +</head> +<body> + <!-- TODO: replace this with something that matches your app style --> + <h1>Page Not Found</h1> + <p>There's no page at the address you requested. If you entered it + by hand, check for typos. If you followed a link or a bookmark, + it may need to be updated.</p> +</body> +</html> diff --git a/resources/500.html b/resources/500.html new file mode 100644 index 0000000..cb6474f --- /dev/null +++ b/resources/500.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <title>Error</title> + <style type="text/css"> + body { + font-family: "Ubuntu Light", helvetica, sans-serif; + width: 960px; + margin: 3em auto; + } + </style> +</head> +<body> + <!-- TODO: replace this with something that matches your app style --> + <h1>Error</h1> + <p>Something went wrong. Try again, and if the problem persists + please contact support.</p> +</body> +</html> diff --git a/src/pronouns/web.clj b/src/pronouns/web.clj new file mode 100644 index 0000000..849465a --- /dev/null +++ b/src/pronouns/web.clj @@ -0,0 +1,42 @@ +(ns pronouns.web + (:require [compojure.core :refer [defroutes GET PUT POST DELETE ANY]] + [compojure.handler :refer [site]] + [compojure.route :as route] + [clojure.java.io :as io] + [ring.middleware.logger :as logger] + [ring.middleware.stacktrace :as trace] + [ring.middleware.session :as session] + [ring.middleware.session.cookie :as cookie] + [ring.adapter.jetty :as jetty] + [environ.core :refer [env]])) + +(def config {:server-port 5000}) + +(defroutes app-routes + (GET "/" [] + {:status 200 + :headers {"Content-Type" "text/plain"} + :body "a blurb explaining how to use this site"}) + (ANY "*" [] + (route/not-found (slurp (io/resource "404.html"))))) + +(defn wrap-error-page [handler] + (fn [req] + (try (handler req) + (catch Exception e + {:status 500 + :headers {"Content-Type" "text/html"} + :body (slurp (io/resource "500.html"))})))) + +(def app + (-> app-routes + ; logger/wrap-with-logger + wrap-error-page + trace/wrap-stacktrace)) + +(defn -main [] + (jetty/run-jetty app {:port (:server-port config)})) + +;; For interactive development: +;; (.stop server) +;; (def server (-main)) |