diff --git a/.gitignore b/.gitignore index 300eb37..9193cfb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.pyc __pycache__/ +config/ +data/ venv/ diff --git a/app.py b/app.py index 19318c6..17f6422 100755 --- a/app.py +++ b/app.py @@ -1,19 +1,29 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- +from pathlib import Path + from flask import Flask, g from flask_mako import MakoTemplates, render_template +from calefaction import __version__ as version +from calefaction.config import Config +from calefaction.eve import EVE from calefaction.util import catch_errors, set_up_hash_versioning +basepath = Path(__file__).resolve().parent app = Flask(__name__) +config = Config(basepath / "config") +eve = EVE() MakoTemplates(app) set_up_hash_versioning(app) @app.before_request def prepare_request(): - g.something = None # ... + g.config = config + g.eve = eve + g.version = version @app.route("/") @catch_errors(app) diff --git a/calefaction/__init__.py b/calefaction/__init__.py index e69de29..a4e2017 100644 --- a/calefaction/__init__.py +++ b/calefaction/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1" diff --git a/calefaction/config.py b/calefaction/config.py new file mode 100644 index 0000000..599a128 --- /dev/null +++ b/calefaction/config.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +import yaml + +__all__ = ["Config"] + +class Config: + + def __init__(self, confdir): + self._filename = confdir / "config.yml" + self._data = None + self._load() + + def _load(self): + with self._filename.open("rb") as fp: + self._data = yaml.load(fp) + + def get(self, key="", default=None): + obj = self._data + for item in key.split("."): + if item not in obj: + return default + obj = obj[item] + return obj diff --git a/calefaction/eve/__init__.py b/calefaction/eve/__init__.py new file mode 100644 index 0000000..a9e90e1 --- /dev/null +++ b/calefaction/eve/__init__.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +from .image import ImageServer + +__all__ = ["EVE"] + +class EVE: + + def __init__(self): + self._image = ImageServer() + + @property + def image(self): + return self._image diff --git a/calefaction/eve/image.py b/calefaction/eve/image.py new file mode 100644 index 0000000..9d5cb6f --- /dev/null +++ b/calefaction/eve/image.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +__all__ = ["ImageServer"] + +class ImageServer: + + def __init__(self): + self._url = "https://imageserver.eveonline.com/" + + @property + def alliance_widths(self): + return [32, 64, 128] + + @property + def corp_widths(self): + return [32, 64, 128, 256] + + @property + def character_widths(self): + return [32, 64, 128, 256, 512, 1024] + + @property + def faction_widths(self): + return [32, 64, 128] + + @property + def inventory_widths(self): + return [32, 64] + + @property + def render_widths(self): + return [32, 64, 128, 256, 512] + + def alliance(self, id, width): + return self._url + "Alliance/{}_{}.png".format(id, width) + + def corp(self, id, width): + return self._url + "Corporation/{}_{}.png".format(id, width) + + def character(self, id, width): + return self._url + "Character/{}_{}.jpg".format(id, width) + + def faction(self, id, width): + return self._url + "Alliance/{}_{}.jpg".format(id, width) + + def inventory(self, id, width): + return self._url + "Type/{}_{}.jpg".format(id, width) + + def render(self, id, width): + return self._url + "Render/{}_{}.jpg".format(id, width) diff --git a/calefaction/util.py b/calefaction/util.py index b288d46..cf9d46e 100644 --- a/calefaction/util.py +++ b/calefaction/util.py @@ -30,7 +30,10 @@ def set_up_hash_versioning(app): if endpoint == "staticv": filename = values["filename"] fpath = path.join(app.static_folder, filename) - mtime = path.getmtime(fpath) + try: + mtime = path.getmtime(fpath) + except OSError: + return url_for("static", filename=filename) cache = app._hash_cache.get(fpath) if cache and cache[0] == mtime: hashstr = cache[1] diff --git a/requirements.txt b/requirements.txt index 9923c3c..74fd9f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ Flask==0.11.1 Flask-Mako==0.4 +PyYAML==3.12 requests==2.12.4 diff --git a/static/images/amarr.jpg b/static/images/amarr.jpg new file mode 100644 index 0000000..d44aeda Binary files /dev/null and b/static/images/amarr.jpg differ diff --git a/static/images/caldari.jpg b/static/images/caldari.jpg new file mode 100644 index 0000000..13584e2 Binary files /dev/null and b/static/images/caldari.jpg differ diff --git a/static/images/gallente.jpg b/static/images/gallente.jpg new file mode 100644 index 0000000..713d937 Binary files /dev/null and b/static/images/gallente.jpg differ diff --git a/static/images/minmatar.jpg b/static/images/minmatar.jpg new file mode 100644 index 0000000..5b71ac0 Binary files /dev/null and b/static/images/minmatar.jpg differ diff --git a/static/style.css b/static/main.css similarity index 50% rename from static/style.css rename to static/main.css index 307496d..6e9cebd 100644 --- a/static/style.css +++ b/static/main.css @@ -1,14 +1,29 @@ -/* FONT... */ /* MOBILE... */ +@import url(//fonts.googleapis.com/css?family=Open+Sans:400,400italic,700); + body { display: flex; min-height: 100vh; flex-direction: column; margin: 0; - font-family: sans-serif; - background-color: #173350; - color: #E6EAEF; + font-family: "Open Sans", sans-serif; + line-height: 1.3; + color: #EAEAEA; + background-color: black; + background-size: cover; + background-position: center; + background-attachment: fixed; +} + +a { + color: #78CEFF; + text-decoration: none; +} + +a:hover { + color: #68BEDD; + text-decoration: underline; } #container { @@ -21,27 +36,46 @@ body { } main, header, footer { - background-color: rgba(0, 0, 0, 0.85); + background-color: rgba(0, 0, 0, 0.8); + border-color: #4A4A4A; +} + +main { + margin: 2em auto; + padding: 0 1em; + border-width: 1px; + border-style: solid; +} + +header { + font-size: 120%; + border-bottom-width: 1px; + border-bottom-style: solid; +} + +footer { + font-size: 85%; + border-top-width: 1px; + border-top-style: solid; } main, header > div, footer > div { max-width: 1000px; width: 80%; - padding: 1em; } -main { - margin: 2em auto; - border: 1px solid #364A5F; +header > div { + margin: 0 auto; + padding: 0.5em; } -header > div, footer > div { +footer > div { margin: 0 auto; + padding: 1em; } header > div > div { display: inline-block; - vertical-align: middle; } header > div > .left { @@ -54,24 +88,25 @@ header > div > .right { width: 30%; } -header { - font-size: 120%; - border-bottom: 1px solid #364A5F; +header a { + color: #EAEAEA; } -footer { - font-size: 85%; - border-top: 1px solid #364A5F; +header a:hover { + color: #CACACA; } -a { - color: #78CEFF; - text-decoration: none; +header .aligned { + vertical-align: middle; } -a:hover { - color: #68BEDD; - text-decoration: underline; +#corp-masthead { + height: 30px; + margin-right: 0.5em; +} + +#login-button { + height: 30px; } #error pre { diff --git a/static/styles/amarr.css b/static/styles/amarr.css new file mode 100644 index 0000000..89d9892 --- /dev/null +++ b/static/styles/amarr.css @@ -0,0 +1,7 @@ +body { + background-image: url("/static/images/amarr.jpg"); +} + +main, header, footer { + border-color: #5F4A26; +} diff --git a/static/styles/caldari.css b/static/styles/caldari.css new file mode 100644 index 0000000..d04db72 --- /dev/null +++ b/static/styles/caldari.css @@ -0,0 +1,7 @@ +body { + background-image: url("/static/images/caldari.jpg"); +} + +main, header, footer { + border-color: #364A5F; +} diff --git a/static/styles/gallente.css b/static/styles/gallente.css new file mode 100644 index 0000000..0e9006a --- /dev/null +++ b/static/styles/gallente.css @@ -0,0 +1,7 @@ +body { + background-image: url("/static/images/gallente.jpg"); +} + +main, header, footer { + border-color: #365F4A; +} diff --git a/static/styles/minmatar.css b/static/styles/minmatar.css new file mode 100644 index 0000000..5d49b5e --- /dev/null +++ b/static/styles/minmatar.css @@ -0,0 +1,7 @@ +body { + background-image: url("/static/images/minmatar.jpg"); +} + +main, header, footer { + border-color: #5F3C42; +} diff --git a/templates/_base.mako b/templates/_base.mako index f83cdb8..6d939fd 100644 --- a/templates/_base.mako +++ b/templates/_base.mako @@ -6,21 +6,22 @@ - <%block name="title">CORP_NAME...</%block> + <%block name="title">${g.config.get("corp.name")}</%block> - - + + + % for size in g.eve.image.corp_widths: + + % endfor ${next.body()}