Update image handler to serve files relatively

main
Eric Ihli 3 years ago
parent 6f35ae4e05
commit 59c272ece9

@ -36,3 +36,21 @@ The world's largest metal limericks archive on the Web.
Requires [[https://github.com/tachyons-css/tachyons/][Tachyons CSS]]. There is a symlink in ~web/resources/public~ to the pre-built ~tachyons.css~ and ~tachyons.min.css~ found in the repo.
Build ~.jar~ with ~clojure -X:depstar uberjar :jar prhyme.jar~.
* Deployment
Since I'm developing this independently, it's not a very robust deployment system.
It's nice to have some parts of the repo available on the server; the db/kv scripts for example.
But obviously the album images and the data in the db/kv are going to be different between local and prod.
You can use ~rsync~ with ~--exclude~ to only sync over the code bits.
~rsync --exclude '*/data/*' --exclude '*/images/*' -aLP ./ root@darklimericks.com:/root/darklimericks/~
Note the ~-L~ to follow symlinks. Locally, I'm symlinking tachyons.css.
The other shortcut I'm taking is that images are stored and served relative to the path of the running application.
That means you need to launch the jar file from the ~web~ directory.

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

@ -48,8 +48,8 @@
artists-by-album))})))
(def resource-handler (ring/create-resource-handler {:allow-symlinks? true}))
(def file-handler (ring/create-resource-handler {:allow-symlinks? true
:root "public"}))
(def file-handler (ring/create-file-handler {:allow-symlinks? true
:root "resources/public"}))
(defn limerick-generation-post-handler
[db cache]

@ -139,9 +139,10 @@
[artist-id album-id] album-artist
album (albums/album db album-id)]
(when (:new-album (meta album-artist))
(identicon/generate (-> (:album/name album)
string/lower-case
(string/replace #" " "-")) 128))
(let [icon (identicon/generate
(-> (:album/name album)
string/lower-case
(string/replace #" " "-")) 128)]))
(db.limericks/insert-user-limerick
db
session-id

@ -106,18 +106,30 @@
(defn generate
"Make a new avatar."
[identifier size]
(let
[tile-size (quot size tiles-per-side)
md5 (digest/md5 identifier)
icon (BufferedImage. size size BufferedImage/TYPE_INT_RGB)
[r g b] (get-color (first (to-numbers md5)))
color (Color. r g b)
draw (.createGraphics icon)]
(let [tile-size (quot size tiles-per-side)
md5 (digest/md5 identifier)
icon (BufferedImage. size size BufferedImage/TYPE_INT_RGB)
[r g b] (get-color (first (to-numbers md5)))
color (Color. r g b)
draw (.createGraphics icon)]
(fill-background draw size)
(.setColor draw color)
(draw-it draw tile-size 0 (to-bools md5))
(ImageIO/write icon "png" (File. (file-name identifier size)))
file-name))
(defn generate-sans-write
"Make a new avatar."
[identifier size]
(let [tile-size (quot size tiles-per-side)
md5 (digest/md5 identifier)
icon (BufferedImage. size size BufferedImage/TYPE_INT_RGB)
[r g b] (get-color (first (to-numbers md5)))
color (Color. r g b)
draw (.createGraphics icon)]
(fill-background draw size)
(.setColor draw color)
(draw-it draw tile-size 0 (to-bools md5))))
(comment
(generate "foobar-bazz" 128))

Loading…
Cancel
Save