mirror of https://github.com/dirtbags/moth.git
Trying to put javascript into v3
This commit is contained in:
parent
985b52ffd8
commit
07457d24bb
|
@ -1,4 +1,4 @@
|
||||||
FROM alpine AS builder
|
FROM alpine:3.8 AS builder
|
||||||
RUN apk --no-cache add go libc-dev
|
RUN apk --no-cache add go libc-dev
|
||||||
COPY src /src
|
COPY src /src
|
||||||
RUN go build -o /mothd /src/*.go
|
RUN go build -o /mothd /src/*.go
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM alpine:3.7
|
FROM alpine:3.8
|
||||||
|
|
||||||
RUN apk --no-cache add \
|
RUN apk --no-cache add \
|
||||||
gcc \
|
gcc \
|
||||||
|
|
|
@ -37,60 +37,6 @@ def escape(s):
|
||||||
return s.replace('&', '&').replace('<', '<').replace('>', '>')
|
return s.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||||
|
|
||||||
|
|
||||||
def generate_html(ziphandle, puzzle, puzzledir, category, points, authors, files):
|
|
||||||
html_content = io.StringIO()
|
|
||||||
file_content = io.StringIO()
|
|
||||||
if files:
|
|
||||||
file_content.write(
|
|
||||||
''' <section id="files">
|
|
||||||
<h2>Associated files:</h2>
|
|
||||||
<ul>
|
|
||||||
''')
|
|
||||||
for fn in files:
|
|
||||||
file_content.write(' <li><a href="{fn}">{efn}</a></li>\n'.format(fn=fn, efn=escape(fn)))
|
|
||||||
file_content.write(
|
|
||||||
''' </ul>
|
|
||||||
</section>
|
|
||||||
''')
|
|
||||||
scripts = ['<script src="{}"></script>'.format(s) for s in puzzle.scripts]
|
|
||||||
|
|
||||||
html_content.write(
|
|
||||||
'''<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
<title>{category} {points}</title>
|
|
||||||
<link rel="stylesheet" href="../../style.css">
|
|
||||||
{scripts}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>{category} for {points} points</h1>
|
|
||||||
<section id="readme">
|
|
||||||
{body} </section>
|
|
||||||
{file_content} <section id="form">
|
|
||||||
<form id="puzzler" action="../../cgi-bin/puzzler.cgi" method="get" accept-charset="utf-8" autocomplete="off">
|
|
||||||
<input type="hidden" name="c" value="{category}">
|
|
||||||
<input type="hidden" name="p" value="{points}">
|
|
||||||
<div>Team hash:<input name="t" size="8"></div>
|
|
||||||
<div>Answer:<input name="a" id="answer" size="20"></div>
|
|
||||||
<input type="submit" value="submit">
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
<address>Puzzle by <span class="authors" data-handle="{authors}">{authors}</span></address>
|
|
||||||
</body>
|
|
||||||
</html>'''.format(
|
|
||||||
category=category,
|
|
||||||
points=points,
|
|
||||||
body=puzzle.html_body(),
|
|
||||||
file_content=file_content.getvalue(),
|
|
||||||
authors=', '.join(authors),
|
|
||||||
scripts='\n'.join(scripts),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
ziphandle.writestr(os.path.join(puzzledir, 'index.html'), html_content.getvalue())
|
|
||||||
|
|
||||||
|
|
||||||
def build_category(categorydir, outdir):
|
def build_category(categorydir, outdir):
|
||||||
category_seed = binascii.b2a_hex(os.urandom(20))
|
category_seed = binascii.b2a_hex(os.urandom(20))
|
||||||
|
|
||||||
|
@ -148,11 +94,11 @@ def package(categoryname, categorydir, seed):
|
||||||
'authors': puzzle.authors,
|
'authors': puzzle.authors,
|
||||||
'hashes': puzzle.hashes(),
|
'hashes': puzzle.hashes(),
|
||||||
'files': files,
|
'files': files,
|
||||||
|
'scripts': puzzle.scripts,
|
||||||
'body': puzzle.html_body(),
|
'body': puzzle.html_body(),
|
||||||
}
|
}
|
||||||
puzzlejson = json.dumps(puzzledict)
|
puzzlejson = json.dumps(puzzledict)
|
||||||
zf.writestr(os.path.join(puzzledir, 'puzzle.json'), puzzlejson)
|
zf.writestr(os.path.join(puzzledir, 'puzzle.json'), puzzlejson)
|
||||||
generate_html(zf, puzzle, puzzledir, categoryname, puzzle.points, puzzle.get_authors(), files)
|
|
||||||
|
|
||||||
write_kv_pairs(zf, 'map.txt', mapping)
|
write_kv_pairs(zf, 'map.txt', mapping)
|
||||||
write_kv_pairs(zf, 'answers.txt', answers)
|
write_kv_pairs(zf, 'answers.txt', answers)
|
||||||
|
|
Loading…
Reference in New Issue