diff --git a/example-puzzles/example/10/puzzle.moth b/example-puzzles/example/10/puzzle.md similarity index 96% rename from example-puzzles/example/10/puzzle.moth rename to example-puzzles/example/10/puzzle.md index 3d0e943..ce8e0bb 100644 --- a/example-puzzles/example/10/puzzle.moth +++ b/example-puzzles/example/10/puzzle.md @@ -1,6 +1,12 @@ -Author: neale -Summary: Making excellent puzzles -Answer: moo +--- +pre: + authors: + - neale +debug: + summary: Making excellent puzzles +answers: + - moo +--- Making Excellent Puzzles ==================== diff --git a/example-puzzles/example/100/puzzle.py b/example-puzzles/example/100/puzzle.py deleted file mode 100755 index 6b29a25..0000000 --- a/example-puzzles/example/100/puzzle.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python3 - -import io - -def make(puzzle): - puzzle.author = 'neale' - puzzle.summary = 'crazy stuff you can do with puzzle generation' - - puzzle.body.write("## Crazy Things You Can Do With Puzzle Generation\n") - puzzle.body.write("\n") - puzzle.body.write("The source to this puzzle has some advanced examples of stuff you can do in Python.\n") - puzzle.body.write("\n") - - # You can use any file-like object; even your own class that generates output. - f = io.BytesIO("This is some text! Isn't that fantastic?".encode('utf-8')) - puzzle.add_stream(f) - - # We have debug logging - puzzle.log("You don't have to disable puzzle.log calls to move to production; the debug log is just ignored at build-time.") - puzzle.log("HTML is escaped, so you don't have to worry about that!") - - puzzle.answers.append('coffee') - answer = puzzle.make_answer() # Generates a random answer, appending it to puzzle.answers too - puzzle.log("Answers: {}".format(puzzle.answers)) - diff --git a/example-puzzles/example/200/puzzle.py b/example-puzzles/example/200/puzzle.py deleted file mode 100755 index cfb9614..0000000 --- a/example-puzzles/example/200/puzzle.py +++ /dev/null @@ -1,19 +0,0 @@ -import io -import categorylib # Category-level libraries can be imported here - -def make(puzzle): - import puzzlelib # puzzle-level libraries can only be imported inside of the make function - puzzle.authors = ['donaldson'] - puzzle.summary = 'more crazy stuff you can do with puzzle generation using Python libraries' - - puzzle.body.write("## Crazy Things You Can Do With Puzzle Generation (part II)\n") - puzzle.body.write("\n") - puzzle.body.write("The source to this puzzle has some more advanced examples of stuff you can do in Python.\n") - puzzle.body.write("\n") - puzzle.body.write("1 == %s\n\n" % puzzlelib.getone(),) - puzzle.body.write("2 == %s\n\n" % categorylib.gettwo(),) - - puzzle.answers.append('tea') - answer = puzzle.make_answer() # Generates a random answer, appending it to puzzle.answers too - puzzle.log("Answers: {}".format(puzzle.answers)) - diff --git a/example-puzzles/example/200/puzzlelib.py b/example-puzzles/example/200/puzzlelib.py deleted file mode 100644 index 566be76..0000000 --- a/example-puzzles/example/200/puzzlelib.py +++ /dev/null @@ -1,7 +0,0 @@ -"""This is an example of a puzzle-level library. - -This library can be imported by sibling puzzles using `import puzzlelib` -""" - -def getone(): - return 1 diff --git a/example-puzzles/example/6/puzzle.md b/example-puzzles/example/6/puzzle.md deleted file mode 100644 index cd7ae00..0000000 --- a/example-puzzles/example/6/puzzle.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -pre: - authors: - - neale -answers: - - YAML - - yaml -debug: - summary: YAML Metadata -post: - objective: Understand how YAML metadata can be used in a `.moth` file - success: - acceptable: Enter the answer and move on - mastery: Create a `.md` file using YAML metadata and serve it through the devel server. ---- - -You can also provide metadata in YAML format. -This puzzle's `.md` file serves as an example. diff --git a/example-puzzles/example/7/mkpuzzle b/example-puzzles/example/7/mkpuzzle deleted file mode 100755 index 6919d6b..0000000 --- a/example-puzzles/example/7/mkpuzzle +++ /dev/null @@ -1,24 +0,0 @@ -#! /bin/sh - -cat <Writing Your Own Generator

\ -

\ - You can output the JSON puzzle format if you want.\ - See the source of this puzzle for an example!\ -

\ - " - }, - "debug": { - "log": [ - "There are many fields you can specify, aside from those in this file.", - "See puzzle.moth for the full spec.", - "MOTH_PUZZLE_SEED=$MOTH_PUZZLE_SEED" - ] - }, - "answers": ["JSON"] -} -EOD diff --git a/example-puzzles/example/categorylib.py b/example-puzzles/example/categorylib.py deleted file mode 100644 index fb5a230..0000000 --- a/example-puzzles/example/categorylib.py +++ /dev/null @@ -1,7 +0,0 @@ -"""This is an example of a category-level library. - -This library can be imported by child puzzles using `import categorylib` -""" - -def gettwo(): - return 2 diff --git a/theme/puzzle.js b/theme/puzzle.js index c5f96b1..49f03ce 100644 --- a/theme/puzzle.js +++ b/theme/puzzle.js @@ -13,18 +13,26 @@ function prettify(key, val) { // devel_addin drops a bunch of development extensions into element e. // It will only modify stuff inside e. function devel_addin(e) { - let h = document.createElement("h2") - e.appendChild(h) - h.textContent = "Development Options" + let h = e.appendChild(document.createElement("h2")) + h.textContent = "Developer Output" - let g = document.createElement("p") - e.appendChild(g) - g.innerText = "This section will not appear for participants." + let log = window.puzzle.Debug.Log || [] + if (log.length > 0) { + e.appendChild(document.createElement("h3")).textContent = "Log" + let le = e.appendChild(document.createElement("ul")) + for (entry of log) { + le.appendChild(document.createElement("li")).textContent = entry + } + } + + e.appendChild(document.createElement("h3")).textContent = "Puzzle object" let hobj = JSON.stringify(window.puzzle, prettify, 2) let d = e.appendChild(document.createElement("pre")) d.classList.add("object") d.innerHTML = hobj + + e.appendChild(document.createElement("p")).textContent = "This debugging information will not be available to participants." } // Hash routine used in v3.4 and earlier