From 72f1a7d47d2b11cf5ee7cefa2d55186d0c45ee54 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 9 Oct 2018 22:05:02 +0000 Subject: [PATCH] More robust theme handling --- devel/devel-server.py | 15 +++++++++------ theme/basic.css | 1 + theme/puzzle.html | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/devel/devel-server.py b/devel/devel-server.py index 350ed07..824fcea 100755 --- a/devel/devel-server.py +++ b/devel/devel-server.py @@ -24,9 +24,7 @@ sys.dont_write_bytecode = True # Don't write .pyc files async def handle_puzzlelist(request): seed = int(request.match_info.get("seed")) puzzles = { - "__devel__": { - "seed": seed, - }, + "__devel__": [[0, ""]], } for p in request.app["puzzles_dir"].glob("*"): if not p.is_dir() or p.match(".*"): @@ -121,11 +119,16 @@ async def handle_index(request): async def handle_static(request): + themes = request.app["theme_dir"] fn = request.match_info.get("filename") if not fn: - fn = "puzzles-list.html" - fn = os.path.join(request.app["theme_dir"], fn) - return web.FileResponse(fn) + for fn in ("puzzle-list.html", "index.html"): + path = themes.joinpath(fn) + if path.exists(): + break + else: + path = themes.joinpath(fn) + return web.FileResponse(path) if __name__ == '__main__': diff --git a/theme/basic.css b/theme/basic.css index 65ab16f..8845713 100644 --- a/theme/basic.css +++ b/theme/basic.css @@ -31,6 +31,7 @@ form, pre { input, select { padding: 0.6em; margin: 0.2em; + max-width: 30em; } nav { border: solid black 2px; diff --git a/theme/puzzle.html b/theme/puzzle.html index deb27b0..1e82577 100644 --- a/theme/puzzle.html +++ b/theme/puzzle.html @@ -24,6 +24,7 @@ function init() { let oldans = document.querySelector("[name=answer]"); let ans = document.createElement("select"); oldans.parentNode.replaceChild(ans, oldans); + ans.multiple = true; for (let a of obj.answers) { let opt = document.createElement("option"); ans.appendChild(opt);