Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/io/perun.clj
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
pod (create-pod images-resize-deps)
files (->> fileset
boot/user-files
(boot/by-ext ["png" "jpeg" "jpg"])
(boot/by-ext perun/images-exts)
(map add-filedata))
updated-files (pod/with-call-in @pod
(io.perun.contrib.images-resize/images-resize ~(.getPath tmp) ~files ~options))]
Expand Down Expand Up @@ -196,6 +196,25 @@
(perun/report-debug "gravatar" "found gravatars" (map target-key updated-files))
(perun/set-meta fileset updated-files)))))


(deftask images
"Assoc list of :images to the post"
[]
(boot/with-pre-wrap fileset
(let [files (perun/get-meta fileset)
images (filter
(fn [file]
(contains? perun/images-exts (perun/extension file)))
files)
groupped-files (group-by :parent-path images)
assoc-images (fn [file]
(if (not? (nil? (:content file)))
(assoc file :images (get groupped-files (:parent-path file)))
file))
updated-files (map assoc-images files)]
(perun/report-info "images" "add associated images to %s files" (count updated-files))
(perun/set-meta fileset updated-files))))

;; Should be handled by more generic filterer options to other tasks
(deftask draft
"Exclude draft files"
Expand Down
2 changes: 2 additions & 0 deletions src/io/perun/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
(defn set-global-meta [fileset data]
(vary-meta fileset assoc +global-meta-key+ data))

(def images-exts #{"jpg" "svg" "png" "gif" "JPG" "SVG" "PNG" "GIF"})

(defn report-info [task msg & args]
(apply u/info
(str
Expand Down