More robust theme handling

This commit is contained in:
Neale Pickett 2018-10-09 22:05:02 +00:00
parent d8d23b2c87
commit 5723e94bd7
3 changed files with 11 additions and 6 deletions

View File

@ -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__':

View File

@ -31,6 +31,7 @@ form, pre {
input, select {
padding: 0.6em;
margin: 0.2em;
max-width: 30em;
}
nav {
border: solid black 2px;

View File

@ -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);