diff options
Diffstat (limited to 'src/chef/utils.clj')
-rw-r--r-- | src/chef/utils.clj | 37 |
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))) |