mirror of https://github.com/dirtbags/moth.git
More robust theme handling
This commit is contained in:
parent
1a1d77905d
commit
72f1a7d47d
|
@ -24,9 +24,7 @@ sys.dont_write_bytecode = True # Don't write .pyc files
|
||||||
async def handle_puzzlelist(request):
|
async def handle_puzzlelist(request):
|
||||||
seed = int(request.match_info.get("seed"))
|
seed = int(request.match_info.get("seed"))
|
||||||
puzzles = {
|
puzzles = {
|
||||||
"__devel__": {
|
"__devel__": [[0, ""]],
|
||||||
"seed": seed,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
for p in request.app["puzzles_dir"].glob("*"):
|
for p in request.app["puzzles_dir"].glob("*"):
|
||||||
if not p.is_dir() or p.match(".*"):
|
if not p.is_dir() or p.match(".*"):
|
||||||
|
@ -121,11 +119,16 @@ async def handle_index(request):
|
||||||
|
|
||||||
|
|
||||||
async def handle_static(request):
|
async def handle_static(request):
|
||||||
|
themes = request.app["theme_dir"]
|
||||||
fn = request.match_info.get("filename")
|
fn = request.match_info.get("filename")
|
||||||
if not fn:
|
if not fn:
|
||||||
fn = "puzzles-list.html"
|
for fn in ("puzzle-list.html", "index.html"):
|
||||||
fn = os.path.join(request.app["theme_dir"], fn)
|
path = themes.joinpath(fn)
|
||||||
return web.FileResponse(fn)
|
if path.exists():
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
path = themes.joinpath(fn)
|
||||||
|
return web.FileResponse(path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -31,6 +31,7 @@ form, pre {
|
||||||
input, select {
|
input, select {
|
||||||
padding: 0.6em;
|
padding: 0.6em;
|
||||||
margin: 0.2em;
|
margin: 0.2em;
|
||||||
|
max-width: 30em;
|
||||||
}
|
}
|
||||||
nav {
|
nav {
|
||||||
border: solid black 2px;
|
border: solid black 2px;
|
||||||
|
|
|
@ -24,6 +24,7 @@ function init() {
|
||||||
let oldans = document.querySelector("[name=answer]");
|
let oldans = document.querySelector("[name=answer]");
|
||||||
let ans = document.createElement("select");
|
let ans = document.createElement("select");
|
||||||
oldans.parentNode.replaceChild(ans, oldans);
|
oldans.parentNode.replaceChild(ans, oldans);
|
||||||
|
ans.multiple = true;
|
||||||
for (let a of obj.answers) {
|
for (let a of obj.answers) {
|
||||||
let opt = document.createElement("option");
|
let opt = document.createElement("option");
|
||||||
ans.appendChild(opt);
|
ans.appendChild(opt);
|
||||||
|
|
Loading…
Reference in New Issue