From 294f71fb3c5ca3f0fee62e70c9c6a3427a9afc12 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 7 Jun 2025 13:09:24 +0200 Subject: Add features to upload and delete thumbnails --- src/chef/utils.clj | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/chef/utils.clj') 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))) -- cgit v1.2.3