From b4d8dc5b74880db64142c6fa6bc453fee037c964 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 19 Sep 2018 00:22:03 +0000 Subject: [PATCH] Add scoreboard plus formatting tweaks --- res/basic.css | 44 ++++++++++++ res/puzzles.html | 81 ++++++++++++++++++++++ res/scoreboard.html | 147 ++++++++++++++++++++++++++++++++++++++++ src/handlers.go | 8 ++- src/static.go | 159 ++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 423 insertions(+), 16 deletions(-) create mode 100644 res/basic.css create mode 100644 res/puzzles.html create mode 100644 res/scoreboard.html diff --git a/res/basic.css b/res/basic.css new file mode 100644 index 0000000..e133165 --- /dev/null +++ b/res/basic.css @@ -0,0 +1,44 @@ +/* http://paletton.com/#uid=63T0u0k7O9o3ouT6LjHih7ltq4c */ +body { + font-family: sans-serif; + max-width: 40em; + background: #282a33; + color: #f6efdc; +} +a:any-link { + color: #8b969a; +} +h1 { + background: #5e576b; + color: #9e98a8; +} +.Fail, .Error { + background: #3a3119; + color: #ffcc98; +} +.Fail:before { + content: "Fail: "; +} +.Error:before { + content: "Error: "; +} +p { + margin: 1em 0em; +} +form, pre { + margin: 1em; +} +input { + padding: 0.6em; + margin: 0.2em; +} +nav { + border: solid black 2px; +} +nav ul, .category ul { + padding: 1em; +} +nav li, .category li { + display: inline; + margin: 1em; +} diff --git a/res/puzzles.html b/res/puzzles.html new file mode 100644 index 0000000..4d1942e --- /dev/null +++ b/res/puzzles.html @@ -0,0 +1,81 @@ + + + + Open Puzzles + + + + + + + +

Open Puzzles

+
+
+
+ + + diff --git a/res/scoreboard.html b/res/scoreboard.html new file mode 100644 index 0000000..9d2d513 --- /dev/null +++ b/res/scoreboard.html @@ -0,0 +1,147 @@ + + + + Open Puzzles + + + + + + + +

Scoreboard

+
+
+
+ + + diff --git a/src/handlers.go b/src/handlers.go index 198c27a..527d4d7 100644 --- a/src/handlers.go +++ b/src/handlers.go @@ -5,9 +5,11 @@ import ( "encoding/json" "fmt" "io" + "io/ioutil" "log" "net/http" "os" + "rand" "strconv" "strings" ) @@ -285,13 +287,15 @@ func (ctx Instance) puzzlesHandler(w http.ResponseWriter, req *http.Request) { } func (ctx Instance) pointsHandler(w http.ResponseWriter, req *http.Request) { - log := ctx.PointsLog() - jlog, err := json.Marshal(log) + plog := ctx.PointsLog() + jlog, err := json.Marshal(plog) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } + // XXX: go through plog, building an array of teams, so we can anonymize team IDs + w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) diff --git a/src/static.go b/src/static.go index ee788ca..4176ef4 100644 --- a/src/static.go +++ b/src/static.go @@ -97,14 +97,14 @@ h1 { background: #5e576b; color: #9e98a8; } -h1.Fail, h1.Error { +.Fail, .Error { background: #3a3119; color: #ffcc98; } -h1.Fail:before { +.Fail:before { content: "Fail: "; } -h1.Error:before { +.Error:before { content: "Error: "; } p { @@ -117,15 +117,15 @@ input { padding: 0.6em; margin: 0.2em; } -li { - margin: 0.5em 0em; -} nav { border: solid black 2px; } -nav li { +nav ul, .category ul { + padding: 1em; +} +nav li, .category li { display: inline; - margin: 2em; + margin: 1em; } `, ) @@ -158,7 +158,136 @@ func staticScoreboard(w http.ResponseWriter) { ShowHtml( w, Success, "Scoreboard", - "XXX: This would be the scoreboard", + ` +
+
+
+ + `, ) } @@ -167,11 +296,12 @@ func staticPuzzles(w http.ResponseWriter) { w, Success, "Open Puzzles", ` -
+
+
+
`, )