mirror of https://github.com/dirtbags/moth.git
Fix some junk
This commit is contained in:
parent
3d0e73d0e9
commit
6d2c65f9c0
|
@ -153,7 +153,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.send_error(
|
self.send_error(
|
||||||
HTTPStatus.NOT_FOUND,
|
HTTPStatus.NOT_FOUND,
|
||||||
"File Not Found",
|
"File Not Found: %s" % self.req["filename"],
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -233,6 +233,8 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
HTTPStatus.NOT_IMPLEMENTED,
|
HTTPStatus.NOT_IMPLEMENTED,
|
||||||
"Unsupported method (%r)" % self.command,
|
"Unsupported method (%r)" % self.command,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# I don't fully understand why you can't do this inside the class definition.
|
||||||
MothRequestHandler.extensions_map[".mjs"] = "application/ecmascript"
|
MothRequestHandler.extensions_map[".mjs"] = "application/ecmascript"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,12 @@ class Puzzle:
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
self.files[name] = PuzzleFile(stream, name, not hidden)
|
self.files[name] = PuzzleFile(stream, name, not hidden)
|
||||||
|
elif key == 'files':
|
||||||
|
for file in val:
|
||||||
|
path = file["path"]
|
||||||
|
stream = open(path, "rb")
|
||||||
|
name = file.get("name") or path
|
||||||
|
self.files[name] = PuzzleFile(stream, name, not file.get("hidden"))
|
||||||
elif key == 'script':
|
elif key == 'script':
|
||||||
stream = open(val, 'rb')
|
stream = open(val, 'rb')
|
||||||
self.add_script_stream(stream, val)
|
self.add_script_stream(stream, val)
|
||||||
|
@ -400,10 +406,12 @@ class Puzzle:
|
||||||
"""Return a dict packaging of the puzzle."""
|
"""Return a dict packaging of the puzzle."""
|
||||||
|
|
||||||
files = [fn for fn,f in self.files.items() if f.visible]
|
files = [fn for fn,f in self.files.items() if f.visible]
|
||||||
|
hidden = [fn for fn,f in self.files.items() if not f.visible]
|
||||||
return {
|
return {
|
||||||
'authors': self.get_authors(),
|
'authors': self.get_authors(),
|
||||||
'hashes': self.hashes(),
|
'hashes': self.hashes(),
|
||||||
'files': files,
|
'files': files,
|
||||||
|
'hidden': hidden,
|
||||||
'scripts': self.scripts,
|
'scripts': self.scripts,
|
||||||
'pattern': self.pattern,
|
'pattern': self.pattern,
|
||||||
'body': self.html_body(),
|
'body': self.html_body(),
|
||||||
|
|
Loading…
Reference in New Issue