diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0634e13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.pyc +*.egg +*.egg-info +.DS_Store +__pycache__ + +.earwigbot +*.min.js +*.min.css +logs/* +!logs/.gitinclude diff --git a/app.py b/app.py index db8c411..0eee91c 100644 --- a/app.py +++ b/app.py @@ -1,28 +1,22 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- -from flask import Flask, g +from flask import Flask from flask.ext.mako import MakoTemplates, render_template +from tif.calc import calculate_tif from tif.util import catch_errors, set_up_hash_caching app = Flask(__name__) MakoTemplates(app) set_up_hash_caching(app) -@app.before_request -def prepare_request(): - g._db = None - -@app.teardown_appcontext -def close_databases(error): - if g._db: - g._db.close() - @app.route("/") @catch_errors(app) def index(): - return render_template("index.mako") + title = request.args.get("title") + result = calculate_tif(title) if title else None + return render_template("index.mako", result=result) if __name__ == '__main__': app.run() diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..f745d12 --- /dev/null +++ b/static/style.css @@ -0,0 +1,13 @@ +header {} + +footer {} + +#container {} + +#error {} + +#result {} + +#result-page {} + +#result-cache {} diff --git a/templates/error.mako b/templates/error.mako index e69de29..a2df007 100644 --- a/templates/error.mako +++ b/templates/error.mako @@ -0,0 +1,7 @@ +<%include file="/support/header.mako" args="title='Error - TIF Calculator'"/> +
An error occurred. If it hasn't been reported (try to check), please file an issue or email me. Include the following information:
+${traceback | trim,h}+
Can't find the given page: ${result["page"].title | h}.
+ % else + An unknown error occurred. + % endif +TIF | +${result["tif"]} | +
Transclusions | +${result["transclusions"]} | +
Protection | +${result["protection"]} | +