From 635cd54b4fd63276dc79a1f05456807889c9dab6 Mon Sep 17 00:00:00 2001 From: Brent Hagany Date: Fri, 13 Jan 2017 19:13:49 -0600 Subject: [PATCH 1/5] Correct docstring for `images-resize`, re: generated file name --- src/io/perun.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/perun.clj b/src/io/perun.clj index a97eea16..c1dfb8a9 100644 --- a/src/io/perun.clj +++ b/src/io/perun.clj @@ -98,7 +98,7 @@ (deftask images-resize "Resize images to the provided resolutions. Each image file would have resolution appended to it's name: - e.x. san-francisco.jpg would become san-francisco-3840.jpg" + e.x. san-francisco.jpg would become san-francisco_3840.jpg" [o out-dir OUTDIR str "the output directory" r resolutions RESOLUTIONS #{int} "resoulitions to which images should be resized"] (boot/with-pre-wrap fileset From e12c7105bdcacecb506225b4091b83f46f1266fa Mon Sep 17 00:00:00 2001 From: Brent Hagany Date: Fri, 13 Jan 2017 19:14:14 -0600 Subject: [PATCH 2/5] Actually set metadata in images-resize --- src/io/perun.clj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/io/perun.clj b/src/io/perun.clj index c1dfb8a9..bd0bc437 100644 --- a/src/io/perun.clj +++ b/src/io/perun.clj @@ -113,8 +113,9 @@ updated-files (pod/with-call-in @pod (io.perun.contrib.images-resize/images-resize ~(.getPath tmp) ~files ~options))] (perun/report-debug "images-resize" "new resized images" updated-files) - (pm/set-meta fileset updated-files) - (commit fileset tmp)))) + (-> fileset + (commit tmp) + (pm/set-meta updated-files))))) (def ^:private markdown-deps '[[org.pegdown/pegdown "1.6.0"] From fef47eb4f5a021960673296e41f546d4dd02680c Mon Sep 17 00:00:00 2001 From: Brent Hagany Date: Fri, 13 Jan 2017 19:15:20 -0600 Subject: [PATCH 3/5] Allow images to be in the fileset root directory --- src/io/perun.clj | 2 +- src/io/perun/contrib/images_resize.clj | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/io/perun.clj b/src/io/perun.clj index bd0bc437..8ec4aade 100644 --- a/src/io/perun.clj +++ b/src/io/perun.clj @@ -456,7 +456,7 @@ Returns a boot `with-pre-wrap` result" [render-paths-fn options tracer] - (let [tmp (boot/tmp-dir!)] + (let [tmp (boot/tmp-dir!)] (boot/with-pre-wrap fileset (let [new-metadata (-> fileset (render-paths-fn options) diff --git a/src/io/perun/contrib/images_resize.clj b/src/io/perun/contrib/images_resize.clj index b5832bd7..6ecdc947 100644 --- a/src/io/perun/contrib/images_resize.clj +++ b/src/io/perun/contrib/images_resize.clj @@ -17,9 +17,10 @@ (perun/extension file-path))) (defn ^String new-image-filepath [file-path filename new-filename] - (str (perun/parent-path file-path filename) - "/" - new-filename)) + (perun/relativize-url + (str (perun/parent-path file-path filename) + "/" + new-filename))) (defn write-file [options tmp file ^BufferedImage buffered-file resolution] (let [filepath (:path file) From 77af15b0663f1ad25f8d314e58ef504d9cab7ab2 Mon Sep 17 00:00:00 2001 From: Brent Hagany Date: Fri, 13 Jan 2017 19:15:47 -0600 Subject: [PATCH 4/5] Code cleanup committed in the process of bug hunting --- src/io/perun/contrib/images_resize.clj | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/io/perun/contrib/images_resize.clj b/src/io/perun/contrib/images_resize.clj index 6ecdc947..a4236e48 100644 --- a/src/io/perun/contrib/images_resize.clj +++ b/src/io/perun/contrib/images_resize.clj @@ -29,12 +29,11 @@ filepath-with-resolution (new-image-filepath filepath filename new-filename) image-filepath (perun/create-filepath (:out-dir options) filepath-with-resolution) new-file (io/file tmp image-filepath)] - (do - (io/make-parents new-file) - (ImageIO/write buffered-file (:extension file) new-file) - {:short-name (perun/filename new-filename) - :filename new-filename - :path image-filepath}))) + (io/make-parents new-file) + (ImageIO/write buffered-file (:extension file) new-file) + {:short-name (perun/filename new-filename) + :filename new-filename + :path image-filepath})) (defn resize-to [tgt-path file options resolution] (let [io-file (-> file :full-path io/file) @@ -43,18 +42,13 @@ new-dimensions (iu/dimensions resized-buffered-image) new-meta (write-file options tgt-path file resized-buffered-image resolution) dimensions {:width (first new-dimensions) :height (second new-dimensions)}] - (merge file new-meta dimensions))) + (merge file new-meta dimensions))) (defn process-image [tgt-path file options] (perun/report-debug "image-resize" "resizing" (:path file)) - (let [resolutions (:resolutions options)] - (doall - (clojure.core/pmap - (fn [resolution] - (resize-to tgt-path file options resolution)) - resolutions)))) + (pmap #(resize-to tgt-path file options %) (:resolutions options))) (defn images-resize [tgt-path files options] - (let [updated-files (flatten (doall (map #(process-image tgt-path % options) files)))] + (let [updated-files (doall (mapcat #(process-image tgt-path % options) files))] (perun/report-info "image-resize" "processed %s image files" (count files)) updated-files)) From 477ab0f3f7e150b4c9bf3676288caea3f1e8c6b1 Mon Sep 17 00:00:00 2001 From: Brent Hagany Date: Fri, 13 Jan 2017 19:16:09 -0600 Subject: [PATCH 5/5] Use correct namespace... confused about this one --- src/io/perun/gravatar.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/perun/gravatar.clj b/src/io/perun/gravatar.clj index 9ac2d5c3..40831170 100644 --- a/src/io/perun/gravatar.clj +++ b/src/io/perun/gravatar.clj @@ -1,6 +1,6 @@ (ns io.perun.gravatar (:require [io.perun.core :as perun] - [gravatar :as gr])) + [gravatar.core :as gr])) (defn add-gravatar [file source-prop target-prop] (if-let [email (get file source-prop)]