Make yenu work out of the box
This commit is contained in:
parent
44546efb0d
commit
1877d81ac7
7 changed files with 34 additions and 11 deletions
5
env/dev/resources/config.edn
vendored
5
env/dev/resources/config.edn
vendored
|
@ -3,4 +3,7 @@
|
|||
:creator-password "creator"
|
||||
:user-password "user"
|
||||
;; when :nrepl-port is set the application starts the nREPL server on load
|
||||
:nrepl-port 7000}
|
||||
:nrepl-port 7000
|
||||
|
||||
:database-url "jdbc:sqlite:yenu_dev.db"
|
||||
}
|
||||
|
|
5
env/prod/resources/config.edn
vendored
5
env/prod/resources/config.edn
vendored
|
@ -1,4 +1,7 @@
|
|||
{:production true
|
||||
:creator-password "xxx"
|
||||
:user-password "yyy"
|
||||
:port 3000}
|
||||
:port 3000
|
||||
|
||||
:database-url "jdbc:sqlite:yenu.db"
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
[mount.core :refer [args defstate]]))
|
||||
|
||||
(defstate env :start (load-config
|
||||
:merge
|
||||
[(args)
|
||||
(source/from-system-props)
|
||||
(source/from-env)]))
|
||||
:merge
|
||||
[(args)
|
||||
(source/from-system-props)
|
||||
(source/from-props-file "yenu.properties")
|
||||
(source/from-env)]))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[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))
|
||||
|
||||
|
@ -51,8 +52,9 @@
|
|||
(some #{"migrate" "rollback"} args)
|
||||
(do
|
||||
(mount/start #'yenu.config/env)
|
||||
(image/create-needed-folders)
|
||||
(migrations/migrate args (select-keys env [:database-url]))
|
||||
(System/exit 0))
|
||||
:else
|
||||
(start-app args)))
|
||||
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
(.getPath (io/file (env :user-dir) "data" postfix)))))
|
||||
|
||||
(defn create-needed-folders []
|
||||
(if (not (fs/exists? (data-path "to-process")))
|
||||
(if-not (fs/exists? (data-path "to-process"))
|
||||
(fs/mkdirs (data-path "to-process")))
|
||||
(if (not (fs/exists? (data-path "gallery")))
|
||||
(map #(fs/mkdirs (data-path "gallery" %))
|
||||
["normal" "raw" "thumbnails"])))
|
||||
(if-not (fs/exists? (data-path "gallery"))
|
||||
(run! #(fs/mkdirs (data-path "gallery" %))
|
||||
["normal" "raw" "thumbnails"])))
|
||||
|
||||
(defn target-image-filename [image-file-path]
|
||||
(let [file (io/file image-file-path)]
|
||||
|
@ -77,6 +77,9 @@
|
|||
(fs/delete file)
|
||||
false))))
|
||||
|
||||
(defn remove-temp-image [filepath]
|
||||
(fs/delete filepath))
|
||||
|
||||
(defn scale-image-and-save [filepath]
|
||||
(let [image-hash (target-image-filename filepath)
|
||||
file-extension (fs/extension filepath)
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
(POST "/upload" [file title description tags]
|
||||
(let [filename (upload-file file)
|
||||
imghash (images/scale-image-and-save filename)]
|
||||
(images/remove-temp-image filename)
|
||||
(if imghash
|
||||
(do
|
||||
(add-image-to-database imghash title description tags)
|
||||
|
|
10
yenu.properties
Normal file
10
yenu.properties
Normal file
|
@ -0,0 +1,10 @@
|
|||
domain=localhost
|
||||
port=3000
|
||||
|
||||
# Passwords
|
||||
user-password=user
|
||||
creator-password=creator
|
||||
|
||||
# Content stuff
|
||||
images_per_page=25
|
||||
footer=© 2013 - 2017 Aaron & Beatrice Fischer
|
Loading…
Reference in a new issue