blob: 3170be95b6928ac4e3f1b166c36baa9ce93344cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
(ns chef.utils
(:require [ring.util.response :as ruresp]))
(defn gen-page [title & content]
[:html
[:head
[:meta {:name "viewport" :content "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"}]
[:title title]
[:link {:rel :stylesheet :href "/static/style.css"}]
[:meta {:http-equiv "content-type" :content "text/html; charset=utf-8"}]]
(apply conj [:body] content [[:script {:src "/static/htmx.js"}]])])
(defmacro auth-only [request & body]
`(if (some? (get-in ~request [:session :oauth-token]))
(do ~@body)
~(-> (ruresp/response "Unauthorized.")
(ruresp/status 401))))
|