diff --git a/.gitignore b/.gitignore index 91424b0..c3c1634 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ build/ cache/ target/ -packages/forensics +puzzles \ No newline at end of file diff --git a/devel-server.py b/devel-server.py index 3b29fa6..cd3c407 100755 --- a/devel-server.py +++ b/devel-server.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 +import glob import http.server import mistune import pathlib @@ -22,7 +23,12 @@ def page(title, body): """.format(title, body) def mdpage(body): - title, _ = body.split('\n', 1) + try: + title, _ = body.split('\n', 1) + except ValueError: + title = "Result" + title = title.lstrip("#") + title = title.strip() return page(title, mistune.markdown(body)) @@ -33,7 +39,9 @@ class MothHandler(http.server.CGIHTTPRequestHandler): def do_GET(self): if self.path == "/": self.serve_front() - elif self.path.startswith("/files/"): + elif self.path.startswith("/puzzles"): + self.serve_puzzles() + elif self.path.startswith("/files"): self.serve_file() else: self.send_error(HTTPStatus.NOT_FOUND, "File not found") @@ -61,6 +69,18 @@ you are a fool. """ self.serve_md(page) + def serve_puzzles(self): + body = [] + parts = self.path.split("/") + if len(parts) < 3: + body.append("# Puzzle Categories") + # List all categories + for i in glob.glob("puzzles/*/"): + body.append("* [{}](/{})".format(i, i)) + else: + body.append("# Not Implemented Yet") + self.serve_md('\n'.join(body)) + def serve_file(self): if self.path.endswith(".md"): self.serve_md() diff --git a/doc/devel-server.md b/doc/devel-server.md index 4090872..9393b33 100644 --- a/doc/devel-server.md +++ b/doc/devel-server.md @@ -26,7 +26,7 @@ In the directory containing `devel-server.py`, you would run something like: git clone /path/to/my/puzzles-repository puzzles -or +or on Unix: ln -s /path/to/my/puzzles-repository puzzles diff --git a/www/res/style.css b/www/res/style.css index 4d559a4..404d707 100644 --- a/www/res/style.css +++ b/www/res/style.css @@ -39,6 +39,7 @@ body { pre, tt { font-family: 'Dosis', monospace; + background-color: rgba(0, 0, 0, 0.3); } .terminal {