summaryrefslogtreecommitdiff
path: root/src/chef/utils.clj
diff options
context:
space:
mode:
authorTim <contact@bytim.eu>2025-06-14 11:49:28 +0200
committerTim <contact@bytim.eu>2025-06-14 11:49:28 +0200
commit8e23d9dade945f87f5fc7fb15042a53a7eeb9a9e (patch)
treec0f5b6587b6f9f0b591b395c69ad7da08717a30b /src/chef/utils.clj
parent229299146376a2b847f4fe3f331efbd26c0abc70 (diff)
downloadchef-8e23d9dade945f87f5fc7fb15042a53a7eeb9a9e.tar.xz
chef-8e23d9dade945f87f5fc7fb15042a53a7eeb9a9e.zip
Refactor project structure
Diffstat (limited to 'src/chef/utils.clj')
-rw-r--r--src/chef/utils.clj37
1 files changed, 4 insertions, 33 deletions
diff --git a/src/chef/utils.clj b/src/chef/utils.clj
index 22797cb..7329737 100644
--- a/src/chef/utils.clj
+++ b/src/chef/utils.clj
@@ -1,10 +1,5 @@
(ns chef.utils
- (:require [chef.database :as cdb]
- [honey.sql :as sql]
- [next.jdbc :as jdbc]
- [ring.util.response :as ruresp]
- [clojure.string :as cstr])
- (:import java.io.File))
+ (:require [ring.util.response :as ruresp]))
(defn gen-page [title & content]
[:html
@@ -24,25 +19,9 @@
(ruresp/status 302)
(ruresp/header "Location" "/auth"))))
-(defn category-parents [category]
- (loop [parents (list)
- category category]
- (let [updated-parents (conj parents category)]
- (if (not= -1 (:categories/parent category))
- (recur updated-parents
- (->> {:select [:*]
- :from [:categories]
- :where [:= :id (:categories/parent category)]}
- sql/format
- (jdbc/execute! @cdb/db)
- first))
- updated-parents))))
-
-(defn category-path [category]
- (->> category
- category-parents
- (map #(:categories/name %))
- (cstr/join " > ")))
+(defn s->int-or-nil [s]
+ (try (Integer/parseInt s)
+ (catch Exception _ nil)))
(defn parse-ingredients [s]
(->> s
@@ -56,11 +35,3 @@
(->> 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)))