blob: a06a4ffc20cb68c4c4f130596532a69d42a13b19 (
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
|
(ns dionysus.web.admin.home
(:require [dionysus.spotify :as dspotify]
[dionysus.web.utils :as dwutils]
[ring.util.response :as ruresp]
[dionysus.web.admin.home.blacklist :as dwahblacklist]
[dionysus.web.admin.home.server-settings :as dwahserver-settings]))
(defn- render [_req]
(let [title (str @dwutils/title " - ADMIN")]
(dwutils/render-page title
[:div {:class "text"}
[:h1 title]
(dwahserver-settings/render-server-settings)
[:h2 "Blacklist"]
(dwahblacklist/render-blacklist-table nil)]
[:script {:src "/assets/htmx.js"}])))
(defn handle [req]
(let [access-token (get-in req [:oauth2/access-tokens :spotify])
page-resp (delay (-> req
render
ruresp/response))]
(cond
(and (nil? access-token) (nil? @dspotify/token))
(ruresp/redirect "/auth")
(nil? @dspotify/token)
(do (reset! dspotify/token access-token)
@page-resp)
:else
@page-resp)))
|