diff options
author | Tim <contact@bytim.eu> | 2025-05-30 17:09:57 +0200 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-05-30 17:09:57 +0200 |
commit | ea7b0078478ba7925f2db3cb1fa038e8a3d85ab8 (patch) | |
tree | 41b18b1bbd073521891524ee8d32ecc381874a11 /src/chef/utils.clj | |
parent | d1699f9af8cb7457f248bf71197535221f3d9472 (diff) | |
download | chef-ea7b0078478ba7925f2db3cb1fa038e8a3d85ab8.tar.xz chef-ea7b0078478ba7925f2db3cb1fa038e8a3d85ab8.zip |
Add features to manage recipes in admin interface
Diffstat (limited to 'src/chef/utils.clj')
-rw-r--r-- | src/chef/utils.clj | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/chef/utils.clj b/src/chef/utils.clj index f909c52..1ea5136 100644 --- a/src/chef/utils.clj +++ b/src/chef/utils.clj @@ -1,5 +1,9 @@ (ns chef.utils - (:require [ring.util.response :as ruresp])) + (:require [chef.database :as cdb] + [honey.sql :as sql] + [next.jdbc :as jdbc] + [ring.util.response :as ruresp] + [clojure.string :as cstr])) (defn gen-page [title & content] [:html @@ -16,3 +20,18 @@ ~(-> (ruresp/response "Unauthorized.") (ruresp/status 302) (ruresp/header "Location" "/auth")))) + +(defn category-path [category] + (cstr/join " > " + (loop [path (list) + category category] + (let [new-path (conj path (:categories/name category))] + (if (some? (:categories/parent category)) + (recur new-path + (->> {:select [:*] + :from [:categories] + :where [:= :id (:categories/parent category)]} + sql/format + (jdbc/execute! @cdb/db) + first)) + new-path))))) |