Spaces:
Running
Running
Four judge lists (common + per track), allowlist-only page, 5-field info card, status lights
Browse files- app.py +108 -18
- static/index.html +26 -13
app.py
CHANGED
|
@@ -1,11 +1,18 @@
|
|
| 1 |
"""Lexsi Hackathon judging — HF Space (Docker).
|
| 2 |
|
| 3 |
-
Judges sign in with Hugging Face; only usernames
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
Each judge is stored under an anonymous id = HMAC(JUDGE_SALT, username), never the username.
|
| 5 |
Reviews are JSON files in a private HF dataset (REVIEWS_DATASET), so they survive Space restarts.
|
| 6 |
|
| 7 |
Space secrets / variables:
|
| 8 |
-
|
| 9 |
JUDGE_SALT random key for the anonymous judge ids (keep private, never change mid-judging)
|
| 10 |
SESSION_SECRET random key for login cookies
|
| 11 |
REVIEWS_DATASET private dataset repo for reviews + submissions.json, e.g. Lexsi/Hackathon_judging_reviews
|
|
@@ -22,7 +29,6 @@ import httpx
|
|
| 22 |
import jwt
|
| 23 |
from fastapi import FastAPI, HTTPException, Request
|
| 24 |
from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
|
| 25 |
-
from fastapi.staticfiles import StaticFiles
|
| 26 |
from starlette.middleware.sessions import SessionMiddleware
|
| 27 |
|
| 28 |
ROOT = Path(__file__).parent
|
|
@@ -33,7 +39,14 @@ CLIENT_ID = os.getenv("OAUTH_CLIENT_ID")
|
|
| 33 |
CLIENT_SECRET = os.getenv("OAUTH_CLIENT_SECRET")
|
| 34 |
PROVIDER = os.getenv("OPENID_PROVIDER_URL", "https://huggingface.co").rstrip("/")
|
| 35 |
SPACE_HOST = os.getenv("SPACE_HOST", "")
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
SALT = os.getenv("JUDGE_SALT", "")
|
| 38 |
DATASET = os.getenv("REVIEWS_DATASET", "")
|
| 39 |
HF_TOKEN = os.getenv("HF_TOKEN", "")
|
|
@@ -47,7 +60,6 @@ if SPACE_ID and not SALT:
|
|
| 47 |
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
|
| 48 |
app.add_middleware(SessionMiddleware, secret_key=os.getenv("SESSION_SECRET") or secrets.token_hex(32),
|
| 49 |
same_site="none" if CLIENT_ID else "lax", https_only=bool(CLIENT_ID), max_age=14 * 86400)
|
| 50 |
-
app.mount("/static", StaticFiles(directory=ROOT / "static"), name="static")
|
| 51 |
lock = threading.Lock()
|
| 52 |
|
| 53 |
|
|
@@ -161,8 +173,8 @@ def user_from_sign(token: str):
|
|
| 161 |
|
| 162 |
|
| 163 |
def current_user(request: Request):
|
| 164 |
-
if DEV_USER:
|
| 165 |
-
return DEV_USER
|
| 166 |
sign = request.query_params.get("__sign") or request.headers.get("x-hf-sign")
|
| 167 |
return (user_from_sign(sign) if sign else None) or request.session.get("user")
|
| 168 |
|
|
@@ -224,17 +236,42 @@ def build_index():
|
|
| 224 |
INDEX = build_index()
|
| 225 |
|
| 226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
@app.get("/")
|
| 228 |
-
def index():
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
|
| 232 |
@app.get("/api/me")
|
| 233 |
def me(request: Request):
|
| 234 |
u = current_user(request)
|
| 235 |
allowed = bool(u) and u.lower() in JUDGES
|
| 236 |
-
|
| 237 |
-
|
|
|
|
|
|
|
| 238 |
|
| 239 |
|
| 240 |
def locked():
|
|
@@ -243,26 +280,79 @@ def locked():
|
|
| 243 |
return datetime.now(timezone.utc) > datetime.fromisoformat(DEADLINE.replace("Z", "+00:00"))
|
| 244 |
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
@app.get("/api/submissions")
|
| 247 |
def list_submissions(request: Request):
|
| 248 |
-
j =
|
| 249 |
out = []
|
| 250 |
-
for s in
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
out.append({**s, "status": st})
|
| 254 |
return out
|
| 255 |
|
| 256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
@app.get("/api/review/{sid}")
|
| 258 |
def get_review(sid: str, request: Request):
|
| 259 |
-
p = review_path(
|
| 260 |
return json.loads(p.read_text()) if p.exists() else {"answers": {}, "status": "not_started"}
|
| 261 |
|
| 262 |
|
| 263 |
@app.post("/api/review/{sid}")
|
| 264 |
async def save_review(sid: str, request: Request):
|
| 265 |
-
j =
|
| 266 |
if locked():
|
| 267 |
raise HTTPException(423, "reviews are locked after the deadline")
|
| 268 |
sub = next((s for s in submissions() if s["id"] == sid), None)
|
|
|
|
| 1 |
"""Lexsi Hackathon judging — HF Space (Docker).
|
| 2 |
|
| 3 |
+
Judges sign in with Hugging Face; only usernames on one of the four judge lists get in.
|
| 4 |
+
Anyone else gets a sign-in or "not on the list" card and nothing else: no form, no submissions.
|
| 5 |
+
|
| 6 |
+
Judge lists (comma-separated HF usernames, all Space secrets):
|
| 7 |
+
JUDGES common list: sees every submission still pending (fewer than TARGET_REVIEWS
|
| 8 |
+
submitted reviews), in any track, plus any submission they already started
|
| 9 |
+
JUDGES_T1/T2/T3 track lists: see every submission whose labeled track is t1 / t2 / t3
|
| 10 |
+
A username may be on several lists; it then sees the union.
|
| 11 |
Each judge is stored under an anonymous id = HMAC(JUDGE_SALT, username), never the username.
|
| 12 |
Reviews are JSON files in a private HF dataset (REVIEWS_DATASET), so they survive Space restarts.
|
| 13 |
|
| 14 |
Space secrets / variables:
|
| 15 |
+
TARGET_REVIEWS optional, submitted reviews after which a submission stops being pending (default 3)
|
| 16 |
JUDGE_SALT random key for the anonymous judge ids (keep private, never change mid-judging)
|
| 17 |
SESSION_SECRET random key for login cookies
|
| 18 |
REVIEWS_DATASET private dataset repo for reviews + submissions.json, e.g. Lexsi/Hackathon_judging_reviews
|
|
|
|
| 29 |
import jwt
|
| 30 |
from fastapi import FastAPI, HTTPException, Request
|
| 31 |
from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
|
|
|
|
| 32 |
from starlette.middleware.sessions import SessionMiddleware
|
| 33 |
|
| 34 |
ROOT = Path(__file__).parent
|
|
|
|
| 39 |
CLIENT_SECRET = os.getenv("OAUTH_CLIENT_SECRET")
|
| 40 |
PROVIDER = os.getenv("OPENID_PROVIDER_URL", "https://huggingface.co").rstrip("/")
|
| 41 |
SPACE_HOST = os.getenv("SPACE_HOST", "")
|
| 42 |
+
def _names(var):
|
| 43 |
+
return {u.strip().lower().lstrip("@") for u in os.getenv(var, "").split(",") if u.strip()}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
COMMON = _names("JUDGES")
|
| 47 |
+
TRACK_JUDGES = {t: _names(f"JUDGES_{t.upper()}") for t in ("t1", "t2", "t3")}
|
| 48 |
+
JUDGES = COMMON.union(*TRACK_JUDGES.values())
|
| 49 |
+
TARGET = int(os.getenv("TARGET_REVIEWS", "3") or 3)
|
| 50 |
SALT = os.getenv("JUDGE_SALT", "")
|
| 51 |
DATASET = os.getenv("REVIEWS_DATASET", "")
|
| 52 |
HF_TOKEN = os.getenv("HF_TOKEN", "")
|
|
|
|
| 60 |
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
|
| 61 |
app.add_middleware(SessionMiddleware, secret_key=os.getenv("SESSION_SECRET") or secrets.token_hex(32),
|
| 62 |
same_site="none" if CLIENT_ID else "lax", https_only=bool(CLIENT_ID), max_age=14 * 86400)
|
|
|
|
| 63 |
lock = threading.Lock()
|
| 64 |
|
| 65 |
|
|
|
|
| 173 |
|
| 174 |
|
| 175 |
def current_user(request: Request):
|
| 176 |
+
if DEV_USER: # local testing only; ?as=<user> switches the pretend judge
|
| 177 |
+
return request.query_params.get("as") or request.cookies.get("dev_as") or DEV_USER
|
| 178 |
sign = request.query_params.get("__sign") or request.headers.get("x-hf-sign")
|
| 179 |
return (user_from_sign(sign) if sign else None) or request.session.get("user")
|
| 180 |
|
|
|
|
| 236 |
INDEX = build_index()
|
| 237 |
|
| 238 |
|
| 239 |
+
def gate_page(title, body, button=""):
|
| 240 |
+
return f"""<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
| 241 |
+
<meta name="robots" content="noindex, nofollow"><title>Judging | Lexsi</title>
|
| 242 |
+
<style>*{{box-sizing:border-box;margin:0}}html{{color-scheme:dark}}body{{background:#000;color:#fff;font-family:system-ui,sans-serif;min-height:100vh;display:grid;place-items:center;padding:16px}}
|
| 243 |
+
.c{{max-width:420px;width:100%;border:2px solid #FF4B0A;border-radius:12px;padding:36px 28px;text-align:center}}h1{{font-size:24px;margin-bottom:10px}}p{{color:#FFFFFFD1;font-size:15px;line-height:1.5}}
|
| 244 |
+
a{{display:inline-block;margin-top:22px;background:#FFD21E;color:#000;font-weight:600;padding:12px 22px;border-radius:8px;text-decoration:none}}</style></head>
|
| 245 |
+
<body><div class="c"><h1>{title}</h1><p>{body}</p>{button}</div></body></html>"""
|
| 246 |
+
|
| 247 |
+
|
| 248 |
@app.get("/")
|
| 249 |
+
def index(request: Request):
|
| 250 |
+
u = current_user(request)
|
| 251 |
+
if not u:
|
| 252 |
+
url = f"https://{SPACE_HOST}/login" if SPACE_HOST else "/login"
|
| 253 |
+
return HTMLResponse(gate_page("Judges only", "Sign in with the Hugging Face account you were invited with.",
|
| 254 |
+
f'<a href="{url}" target="_top">Sign in with Hugging Face</a>'),
|
| 255 |
+
status_code=401, headers={"Cache-Control": "no-store"})
|
| 256 |
+
if u.lower() not in JUDGES:
|
| 257 |
+
import html
|
| 258 |
+
return HTMLResponse(gate_page("Not on the judges list", f"You're signed in as @{html.escape(u)}, which isn't an invited judge account. "
|
| 259 |
+
"If that's a mistake, message the Lexsi team."),
|
| 260 |
+
status_code=403, headers={"Cache-Control": "no-store"})
|
| 261 |
+
r = HTMLResponse(INDEX, headers={"Cache-Control": "no-store"})
|
| 262 |
+
if DEV_USER and request.query_params.get("as"):
|
| 263 |
+
r.set_cookie("dev_as", request.query_params["as"])
|
| 264 |
+
return r
|
| 265 |
|
| 266 |
|
| 267 |
@app.get("/api/me")
|
| 268 |
def me(request: Request):
|
| 269 |
u = current_user(request)
|
| 270 |
allowed = bool(u) and u.lower() in JUDGES
|
| 271 |
+
roles = (["common"] if allowed and u.lower() in COMMON else []) + \
|
| 272 |
+
[t for t, ns in TRACK_JUDGES.items() if allowed and u.lower() in ns]
|
| 273 |
+
return {"user": u, "allowed": allowed, "judge": judge_id(u) if allowed else None, "roles": roles,
|
| 274 |
+
"target": TARGET, "deadline": DEADLINE or None, "locked": locked()}
|
| 275 |
|
| 276 |
|
| 277 |
def locked():
|
|
|
|
| 280 |
return datetime.now(timezone.utc) > datetime.fromisoformat(DEADLINE.replace("Z", "+00:00"))
|
| 281 |
|
| 282 |
|
| 283 |
+
def all_statuses():
|
| 284 |
+
"""{submission id: {judge id: status}} from the review files on disk."""
|
| 285 |
+
out = {}
|
| 286 |
+
for f in (DATA / "reviews").glob("*/*.json"):
|
| 287 |
+
try:
|
| 288 |
+
out.setdefault(f.stem, {})[f.parent.name] = json.loads(f.read_text()).get("status", "draft")
|
| 289 |
+
except Exception:
|
| 290 |
+
pass
|
| 291 |
+
return out
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
DONE = ("submitted", "ended_checklist")
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def visible(u, j, s, st):
|
| 298 |
+
"""Can judge u (id j) see submission s? st = {judge id: status} for s."""
|
| 299 |
+
u = u.lower()
|
| 300 |
+
if u in TRACK_JUDGES.get(s.get("track"), ()):
|
| 301 |
+
return True
|
| 302 |
+
if u in COMMON:
|
| 303 |
+
if j in st:
|
| 304 |
+
return True
|
| 305 |
+
return sum(1 for k, v in st.items() if k != j and v in DONE) < TARGET
|
| 306 |
+
return False
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
def light(v):
|
| 310 |
+
return "done" if v in DONE else "draft" if v == "draft" else "off"
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
def lights(u, j, s, st):
|
| 314 |
+
"""Slot 1 is the viewer. Slots 2-3: two other judges on this submission, picked at random
|
| 315 |
+
(stable per viewer and submission), from its track list plus anyone who has started it. None = empty."""
|
| 316 |
+
others = {judge_id(x) for x in TRACK_JUDGES.get(s.get("track"), ())} | set(st)
|
| 317 |
+
others.discard(j)
|
| 318 |
+
import random
|
| 319 |
+
pick = random.Random(f"{j}:{s['id']}").sample(sorted(others), min(2, len(others)))
|
| 320 |
+
return [light(st.get(j))] + [light(st.get(o)) for o in pick] + [None] * (2 - len(pick))
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def my_subs(request: Request):
|
| 324 |
+
j = require_judge(request)
|
| 325 |
+
u = current_user(request)
|
| 326 |
+
st_all = all_statuses()
|
| 327 |
+
return j, u, st_all, [s for s in submissions() if visible(u, j, s, st_all.get(s["id"], {}))]
|
| 328 |
+
|
| 329 |
+
|
| 330 |
@app.get("/api/submissions")
|
| 331 |
def list_submissions(request: Request):
|
| 332 |
+
j, u, st_all, subs = my_subs(request)
|
| 333 |
out = []
|
| 334 |
+
for s in subs:
|
| 335 |
+
st = st_all.get(s["id"], {})
|
| 336 |
+
out.append({**s, "status": st.get(j, "not_started"), "lights": lights(u, j, s, st)})
|
|
|
|
| 337 |
return out
|
| 338 |
|
| 339 |
|
| 340 |
+
def require_access(request: Request, sid: str) -> str:
|
| 341 |
+
j, _, _, subs = my_subs(request)
|
| 342 |
+
if not any(s["id"] == sid for s in subs):
|
| 343 |
+
raise HTTPException(404, "not assigned to you")
|
| 344 |
+
return j
|
| 345 |
+
|
| 346 |
+
|
| 347 |
@app.get("/api/review/{sid}")
|
| 348 |
def get_review(sid: str, request: Request):
|
| 349 |
+
p = review_path(require_access(request, sid), sid)
|
| 350 |
return json.loads(p.read_text()) if p.exists() else {"answers": {}, "status": "not_started"}
|
| 351 |
|
| 352 |
|
| 353 |
@app.post("/api/review/{sid}")
|
| 354 |
async def save_review(sid: str, request: Request):
|
| 355 |
+
j = require_access(request, sid)
|
| 356 |
if locked():
|
| 357 |
raise HTTPException(423, "reviews are locked after the deadline")
|
| 358 |
sub = next((s for s in submissions() if s["id"] == sid), None)
|
static/index.html
CHANGED
|
@@ -66,16 +66,23 @@ input,textarea{font-family:inherit;color:var(--text)}
|
|
| 66 |
.pill.draft{color:#FFD21E;border-color:#FFD21E66}
|
| 67 |
.pill.submitted{color:#4ADE80;border-color:#4ADE8066}
|
| 68 |
.pill.ended_checklist{color:var(--accent);border-color:#FF4B0A66}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
/* main */
|
| 71 |
.main{display:flex;flex-direction:column;gap:28px;min-width:0}
|
| 72 |
.sub-title{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap}
|
| 73 |
.sub-title h1{font-size:30px;font-weight:700;line-height:1.2}
|
| 74 |
.sub-title .tag{font-family:var(--mono);font-size:13px;border:1px solid #5C5C5C;background:#1A1A1A;border-radius:4px;padding:2px 8px}
|
| 75 |
-
.meta{display:grid;grid-template-columns:1fr 1fr;gap:0 40px;margin-top:
|
| 76 |
-
.meta
|
| 77 |
-
.meta .row{
|
| 78 |
-
.meta .row:last-child{border-bottom:0}
|
| 79 |
.meta dt{color:var(--text-muted)}
|
| 80 |
.meta dd{color:var(--text);font-weight:500;word-break:break-word}
|
| 81 |
.meta dd a{color:var(--accent)}
|
|
@@ -119,6 +126,7 @@ input:focus,textarea:focus{outline:none;border-color:var(--accent)}
|
|
| 119 |
.side{position:static;max-height:none}
|
| 120 |
.subs{max-height:240px}
|
| 121 |
.meta{grid-template-columns:1fr}
|
|
|
|
| 122 |
.header-inner{padding:0 16px;gap:12px}
|
| 123 |
.logo img{height:22px}
|
| 124 |
.crumb{padding-left:12px;font-size:14px}
|
|
@@ -206,6 +214,8 @@ async function boot() {
|
|
| 206 |
<a class="btn btn-hf" href="https://huggingface.co/spaces/Lexsi/Hackathon_judging" target="_top">🤗 Open on Hugging Face</a>`);
|
| 207 |
}
|
| 208 |
$('#me').hidden = false; $('#who').textContent = '@' + ME.user;
|
|
|
|
|
|
|
| 209 |
if (!ME.allowed) return gate(`<h1>Not on the judges list</h1><p>You're signed in as <b>@${esc(ME.user)}</b>, but this account isn't an invited judge. If you think that's a mistake, message the Lexsi team.</p>`);
|
| 210 |
$('#jid').textContent = ME.judge;
|
| 211 |
$('#app').hidden = false; $('#bar').hidden = false;
|
|
@@ -219,10 +229,11 @@ async function loadSubs() {
|
|
| 219 |
const done = SUBS.filter(s => s.status === 'submitted' || s.status === 'ended_checklist').length;
|
| 220 |
$('#count').textContent = `${done} of ${SUBS.length} reviewed`;
|
| 221 |
$('#prog').style.width = SUBS.length ? (100 * done / SUBS.length) + '%' : 0;
|
| 222 |
-
const
|
|
|
|
| 223 |
$('#subs').innerHTML = SUBS.map(s => `<li><button data-id="${esc(s.id)}" class="${s.id === cur ? 'on' : ''}">
|
| 224 |
<span class="num">#${esc(s.number)}</span><span class="nm">${esc(s.team_name)}</span>
|
| 225 |
-
<span class="
|
| 226 |
$('#subs').querySelectorAll('button').forEach(b => b.onclick = () => open(b.dataset.id));
|
| 227 |
}
|
| 228 |
|
|
@@ -240,18 +251,20 @@ async function open(id) {
|
|
| 240 |
}
|
| 241 |
const key = () => `judging:${ME.judge}:${cur}`;
|
| 242 |
|
| 243 |
-
const link = v => /^https?:\/\//.test(v || '') ? `<a class="u" href="${esc(v)}" target="_blank" rel="noopener">${esc(v.replace(/^https?:\/\/(www\.)?/, ''))}</a>` : esc(v || '
|
| 244 |
|
| 245 |
function render(showMissing) {
|
| 246 |
-
const s = SUBS.find(x => x.id === cur)
|
| 247 |
const [secs, ended] = visibleSections(A), miss = showMissing ? new Set(missing(A)) : new Set();
|
| 248 |
-
const row = (k, v) => `<div class="row"><dt>${k}</dt><dd>${v}</dd></div>`;
|
|
|
|
| 249 |
let h = `<section class="card">
|
| 250 |
<div class="sub-title"><h1>${esc(s.team_name || 'XXX')}</h1><span class="tag">Submission #${esc(s.number)}</span></div>
|
| 251 |
-
<
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
|
|
|
| 255 |
secs.forEach((sec, i) => {
|
| 256 |
h += `<section class="card sec"><h3><span class="n">${sec.num}</span>${esc(sec.title)}</h3>`;
|
| 257 |
for (const f of sec.fields) {
|
|
|
|
| 66 |
.pill.draft{color:#FFD21E;border-color:#FFD21E66}
|
| 67 |
.pill.submitted{color:#4ADE80;border-color:#4ADE8066}
|
| 68 |
.pill.ended_checklist{color:var(--accent);border-color:#FF4B0A66}
|
| 69 |
+
/* status lights: slot 1 = you, slots 2-3 = two other judges on this submission */
|
| 70 |
+
.lights{display:flex;gap:4px;flex-shrink:0}
|
| 71 |
+
.lights i{width:8px;height:8px;border-radius:2px;display:block}
|
| 72 |
+
.lights i.off{background:#EF4444;box-shadow:0 0 5px 1px #EF444480}
|
| 73 |
+
.lights i.draft{background:#FACC15;box-shadow:0 0 5px 1px #FACC1580}
|
| 74 |
+
.lights i.done{background:#22C55E;box-shadow:0 0 5px 1px #22C55E80}
|
| 75 |
+
.lights i.none{border:1px solid #FFFFFF2E}
|
| 76 |
+
.lights i:first-child{outline:1px solid #FFFFFF59;outline-offset:1px}
|
| 77 |
|
| 78 |
/* main */
|
| 79 |
.main{display:flex;flex-direction:column;gap:28px;min-width:0}
|
| 80 |
.sub-title{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap}
|
| 81 |
.sub-title h1{font-size:30px;font-weight:700;line-height:1.2}
|
| 82 |
.sub-title .tag{font-family:var(--mono);font-size:13px;border:1px solid #5C5C5C;background:#1A1A1A;border-radius:4px;padding:2px 8px}
|
| 83 |
+
.meta{display:grid;grid-template-columns:1fr 1fr;gap:0 40px;margin-top:16px}
|
| 84 |
+
.meta .row{display:grid;grid-template-columns:110px minmax(0,1fr);gap:12px;padding:10px 0;border-bottom:1px solid var(--border);font-size:15px}
|
| 85 |
+
.meta .row.wide{grid-column:1/-1;border-bottom:0}
|
|
|
|
| 86 |
.meta dt{color:var(--text-muted)}
|
| 87 |
.meta dd{color:var(--text);font-weight:500;word-break:break-word}
|
| 88 |
.meta dd a{color:var(--accent)}
|
|
|
|
| 126 |
.side{position:static;max-height:none}
|
| 127 |
.subs{max-height:240px}
|
| 128 |
.meta{grid-template-columns:1fr}
|
| 129 |
+
.meta .row.wide{border-bottom:0}
|
| 130 |
.header-inner{padding:0 16px;gap:12px}
|
| 131 |
.logo img{height:22px}
|
| 132 |
.crumb{padding-left:12px;font-size:14px}
|
|
|
|
| 214 |
<a class="btn btn-hf" href="https://huggingface.co/spaces/Lexsi/Hackathon_judging" target="_top">🤗 Open on Hugging Face</a>`);
|
| 215 |
}
|
| 216 |
$('#me').hidden = false; $('#who').textContent = '@' + ME.user;
|
| 217 |
+
const RL = {common: 'Common', t1: 'Track 1', t2: 'Track 2', t3: 'Track 3'};
|
| 218 |
+
$('#who').title = 'Judging lists: ' + ((ME.roles || []).map(r => RL[r]).join(', ') || 'none');
|
| 219 |
if (!ME.allowed) return gate(`<h1>Not on the judges list</h1><p>You're signed in as <b>@${esc(ME.user)}</b>, but this account isn't an invited judge. If you think that's a mistake, message the Lexsi team.</p>`);
|
| 220 |
$('#jid').textContent = ME.judge;
|
| 221 |
$('#app').hidden = false; $('#bar').hidden = false;
|
|
|
|
| 229 |
const done = SUBS.filter(s => s.status === 'submitted' || s.status === 'ended_checklist').length;
|
| 230 |
$('#count').textContent = `${done} of ${SUBS.length} reviewed`;
|
| 231 |
$('#prog').style.width = SUBS.length ? (100 * done / SUBS.length) + '%' : 0;
|
| 232 |
+
const word = {off: 'not started', draft: 'draft saved', done: 'submitted'};
|
| 233 |
+
const lamp = (v, i) => `<i class="${v || 'none'}" title="${i ? 'Another judge' : 'You'}: ${v ? word[v] : 'no judge'}"></i>`;
|
| 234 |
$('#subs').innerHTML = SUBS.map(s => `<li><button data-id="${esc(s.id)}" class="${s.id === cur ? 'on' : ''}">
|
| 235 |
<span class="num">#${esc(s.number)}</span><span class="nm">${esc(s.team_name)}</span>
|
| 236 |
+
<span class="lights">${(s.lights || []).map(lamp).join('')}</span></button></li>`).join('');
|
| 237 |
$('#subs').querySelectorAll('button').forEach(b => b.onclick = () => open(b.dataset.id));
|
| 238 |
}
|
| 239 |
|
|
|
|
| 251 |
}
|
| 252 |
const key = () => `judging:${ME.judge}:${cur}`;
|
| 253 |
|
| 254 |
+
const link = v => /^https?:\/\//.test(v || '') ? `<a class="u" href="${esc(v)}" target="_blank" rel="noopener">${esc(v.replace(/^https?:\/\/(www\.)?/, ''))}</a>` : esc(v || '–');
|
| 255 |
|
| 256 |
function render(showMissing) {
|
| 257 |
+
const s = SUBS.find(x => x.id === cur);
|
| 258 |
const [secs, ended] = visibleSections(A), miss = showMissing ? new Set(missing(A)) : new Set();
|
| 259 |
+
const row = (k, v, c) => `<div class="row ${c || ''}"><dt>${k}</dt><dd>${v}</dd></div>`;
|
| 260 |
+
const mail = v => v ? `<a class="u" href="mailto:${esc(v)}">${esc(v)}</a>` : '–';
|
| 261 |
let h = `<section class="card">
|
| 262 |
<div class="sub-title"><h1>${esc(s.team_name || 'XXX')}</h1><span class="tag">Submission #${esc(s.number)}</span></div>
|
| 263 |
+
<dl class="meta">
|
| 264 |
+
${row('Project', esc(s.project || s.team_name || '–'))}${row('Email', mail(s.email))}
|
| 265 |
+
${row('GitHub repo', link(s.github))}${row('Discord', esc(s.discord || '–'))}
|
| 266 |
+
${row('Tracks chosen', esc(s.tracks_chosen || '–'), 'wide')}
|
| 267 |
+
</dl></section>`;
|
| 268 |
secs.forEach((sec, i) => {
|
| 269 |
h += `<section class="card sec"><h3><span class="n">${sec.num}</span>${esc(sec.title)}</h3>`;
|
| 270 |
for (const f of sec.fields) {
|