diff options
author | Tim <contact@bytim.eu> | 2025-06-07 13:09:24 +0200 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-06-07 13:09:24 +0200 |
commit | 294f71fb3c5ca3f0fee62e70c9c6a3427a9afc12 (patch) | |
tree | a9e0ca6460ce9361b967b42c59572bc053633775 /src/chef/utils.clj | |
parent | 82da261f168454cd606f4f150313844b9d4b9eea (diff) | |
download | chef-294f71fb3c5ca3f0fee62e70c9c6a3427a9afc12.tar.xz chef-294f71fb3c5ca3f0fee62e70c9c6a3427a9afc12.zip |
Add features to upload and delete thumbnails
Diffstat (limited to 'src/chef/utils.clj')
-rw-r--r-- | src/chef/utils.clj | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/chef/utils.clj b/src/chef/utils.clj index 7ccaf88..e2725ce 100644 --- a/src/chef/utils.clj +++ b/src/chef/utils.clj @@ -3,7 +3,8 @@ [honey.sql :as sql] [next.jdbc :as jdbc] [ring.util.response :as ruresp] - [clojure.string :as cstr])) + [clojure.string :as cstr]) + (:import java.io.File)) (defn gen-page [title & content] [:html @@ -54,3 +55,11 @@ (->> s (re-matches #"(([A-z0-9 ]*)=([0-9]*) ?([A-z]*)\n?)*") some?))) + +(defn get-thumbnail-file [recipe] + (let [thumbnails-folder (File. "./thumbnails/")] + (->> thumbnails-folder + .listFiles + (filter #(cstr/starts-with? (.getName ^File %) + (str (:recipes/id recipe) "."))) + first))) |