grub-fork/src-clj/grub/core.clj

41 lines
1.1 KiB
Clojure
Raw Normal View History

2013-07-24 17:39:02 +00:00
(ns grub.core
(:require [grub.websocket :as ws]
[grub.db :as db]
[ring.middleware.reload :as reload]
[compojure.core :refer [defroutes GET POST]]
[compojure.handler :as handler]
2013-07-24 18:38:14 +00:00
[compojure.route :as route]
[org.httpkit.server :as httpkit]
2013-07-24 18:38:14 +00:00
[hiccup
[page :refer [html5]]
[page :refer [include-js include-css]]]))
2013-07-24 18:38:14 +00:00
(defn index-page []
(html5
2013-07-24 19:43:26 +00:00
[:head
[:title "Grub"]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1.0"}]
2013-08-04 18:15:56 +00:00
(include-css "/css/bootstrap.css")
(include-css "/css/styles.css")]
[:body
(include-js "http://code.jquery.com/jquery.js")
(include-js "/js/bootstrap.js")
(include-js "/js/main.js")]))
2013-07-24 18:38:14 +00:00
(defroutes routes
(GET "/ws" [] ws/websocket-handler)
2013-07-24 18:38:14 +00:00
(GET "/" [] (index-page))
(route/files "/")
(route/not-found "<p>Page not found.</p>"))
2013-07-24 17:39:02 +00:00
2013-07-24 18:38:14 +00:00
(def app
(let [dev? true]
(if dev?
2013-08-04 19:22:58 +00:00
(reload/wrap-reload (handler/site #'routes) {:dirs ["src-clj"]})
(handler/site routes))))
2013-07-24 17:39:02 +00:00
2013-07-24 18:38:14 +00:00
(defn -main [& args]
2013-08-17 10:05:05 +00:00
(db/connect-and-handle-events)
(httpkit/run-server app {:port 3000}))