Add ip binding and handle errors
This commit is contained in:
parent
23e76b5e69
commit
b4377c371a
5 changed files with 35 additions and 35 deletions
3
env/dev/resources/config.edn
vendored
3
env/dev/resources/config.edn
vendored
|
@ -1,5 +1,6 @@
|
|||
{:dev true
|
||||
:port 3000
|
||||
:host "0.0.0.0"
|
||||
:creator-password "creator"
|
||||
:user-password "user"
|
||||
;; when :nrepl-port is set the application starts the nREPL server on load
|
||||
|
@ -10,5 +11,5 @@
|
|||
:basepath "http://localhost"
|
||||
:authors ["Aaron Fischer"]
|
||||
|
||||
:images_per_page 25
|
||||
:images-per-page 25
|
||||
}
|
||||
|
|
3
env/prod/resources/config.edn
vendored
3
env/prod/resources/config.edn
vendored
|
@ -2,11 +2,12 @@
|
|||
:creator-password "xxx"
|
||||
:user-password "yyy"
|
||||
:port 3000
|
||||
:host "0.0.0.0"
|
||||
|
||||
:database-url "jdbc:sqlite:yenu.db"
|
||||
|
||||
:basepath "http://localhost"
|
||||
:authors ["Aaron Fischer"]
|
||||
|
||||
:images_per_page 25
|
||||
:images-per-page 25
|
||||
}
|
||||
|
|
|
@ -4,16 +4,11 @@
|
|||
[luminus.http-server :as http]
|
||||
[luminus-migrations.core :as migrations]
|
||||
[yenu.config :refer [env]]
|
||||
[clojure.tools.cli :refer [parse-opts]]
|
||||
[clojure.tools.logging :as log]
|
||||
[yenu.helpers.images :as image]
|
||||
[mount.core :as mount])
|
||||
(:gen-class))
|
||||
|
||||
(def cli-options
|
||||
[["-p" "--port PORT" "Port number"
|
||||
:parse-fn #(Integer/parseInt %)]])
|
||||
|
||||
(mount/defstate ^{:on-reload :noop}
|
||||
http-server
|
||||
:start
|
||||
|
@ -41,7 +36,6 @@
|
|||
|
||||
(defn start-app [args]
|
||||
(doseq [component (-> args
|
||||
(parse-opts cli-options)
|
||||
mount/start-with-args
|
||||
:started)]
|
||||
(log/info component "started"))
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
(page (inc current) (= current num) "disabled" (h/html "Weiter " [:span.fa.fa-arrow-right]))])))
|
||||
|
||||
(defn index-page [current request]
|
||||
(let [image-count (:images_per_page env)
|
||||
(let [image-count (:images-per-page env)
|
||||
offset (* (dec current) image-count)
|
||||
pages (number-of-pages image-count)
|
||||
images (db/get-all-images {:offset offset :count image-count})]
|
||||
|
@ -69,6 +69,7 @@
|
|||
next-img (db/get-next-image {:image-date (:created_at image)})
|
||||
prev-img (db/get-prev-image {:image-date (:created_at image)})
|
||||
saved-author (get-in request [:cookies "author" :value])]
|
||||
(if (not (nil? image))
|
||||
(layout/render-file "detail.html"
|
||||
{:image image
|
||||
:flash (:flash request)
|
||||
|
@ -76,7 +77,9 @@
|
|||
:prev-image prev-img
|
||||
:tags (db/get-tags-for-image {:id (:id image)})
|
||||
:saved-author saved-author
|
||||
:comments (db/get-comments-for-image {:image_id (:id image)})})))
|
||||
:comments (db/get-comments-for-image {:image_id (:id image)})})
|
||||
(layout/error-page {:status 404
|
||||
:title "page not found"}))))
|
||||
|
||||
(defn add-comment! [image-id request]
|
||||
(let [author (:author (:params request))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
basepath=http://localhost
|
||||
basepath=http://127.0.0.1
|
||||
host=0.0.0.0
|
||||
port=3000
|
||||
|
||||
# Passwords
|
||||
|
@ -6,5 +7,5 @@ user-password=user
|
|||
creator-password=creator
|
||||
|
||||
# Content stuff
|
||||
images_per_page=25
|
||||
images-per-page=25
|
||||
authors=Aaron Fischer,Beatrice Fischer
|
||||
|
|
Loading…
Reference in a new issue