From 745314c13d48063c47bb4f8887ca099b976e01b8 Mon Sep 17 00:00:00 2001 From: Morgan Date: Tue, 3 Mar 2015 08:27:23 +0000 Subject: [PATCH] initialize repo --- Procfile | 1 + project.clj | 18 ++++++++++++++++++ resources/404.html | 21 +++++++++++++++++++++ resources/500.html | 20 ++++++++++++++++++++ src/pronouns/web.clj | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 Procfile create mode 100644 project.clj create mode 100644 resources/404.html create mode 100644 resources/500.html create mode 100644 src/pronouns/web.clj 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 @@ + + + + + Page Not Found + + + + +

Page Not Found

+

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.

+ + 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 @@ + + + + + Error + + + + +

Error

+

Something went wrong. Try again, and if the problem persists + please contact support.

+ + 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))