| @@ -0,0 +1,3 @@ | |||||
| *.pyc | |||||
| __pycache__/ | |||||
| venv/ | |||||
| @@ -1,4 +1,4 @@ | |||||
| Copyright (C) 2015-2016 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| Copyright (C) 2016 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | of this software and associated documentation files (the "Software"), to deal | ||||
| @@ -1,10 +1,24 @@ | |||||
| calefaction | calefaction | ||||
| =========== | =========== | ||||
| __calefaction__ is a modular corporation manager for the video game | |||||
| __calefaction__ is a corporation manager and dashboard for the video game | |||||
| [EVE Online](https://www.eveonline.com/). | [EVE Online](https://www.eveonline.com/). | ||||
| Installing | |||||
| Guide | |||||
| ----- | |||||
| ... | |||||
| ### Install | |||||
| git clone git@github.com:earwig/calefaction.git | |||||
| cd calefaction | |||||
| python3 -m venv venv | |||||
| . venv/bin/activate | |||||
| pip install -r requirements.txt | |||||
| ### Setup | |||||
| ... | |||||
| ### Run | |||||
| ... | |||||
| @@ -0,0 +1,24 @@ | |||||
| #! /usr/bin/env python3 | |||||
| # -*- coding: utf-8 -*- | |||||
| from flask import Flask, g | |||||
| from flask_mako import MakoTemplates, render_template | |||||
| from calefaction.util import catch_errors, set_up_hash_versioning | |||||
| app = Flask(__name__) | |||||
| MakoTemplates(app) | |||||
| set_up_hash_versioning(app) | |||||
| @app.before_request | |||||
| def prepare_request(): | |||||
| g.something = None # ... | |||||
| @app.route("/") | |||||
| @catch_errors(app) | |||||
| def index(): | |||||
| return render_template("landing.mako") | |||||
| if __name__ == "__main__": | |||||
| app.run(debug=True, port=8080) | |||||
| @@ -0,0 +1,45 @@ | |||||
| # -*- coding: utf-8 -*- | |||||
| from functools import wraps | |||||
| from hashlib import md5 | |||||
| from os import path | |||||
| from traceback import format_exc | |||||
| from flask import url_for | |||||
| from flask_mako import render_template, TemplateError | |||||
| __all__ = ["catch_errors", "set_up_hash_versioning"] | |||||
| def catch_errors(app): | |||||
| def callback(func): | |||||
| @wraps(func) | |||||
| def inner(*args, **kwargs): | |||||
| try: | |||||
| return func(*args, **kwargs) | |||||
| except TemplateError as exc: | |||||
| app.logger.error("Caught exception:\n{0}".format(exc.text)) | |||||
| return render_template("error.mako", traceback=exc.text) | |||||
| except Exception: | |||||
| app.logger.exception("Caught exception:") | |||||
| return render_template("error.mako", traceback=format_exc()) | |||||
| return inner | |||||
| return callback | |||||
| def set_up_hash_versioning(app): | |||||
| def callback(app, error, endpoint, values): | |||||
| if endpoint == "staticv": | |||||
| filename = values["filename"] | |||||
| fpath = path.join(app.static_folder, filename) | |||||
| mtime = path.getmtime(fpath) | |||||
| cache = app._hash_cache.get(fpath) | |||||
| if cache and cache[0] == mtime: | |||||
| hashstr = cache[1] | |||||
| else: | |||||
| with open(fpath, "rb") as f: | |||||
| hashstr = md5(f.read()).hexdigest() | |||||
| app._hash_cache[fpath] = (mtime, hashstr) | |||||
| return url_for("static", filename=filename, v=hashstr) | |||||
| raise error | |||||
| app._hash_cache = {} | |||||
| app.url_build_error_handlers.append(lambda *args: callback(app, *args)) | |||||
| @@ -0,0 +1,3 @@ | |||||
| Flask==0.11.1 | |||||
| Flask-Mako==0.4 | |||||
| requests==2.12.4 | |||||
| @@ -0,0 +1,77 @@ | |||||
| /* FONT... */ | |||||
| /* MOBILE... */ | |||||
| body { | |||||
| display: flex; | |||||
| min-height: 100vh; | |||||
| flex-direction: column; | |||||
| margin: 0; | |||||
| font-family: sans-serif; | |||||
| background-color: #173350; | |||||
| color: #E6EAEF; | |||||
| } | |||||
| #container { | |||||
| display: flex; | |||||
| flex: 1; | |||||
| } | |||||
| #container > div { | |||||
| width: 100%; | |||||
| } | |||||
| main, header, footer { | |||||
| background-color: rgba(0, 0, 0, 0.85); | |||||
| } | |||||
| main, header > div, footer > div { | |||||
| max-width: 1000px; | |||||
| width: 80%; | |||||
| } | |||||
| main { | |||||
| margin: 2em auto; | |||||
| padding: 1em; | |||||
| } | |||||
| header > div { | |||||
| margin: 0 auto; | |||||
| padding: 1.5em; | |||||
| } | |||||
| header > div > div { | |||||
| display: inline-block; | |||||
| } | |||||
| header > div > .left { | |||||
| text-align: left; | |||||
| width: 70%; | |||||
| } | |||||
| header > div > .right { | |||||
| text-align: right; | |||||
| width: 30%; | |||||
| } | |||||
| footer { | |||||
| font-size: 85%; | |||||
| } | |||||
| footer > div { | |||||
| margin: 0 auto; | |||||
| padding: 1em; | |||||
| } | |||||
| a { | |||||
| color: #78CEFF; | |||||
| text-decoration: none; | |||||
| } | |||||
| a:hover { | |||||
| color: #68BEDD; | |||||
| text-decoration: underline; | |||||
| } | |||||
| #error pre { | |||||
| white-space: pre-wrap; | |||||
| } | |||||
| @@ -0,0 +1,29 @@ | |||||
| <%! | |||||
| from datetime import datetime | |||||
| %>\ | |||||
| <!DOCTYPE html> | |||||
| <html lang="en"> | |||||
| <head> | |||||
| <meta charset="utf-8"> | |||||
| <title> | |||||
| <%block name="title">CORP_NAME...</%block> | |||||
| </title> | |||||
| <link rel="stylesheet" href="${url_for('staticv', filename='style.css')}" type="text/css" /> | |||||
| <!-- FAVICONS... --> | |||||
| </head> | |||||
| <body> | |||||
| ${next.body()} | |||||
| <footer> | |||||
| <div> | |||||
| <% | |||||
| copyright_year = datetime.now().year | |||||
| %> | |||||
| Copyright © ${copyright_year} COPYRIGHT_HOLDER... | |||||
| • | |||||
| Running <a href="https://github.com/earwig/calefaction">Calefaction</a> CALEFACTION_VERSION... | |||||
| • | |||||
| <a href="https://eveonline.com">EVE Online</a> and all related trademarks are property of <a href="https://ccpgames.com">CCP hf</a>. | |||||
| </div> | |||||
| </footer> | |||||
| </body> | |||||
| </html> | |||||
| @@ -0,0 +1,9 @@ | |||||
| <%inherit file="_layout.mako"/> | |||||
| <%block name="lefthead"> | |||||
| [CORP_LOGO] CORP_NAME... | |||||
| <nav>Campaign: XYZ | Map | Intel | Members</nav> | |||||
| </%block> | |||||
| <%block name="righthead-"> | |||||
| PLAYER_NAME [logout] | |||||
| </%block> | |||||
| ${next.body()} | |||||
| @@ -0,0 +1,14 @@ | |||||
| <%inherit file="_base.mako"/> | |||||
| <header> | |||||
| <div> | |||||
| <div class="left"><%block name="lefthead"/></div><!-- | |||||
| --><div class="right"><%block name="righthead"/></div> | |||||
| </div> | |||||
| </header> | |||||
| <div id="container"> | |||||
| <div> | |||||
| <main> | |||||
| ${next.body()} | |||||
| </main> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,15 @@ | |||||
| <%inherit file="_base.mako"/> | |||||
| <%block name="title"> | |||||
| Error – ...name... | |||||
| </%block> | |||||
| <div id="container"> | |||||
| <div> | |||||
| <main> | |||||
| <h1>Error!</h1> | |||||
| <p>You may report the following information to the developers:</p> | |||||
| <div id="error"> | |||||
| <pre>${traceback | trim,h}</pre> | |||||
| </div> | |||||
| </main> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,8 @@ | |||||
| <%inherit file="_layout.mako"/> | |||||
| <%block name="lefthead"> | |||||
| [C_LOGO] C_NAME... | |||||
| </%block> | |||||
| <%block name="righthead"> | |||||
| [login] | |||||
| </%block> | |||||
| <p>Hello, world!</p> | |||||