blob: 4083190f032f871b150706add7db0437f3158592 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
(page "admin.html"
(:require [app.rpc :as rpc]
[app.scoreboard :as s]
[cljs.pprint :refer [pprint]]))
(defc token nil)
(defc= logged-in? (not (nil? token)))
(defc= error rpc/error)
(defc= error-message (when error (.-message error)))
(rpc/init)
(html
(head
(link :rel "stylesheet" :type "text/css" :href "css/main.css")
(title "Potluck CTF Adminstration"))
(body
(h1 "Potluck CTF Administration")
(div
:id "error"
:click #(reset! rpc/error nil)
:toggle (cell= (not (nil? rpc/error)))
(text "Error: ~{error-message}"))
(let [token-input (input :name "token")]
(form
:toggle (cell= (not logged-in?))
:submit #(do (reset! token (.-value token-input))
(set! (.-value token-input) nil))
(text "Admin Token:")
token-input
(input :type "submit")))
(let [eval-input (input :name "eval" :size 100)
output (textarea
:value (cell= (with-out-str
(pprint rpc/eval-result))))]
(form
:toggle logged-in?
:submit #(rpc/admin-eval! @token (.-value eval-input))
(text "(eval ")
eval-input
(text ")")
(br)
output))
(form
:toggle logged-in?
:submit #(do (reset! token nil)
(reset! rpc/token-ok false))
(input :type "submit" :value "Logout"))
(h2 "Scoreboard")
(s/scoreboard :scoreboard rpc/scoreboard)))
;; vim: set expandtab ts=2 sw=2 filetype=clojure :
|