From 8e92287880895931d077baf1a9f05f88b7371c7c Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Wed, 30 Dec 2015 13:50:22 -0600 Subject: Working scoreboard --- .gitignore | 3 + README.md | 23 + assets/css/main.css | 35 ++ .../proximanova-bold/proximanova-bold.eot | Bin 0 -> 23694 bytes .../proximanova-bold/proximanova-bold.svg | 536 ++++++++++++++++++++ .../proximanova-bold/proximanova-bold.ttf | Bin 0 -> 51352 bytes .../proximanova-bold/proximanova-bold.woff | Bin 0 -> 26820 bytes .../proximanova-light/proximanova-light.eot | Bin 0 -> 23370 bytes .../proximanova-light/proximanova-light.svg | 543 ++++++++++++++++++++ .../proximanova-light/proximanova-light.ttf | Bin 0 -> 51232 bytes .../proximanova-light/proximanova-light.woff | Bin 0 -> 26380 bytes .../proximanova-regular/proximanova-regular.eot | Bin 0 -> 23465 bytes .../proximanova-regular/proximanova-regular.svg | 545 +++++++++++++++++++++ .../proximanova-regular/proximanova-regular.ttf | Bin 0 -> 51648 bytes .../proximanova-regular/proximanova-regular.woff | Bin 0 -> 26616 bytes .../proximanova-semibold/proximanova-semibold.eot | Bin 0 -> 23670 bytes .../proximanova-semibold/proximanova-semibold.svg | 536 ++++++++++++++++++++ .../proximanova-semibold/proximanova-semibold.ttf | Bin 0 -> 51492 bytes .../proximanova-semibold/proximanova-semibold.woff | Bin 0 -> 26708 bytes boot.properties | 4 + build.boot | 46 ++ src/app/api.clj | 6 + src/app/handler.clj | 19 + src/app/rpc.cljs | 17 + src/index.cljs.hl | 73 +++ 25 files changed, 2386 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 assets/css/main.css create mode 100644 assets/fonts/proximanova/proximanova-bold/proximanova-bold.eot create mode 100644 assets/fonts/proximanova/proximanova-bold/proximanova-bold.svg create mode 100644 assets/fonts/proximanova/proximanova-bold/proximanova-bold.ttf create mode 100644 assets/fonts/proximanova/proximanova-bold/proximanova-bold.woff create mode 100644 assets/fonts/proximanova/proximanova-light/proximanova-light.eot create mode 100644 assets/fonts/proximanova/proximanova-light/proximanova-light.svg create mode 100644 assets/fonts/proximanova/proximanova-light/proximanova-light.ttf create mode 100644 assets/fonts/proximanova/proximanova-light/proximanova-light.woff create mode 100644 assets/fonts/proximanova/proximanova-regular/proximanova-regular.eot create mode 100644 assets/fonts/proximanova/proximanova-regular/proximanova-regular.svg create mode 100644 assets/fonts/proximanova/proximanova-regular/proximanova-regular.ttf create mode 100644 assets/fonts/proximanova/proximanova-regular/proximanova-regular.woff create mode 100644 assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.eot create mode 100644 assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.svg create mode 100644 assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.ttf create mode 100644 assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.woff create mode 100644 boot.properties create mode 100644 build.boot create mode 100644 src/app/api.clj create mode 100644 src/app/handler.clj create mode 100644 src/app/rpc.cljs create mode 100644 src/index.cljs.hl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0ac88a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target/ +sdb.db +.nrepl-* diff --git a/README.md b/README.md new file mode 100644 index 0000000..6c4a92b --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# potluck-ctf + +A [Hoplon][2] web app for [lolctf][4] potluck CTF competitions. + +## Dependencies + +- java 1.7+ +- [boot][1] + +## Usage + +1. Start the auto-compiler. In a terminal: + + ```bash + $ boot dev + ``` + +2. Go to [http://localhost:8000][3] in your browser. + +[1]: https://boot-clj.com +[2]: https://hoplon.io +[3]: http://localhost:8000 +[4]: https://lolctf.org diff --git a/assets/css/main.css b/assets/css/main.css new file mode 100644 index 0000000..bd431a9 --- /dev/null +++ b/assets/css/main.css @@ -0,0 +1,35 @@ +@font-face { + font-family: "Proxima-light"; + src: url("/fonts/proximanova/proximanova-light/proximanova-light.eot"); + src: url("/fonts/proximanova/proximanova-light/proximanova-light.eot?#iefix") format("embedded-opentype"),url("/fonts/proximanova/proximanova-light/proximanova-light.woff?2") format("woff"),url("/fonts/proximanova/proximanova-light/proximanova-light.ttf?2") format("truetype"),url("/fonts/proximanova/proximanova-light/proximanova-light.svg#svgFontName") format("svg") +} + +@font-face { + font-family: "Proxima-regular"; + src: url("/fonts/proximanova/proximanova-regular/proximanova-regular.eot"); + src: url("/fonts/proximanova/proximanova-regular/proximanova-regular.eot?#iefix") format("embedded-opentype"),url("/fonts/proximanova/proximanova-regular/proximanova-regular.woff?2") format("woff"),url("/fonts/proximanova/proximanova-regular/proximanova-regular.ttf?2") format("truetype"),url("/fonts/proximanova/proximanova-regular/proximanova-regular.svg#svgFontName") format("svg") +} + +@font-face { + font-family: "Proxima-semibold"; + src: url("/fonts/proximanova/proximanova-semibold/proximanova-semibold.eot"); + src: url("/fonts/proximanova/proximanova-semibold/proximanova-semibold.eot?#iefix") format("embedded-opentype"),url("/fonts/proximanova/proximanova-semibold/proximanova-semibold.woff?2") format("woff"),url("/fonts/proximanova/proximanova-semibold/proximanova-semibold.ttf?2") format("truetype"),url("/fonts/proximanova/proximanova-semibold/proximanova-semibold.svg#svgFontName") format("svg") +} + +@font-face { + font-family: "Proxima-bold"; + src: url("/fonts/proximanova/proximanova-bold/proximanova-bold.eot"); + src: url("/fonts/proximanova/proximanova-bold/proximanova-bold.eot?#iefix") format("embedded-opentype"),url("/fonts/proximanova/proximanova-bold/proximanova-bold.woff?2") format("woff"),url("/fonts/proximanova/proximanova-bold/proximanova-bold.ttf?2") format("truetype"),url("/fonts/proximanova/proximanova-bold/proximanova-bold.svg#svgFontName") format("svg") +} +body { + color: #383f45; + background-color: #f5f5f5; + font-family: "Proxima-regular" +} +h1,h2,h3 { + font-family: "Proxima-semibold" +} + +table th { + font-family: "Proxima-bold" +} diff --git a/assets/fonts/proximanova/proximanova-bold/proximanova-bold.eot b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.eot new file mode 100644 index 0000000..f3e2879 Binary files /dev/null and b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.eot differ diff --git a/assets/fonts/proximanova/proximanova-bold/proximanova-bold.svg b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.svg new file mode 100644 index 0000000..a37630e --- /dev/null +++ b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.svg @@ -0,0 +1,536 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/proximanova/proximanova-bold/proximanova-bold.ttf b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.ttf new file mode 100644 index 0000000..b438fdc Binary files /dev/null and b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.ttf differ diff --git a/assets/fonts/proximanova/proximanova-bold/proximanova-bold.woff b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.woff new file mode 100644 index 0000000..7f9c43b Binary files /dev/null and b/assets/fonts/proximanova/proximanova-bold/proximanova-bold.woff differ diff --git a/assets/fonts/proximanova/proximanova-light/proximanova-light.eot b/assets/fonts/proximanova/proximanova-light/proximanova-light.eot new file mode 100644 index 0000000..825415c Binary files /dev/null and b/assets/fonts/proximanova/proximanova-light/proximanova-light.eot differ diff --git a/assets/fonts/proximanova/proximanova-light/proximanova-light.svg b/assets/fonts/proximanova/proximanova-light/proximanova-light.svg new file mode 100644 index 0000000..9153702 --- /dev/null +++ b/assets/fonts/proximanova/proximanova-light/proximanova-light.svg @@ -0,0 +1,543 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/proximanova/proximanova-light/proximanova-light.ttf b/assets/fonts/proximanova/proximanova-light/proximanova-light.ttf new file mode 100644 index 0000000..bfc5b83 Binary files /dev/null and b/assets/fonts/proximanova/proximanova-light/proximanova-light.ttf differ diff --git a/assets/fonts/proximanova/proximanova-light/proximanova-light.woff b/assets/fonts/proximanova/proximanova-light/proximanova-light.woff new file mode 100644 index 0000000..457d435 Binary files /dev/null and b/assets/fonts/proximanova/proximanova-light/proximanova-light.woff differ diff --git a/assets/fonts/proximanova/proximanova-regular/proximanova-regular.eot b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.eot new file mode 100644 index 0000000..9dc497e Binary files /dev/null and b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.eot differ diff --git a/assets/fonts/proximanova/proximanova-regular/proximanova-regular.svg b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.svg new file mode 100644 index 0000000..bf7d498 --- /dev/null +++ b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.svg @@ -0,0 +1,545 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/proximanova/proximanova-regular/proximanova-regular.ttf b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.ttf new file mode 100644 index 0000000..15f4d47 Binary files /dev/null and b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.ttf differ diff --git a/assets/fonts/proximanova/proximanova-regular/proximanova-regular.woff b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.woff new file mode 100644 index 0000000..33a122f Binary files /dev/null and b/assets/fonts/proximanova/proximanova-regular/proximanova-regular.woff differ diff --git a/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.eot b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.eot new file mode 100644 index 0000000..4f2b8ab Binary files /dev/null and b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.eot differ diff --git a/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.svg b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.svg new file mode 100644 index 0000000..1eba50d --- /dev/null +++ b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.svg @@ -0,0 +1,536 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.ttf b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.ttf new file mode 100644 index 0000000..68bb3e9 Binary files /dev/null and b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.ttf differ diff --git a/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.woff b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.woff new file mode 100644 index 0000000..d182a79 Binary files /dev/null and b/assets/fonts/proximanova/proximanova-semibold/proximanova-semibold.woff differ diff --git a/boot.properties b/boot.properties new file mode 100644 index 0000000..fd69fb6 --- /dev/null +++ b/boot.properties @@ -0,0 +1,4 @@ +#https://github.com/boot-clj/boot +#Sat Sep 19 11:31:37 BRT 2015 +BOOT_CLOJURE_VERSION=1.7.0 +BOOT_VERSION=2.5.2 diff --git a/build.boot b/build.boot new file mode 100644 index 0000000..f477fe1 --- /dev/null +++ b/build.boot @@ -0,0 +1,46 @@ +(set-env! + :dependencies '[[adzerk/boot-cljs "1.7.48-4"] + [adzerk/boot-cljs-repl "0.1.9"] + [adzerk/boot-reload "0.3.2"] + [compojure "1.4.0"] + [hoplon/boot-hoplon "0.1.10"] + [hoplon/castra "3.0.0-alpha1"] + [hoplon "6.0.0-alpha10"] + [org.clojure/clojure "1.7.0"] + [org.clojure/clojurescript "1.7.122"] + [pandeiro/boot-http "0.6.3"] + [ring "1.4.0"] + [ring/ring-defaults "0.1.5"] + [simpledb "0.1.4"]] + :source-paths #{"src"} + :resource-paths #{"assets"}) + +(require + '[adzerk.boot-cljs :refer [cljs]] + '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]] + '[adzerk.boot-reload :refer [reload]] + '[hoplon.boot-hoplon :refer [hoplon prerender]] + '[pandeiro.boot-http :refer [serve]]) + +(deftask dev + "Build castra-simple for local development." + [] + (comp + (serve + :handler 'app.handler/app + :reload true + :port 8000) + (watch) + (speak) + (hoplon) + (reload) + (cljs-repl) + (cljs))) + +(deftask prod + "Build castra-simple for production deployment." + [] + (comp + (hoplon) + (cljs :optimizations :advanced) + (prerender))) diff --git a/src/app/api.clj b/src/app/api.clj new file mode 100644 index 0000000..e83f187 --- /dev/null +++ b/src/app/api.clj @@ -0,0 +1,6 @@ +(ns app.api + (:require [castra.core :refer [defrpc]] + [simpledb.core :as db])) + +(defrpc get-scoreboard [] + (db/get :scoreboard)) diff --git a/src/app/handler.clj b/src/app/handler.clj new file mode 100644 index 0000000..a5878b5 --- /dev/null +++ b/src/app/handler.clj @@ -0,0 +1,19 @@ +(ns app.handler + (:require [castra.middleware :as castra] + [compojure.core :as c] + [compojure.route :as route] + [ring.middleware.defaults :as d] + [ring.util.response :as response] + [simpledb.core :as db])) + +(c/defroutes app-routes + (c/GET "/" req (response/content-type (response/resource-response "index.html") "text/html")) + (route/resources "/" {:root ""})) + +(def app + (-> app-routes + (castra/wrap-castra 'app.api) + (castra/wrap-castra-session "a 16-byte secret") + (d/wrap-defaults d/api-defaults))) + +(db/init) diff --git a/src/app/rpc.cljs b/src/app/rpc.cljs new file mode 100644 index 0000000..464809c --- /dev/null +++ b/src/app/rpc.cljs @@ -0,0 +1,17 @@ +(ns app.rpc + (:require-macros + [javelin.core :refer [defc defc=]]) + (:require + [javelin.core] + [castra.core :refer [mkremote]])) + +(defc scoreboard nil) +(defc error nil) +(defc loading []) + +(def get-scoreboard + (mkremote 'app.api/get-scoreboard scoreboard error loading)) + +(defn init [] + (get-scoreboard) + (js/setInterval get-scoreboard 1000)) diff --git a/src/index.cljs.hl b/src/index.cljs.hl new file mode 100644 index 0000000..8ecbc8c --- /dev/null +++ b/src/index.cljs.hl @@ -0,0 +1,73 @@ +(page "index.html" + (:require [app.rpc :as rpc])) + +(defc= scoreboard (merge (sorted-map) rpc/scoreboard)) +(defc= problems (mapcat (fn [[id person]] + (map (partial vector id) (:problems person))) + scoreboard)) +(defc= scores + (reverse (sort + (map (fn [[id person]] + [(apply + + + (concat + (map (fn [[prob state]] + (if (and + (= :solved state) + (not (contains? (:problems person) prob))) + 1 + 0)) + (:scores person)) + (map (fn [prob] + (if (some (fn [[id2 person2]] + (and + (= :solved + (get (:scores person) prob)) + (= :solved + (get (:scores person2) prob)) + (not= id id2))) + scoreboard) + 1 + 0)) + (:problems person)))) + id]) + scoreboard)))) + +(rpc/init) + +(html + (head + (link :rel "stylesheet" :type "text/css" :href "css/main.css") + (title "Potluck CTF")) + (body + (h1 "Potluck CTF") + (text "Login/Register?") + (h2 "Scoreboard") + (table + (thead + (tr + (th) + (th) + (loop-tpl :bindings [probs (cell= (partition-by first problems))] + (th :text (cell= (:name (get scoreboard + (first (first probs))))) + :colspan (cell= (count probs))))) + (tr + (th "Player") + (th "Score") + (loop-tpl :bindings [[owner name] problems] + (th :text name)))) + (tbody + (loop-tpl :bindings [[score id] scores] + (let [player (cell= (get scoreboard id))] + (tr + (td :text (cell= (:name player))) + (td :text score) + (loop-tpl :bindings [[owner _name] problems] + (td :text (cell= + (name (get (:scores player) + _name + :unsolved)))))))) + )))) + +;; vim: set expandtab ts=2 sw=2 filetype=clojure : -- cgit v1.2.3-18-g5258