summaryrefslogtreecommitdiff
path: root/src/chef/pages/recipe.clj
blob: 71dd4b2629aa492afc9884fce977d07a511280a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(ns chef.pages.recipe
  (:require [chef.database :as cdb]
            [chef.utils :as cutils]
            [hiccup2.core :as html]
            [honey.sql :as sql]
            [next.jdbc :as jdbc]
            [ring.util.response :as ruresp]))

(defn- render [recipe]
  (cutils/gen-page (str "chef - " (:recipes/title recipe))
                   [:div {:style {:margin-left "1em"}}
                    [:div
                     [:h1 {:style {:display      :inline-block
                                   :margin-right "0.5em"}}
                      (:recipes/title recipe)]
                     [:i (cutils/category-path (->> {:select [:*]
                                                     :from   [:categories]
                                                     :where  [:= :id (:recipes/category recipe)]}
                                                    sql/format
                                                    (jdbc/execute! @cdb/db)
                                                    first))]]
                    [:b "TODO"]]))

(defn handler [req]
  (->> {:select [:*]
        :from   [:recipes]
        :where  [:= :id (get-in req [:path-params :id])]}
       sql/format
       (jdbc/execute! @cdb/db)
       first
       render
       html/html
       str
       ruresp/response))