mirror of https://github.com/dirtbags/moth.git
multiple author support
This commit is contained in:
parent
ee92b6e4b2
commit
74e871fe55
|
@ -176,7 +176,7 @@ you are a fool.
|
|||
for a in puzzle.answers:
|
||||
body.write("<li><code>{}</code></li>".format(html.escape(a)))
|
||||
body.write("</ul>")
|
||||
body.write("<h2>Author</h2><p>{}</p>".format(puzzle.author))
|
||||
body.write("<h2>Authors</h2><p>{}</p>".format(', '.join(puzzle.get_authors())))
|
||||
body.write("<h2>Summary</h2><p>{}</p>".format(puzzle.summary))
|
||||
if puzzle.logs:
|
||||
body.write("<h2>Debug Log</h2>")
|
||||
|
|
|
@ -63,8 +63,8 @@ class Puzzle:
|
|||
super().__init__()
|
||||
|
||||
self.points = points
|
||||
self.author = None
|
||||
self.summary = None
|
||||
self.authors = []
|
||||
self.answers = []
|
||||
self.files = {}
|
||||
self.body = io.StringIO()
|
||||
|
@ -88,7 +88,7 @@ class Puzzle:
|
|||
key = key.lower()
|
||||
val = val.strip()
|
||||
if key == 'author':
|
||||
self.author = val
|
||||
self.authors.append(val)
|
||||
elif key == 'summary':
|
||||
self.summary = val
|
||||
elif key == 'answer':
|
||||
|
@ -234,6 +234,9 @@ class Puzzle:
|
|||
self.body.write('{:08x}\n'.format(offset))
|
||||
self.body.write('</pre>')
|
||||
|
||||
def get_authors(self):
|
||||
return self.authors or [self.author]
|
||||
|
||||
def get_body(self):
|
||||
return self.body.getvalue()
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ def write_kv_pairs(ziphandle, filename, kv):
|
|||
def escape(s):
|
||||
return s.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||
|
||||
def generate_html(ziphandle, puzzle, puzzledir, category, points, author, files):
|
||||
def generate_html(ziphandle, puzzle, puzzledir, category, points, authors, files):
|
||||
html_content = io.StringIO()
|
||||
file_content = io.StringIO()
|
||||
if files:
|
||||
|
@ -73,14 +73,14 @@ def generate_html(ziphandle, puzzle, puzzledir, category, points, author, files)
|
|||
<input type="submit" value="submit">
|
||||
</form>
|
||||
</section>
|
||||
<address>Puzzle by <span class="author" data-handle="{author}">{author}</span></address>
|
||||
<address>Puzzle by <span class="authors" data-handle="{authors}">{authors}</span></address>
|
||||
<section id="sponsors">
|
||||
<img src="../../images/lanl.png" alt="Los Alamos National Laboratory">
|
||||
<img src="../../images/doe.png" alt="US Department Of Energy">
|
||||
<img src="../../images/sandia.png" alt="Sandia National Laboratories">
|
||||
</section>
|
||||
</body>
|
||||
</html>'''.format(category=category, points=points, body=puzzle.html_body(), file_content=file_content.getvalue(), author=author))
|
||||
</html>'''.format(category=category, points=points, body=puzzle.html_body(), file_content=file_content.getvalue(), authors=', '.join(authors)))
|
||||
ziphandle.writestr(os.path.join(puzzledir, 'index.html'), html_content.getvalue())
|
||||
|
||||
def build_category(categorydir, outdir):
|
||||
|
@ -132,14 +132,14 @@ def build_category(categorydir, outdir):
|
|||
zf.writestr(os.path.join(puzzledir, fn), payload)
|
||||
|
||||
puzzledict = {
|
||||
'author': puzzle.author,
|
||||
'authors': puzzle.authors,
|
||||
'hashes': puzzle.hashes(),
|
||||
'files': files,
|
||||
'body': puzzle.html_body(),
|
||||
}
|
||||
puzzlejson = json.dumps(puzzledict)
|
||||
zf.writestr(os.path.join(puzzledir, 'puzzle.json'), puzzlejson)
|
||||
generate_html(zf, puzzle, puzzledir, categoryname, puzzle.points, puzzle.author, files)
|
||||
generate_html(zf, puzzle, puzzledir, categoryname, puzzle.points, puzzle.get_authors(), files)
|
||||
|
||||
write_kv_pairs(zf, 'map.txt', mapping)
|
||||
write_kv_pairs(zf, 'answers.txt', answers)
|
||||
|
|
Loading…
Reference in New Issue