Skip to content
Permalink
Browse files

added dev REPL hook

  • Loading branch information...
yogthos committed Mar 17, 2015
1 parent 07675fb commit 7c9cbfbf8c0b97f474b442715733e3ada44c0d32
@@ -1,4 +1,4 @@
(defproject luminus/lein-template "2.0.7"
(defproject luminus/lein-template "2.0.8"
:description "a template for creating Luminus applications"
:url "https://github.com/yogthos/luminus-template"
:license {:name "MIT License"
@@ -59,7 +59,6 @@
(append-options :dev-dependencies cljs-dev-dependencies)
(append-options :plugins [['lein-cljsbuild "1.0.4"]])
(append-options :dev-plugins [['lein-figwheel "0.2.3-SNAPSHOT"]])
(append-options :dev-source-paths ["env/dev/clj"])
(update-in [:clean-targets] (fnil into []) clean-targets)
(assoc
:cljs-build (indent root-indent cljs-build)
@@ -30,6 +30,7 @@
["src/<<sanitized>>/layout.clj" "core/src/layout.clj"]
["src/<<sanitized>>/middleware.clj" "core/src/middleware.clj"]
["src/<<sanitized>>/session.clj" "core/src/session.clj"]
["env/dev/clj/<<sanitized>>/repl.clj" "core/env/repl.clj"]


;;HTML templates
@@ -89,6 +90,7 @@
:project-ns (sanitize-ns name)
:sanitized (name-to-path name)
:year (year)
:dev-source-paths ["env/dev/clj"]
:features (set feature-params)}
unsupported (-> (set feature-params)
(clojure.set/difference supported-features)
@@ -0,0 +1,34 @@
(ns <<name>>.repl
(:use <<name>>.handler
ring.server.standalone
[ring.middleware file-info file]))

(defonce server (atom nil))

(defn get-handler []
;; #'app expands to (var app) so that when we reload our code,
;; the server is forced to re-resolve the symbol in the var
;; rather than having its own copy. When the root binding
;; changes, the server picks it up without having to restart.
(-> #'app
; Makes static assets in $PROJECT_DIR/resources/public/ available.
(wrap-file "resources")
; Content-Type, Content-Length, and Last Modified headers for files in body
(wrap-file-info)))

(defn start-server
"used for starting the server in development mode from REPL"
[& [port]]
(let [port (if port (Integer/parseInt port) 3000)]
(reset! server
(serve (get-handler)
{:port port
:init init
:auto-reload? true
:destroy destroy
:join? false}))
(println (str "You can view the site at http://localhost:" port))))

(defn stop-server []
(.stop @server)
(reset! server nil))
@@ -55,16 +55,11 @@
:env {:production true}
<<cljs-uberjar>>
:aot :all}
:production {:ring {:open-browser? false
:stacktraces? false
:auto-reload? false}}
:dev {:dependencies [[ring-mock "0.1.5"]
[ring/ring-devel "1.3.2"]
[pjstadig/humane-test-output "0.6.0"]
<<dev-dependencies>>]
<% if dev-source-paths %>
:source-paths <<dev-source-paths>>
<% endif %>
<% if dev-plugins %>
:plugins <<dev-plugins>>
<% endif %>
@@ -73,6 +68,7 @@
:figwheel
<<figwheel>>
<% endif %>
:repl-options {:init-ns <<project-ns>>.repl}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]
:env {:dev true}}})
Binary file not shown.
@@ -1,8 +1,11 @@
(ns <<project-ns>>.core
(:require [<<project-ns>>.handler :refer [app]]
[ring.adapter.jetty :refer [run-jetty]])
[ring.adapter.jetty :refer [run-jetty]])
(:gen-class))

(defn -main [& args]
(let [port (Integer/parseInt (or (System/getenv "PORT") "3000"))]
(defn parse-port [port]
(Integer/parseInt (or port (System/getenv "PORT") "3000")))

(defn -main [& [port]]
(let [port (parse-port port)]
(run-jetty app {:port port :join? false})))
@@ -10,4 +10,4 @@

(testing "not-found route"
(let [response (app (request :get "/invalid"))]
(is (= 404 (:status response))))))
(is (= 404 (:status response))))))

0 comments on commit 7c9cbfb

Please sign in to comment.
You can’t perform that action at this time.