| @@ -1,15 +0,0 @@ | |||||
| <%! | |||||
| from random import choice | |||||
| bashes = [ | |||||
| "Now 20% cooler!", | |||||
| "I make tools and tool accessories." | |||||
| ] | |||||
| %>\ | |||||
| <%def name="get_bash()">${choice(bashes)}</%def>\ | |||||
| <%include file="/support/header.mako" args="environ=environ, title='Bash'"/> | |||||
| <ol> | |||||
| % for bash in bashes: | |||||
| <li>${bash}</li> | |||||
| % endfor | |||||
| </ol> | |||||
| <%include file="/support/footer.mako" args="environ=environ"/> | |||||
| @@ -1,5 +1,4 @@ | |||||
| <%page args="environ"/>\ | <%page args="environ"/>\ | ||||
| <%namespace name="bash" file="/bash.mako" import="get_bash"/>\ | |||||
| <%! | <%! | ||||
| from os import path | from os import path | ||||
| %>\ | %>\ | ||||
| @@ -20,8 +19,7 @@ | |||||
| <a href="mailto:earwig@toolserver.org">Contact</a> • \ | <a href="mailto:earwig@toolserver.org">Contact</a> • \ | ||||
| <a href="https://github.com/earwig/toolserver">View Source</a> • \ | <a href="https://github.com/earwig/toolserver">View Source</a> • \ | ||||
| <a id="bg_image_link" href="">Background</a> • \ | <a id="bg_image_link" href="">Background</a> • \ | ||||
| <a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0 Strict</a><br /> | |||||
| <i><a class="black" href="${pretty}/bash">"${get_bash()}"</a></i> | |||||
| <a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0 Strict</a> | |||||
| </p> | </p> | ||||
| </td> | </td> | ||||
| <td> | <td> | ||||
| @@ -7,11 +7,20 @@ from earwigbot.bot import Bot | |||||
| import oursql | import oursql | ||||
| class Query(object): | class Query(object): | ||||
| def __init__(self, environ): | |||||
| def __init__(self, environ, method="GET"): | |||||
| self.query = {} | self.query = {} | ||||
| parsed = parse_qs(environ["QUERY_STRING"]) | |||||
| if method == "GET": | |||||
| parsed = parse_qs(environ["QUERY_STRING"]) | |||||
| elif method == "POST": | |||||
| size = environ.get("CONTENT_LENGTH", 0) | |||||
| parsed = parse_qs(environ["wsgi.input"].read(size)) | |||||
| else: | |||||
| parsed = {} | |||||
| for key, value in parsed.iteritems(): | for key, value in parsed.iteritems(): | ||||
| self.query[key] = value[-1].decode("utf8") | |||||
| try: | |||||
| self.query[key] = value[-1].decode("utf8") | |||||
| except UnicodeDecodeError: | |||||
| pass | |||||
| def __getattr__(self, key): | def __getattr__(self, key): | ||||
| try: | try: | ||||
| @@ -6,7 +6,7 @@ from .sites import get_sites | |||||
| def main(context, environ, headers): | def main(context, environ, headers): | ||||
| cookies = parse_cookies(context, environ) | cookies = parse_cookies(context, environ) | ||||
| query = Query(environ) | |||||
| query = Query(environ, method="POST") | |||||
| if query.action == "set": | if query.action == "set": | ||||
| if query.lang: | if query.lang: | ||||