diff --git a/.gitignore b/.gitignore index 9193cfb..a1e953a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ *.pyc __pycache__/ -config/ -data/ venv/ + +config/* +data/* + +!config/config.yml.sample diff --git a/README.md b/README.md index 3f18342..c7f5100 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,15 @@ Guide ### Setup + cp config.yml.sample config.yml + vim config.yml ... -### Run +### Test + + ./app.py + # go to http://localhost:8080 + +### Deploy ... diff --git a/app.py b/app.py index 17f6422..c05872e 100755 --- a/app.py +++ b/app.py @@ -6,7 +6,7 @@ from pathlib import Path from flask import Flask, g from flask_mako import MakoTemplates, render_template -from calefaction import __version__ as version +import calefaction from calefaction.config import Config from calefaction.eve import EVE from calefaction.util import catch_errors, set_up_hash_versioning @@ -23,7 +23,7 @@ set_up_hash_versioning(app) def prepare_request(): g.config = config g.eve = eve - g.version = version + g.version = calefaction.__version__ @app.route("/") @catch_errors(app) diff --git a/config/config.yml.sample b/config/config.yml.sample new file mode 100644 index 0000000..2eb0ec1 --- /dev/null +++ b/config/config.yml.sample @@ -0,0 +1,22 @@ +# This is a sample config file for Calefaction. +# Copy this to config.yml and modify it to set up your website. + +corp: + # Find your corp's ID at, e.g., https://zkillboard.com/corporation/917701062/ + id: 123456789 + # Full corp name (doesn't need to match in-game name exactly, but should) + name: My Corp Name Here + +welcome: |- + (If you are seeing this message on the public internet, someone forgot to + configure their website. Whoops!) + + This message is displayed to anyone who reaches your website without + (or before) logging in. + + It's public, so don't give away any secrets. You might want to explain a bit + about your corp, with recruitment information, or invite corp members to log + in, or maybe just say something cryptic. + + You can type raw HTML in here. Newlines are ignored, except for double + linebreaks, which are treated as separate paragraphs. diff --git a/templates/_base.mako b/templates/_base.mako index 6d939fd..c671c4f 100644 --- a/templates/_base.mako +++ b/templates/_base.mako @@ -1,12 +1,9 @@ -<%! - from datetime import datetime -%>\ - <%block name="title">${g.config.get("corp.name")}</%block> + <%block name="title">${g.config.get("corp.name") | h}</%block> @@ -15,16 +12,40 @@ % endfor - ${next.body()} - + + <%block name="footer"> + + diff --git a/templates/_default.mako b/templates/_default.mako index b30b29a..f329127 100644 --- a/templates/_default.mako +++ b/templates/_default.mako @@ -1,9 +1,6 @@ -<%inherit file="_layout.mako"/> +<%inherit file="_base.mako"/> <%block name="lefthead"> - - - - ${g.config.get("corp.name")} + ${parent.lefthead()} diff --git a/templates/_layout.mako b/templates/_layout.mako deleted file mode 100644 index 5080fec..0000000 --- a/templates/_layout.mako +++ /dev/null @@ -1,14 +0,0 @@ -<%inherit file="_base.mako"/> -
-
-
<%block name="lefthead"/>
<%block name="righthead"/>
-
-
-
-
-
- ${next.body()} -
-
-
diff --git a/templates/error.mako b/templates/error.mako index 50aa719..b59ccd7 100644 --- a/templates/error.mako +++ b/templates/error.mako @@ -1,15 +1,10 @@ <%inherit file="_base.mako"/> <%block name="title"> - Error – ${g.config.get("corp.name")} + Error – ${g.config.get("corp.name") | h} -
-
-
-

Error!

-

You may report the following information to the developers:

-
-
${traceback | trim,h}
-
-
-
+<%block name="header"/> +

Error!

+

You may report the following information to the developers:

+
+
${traceback | trim,h}
diff --git a/templates/landing.mako b/templates/landing.mako index f6aaf67..2f6a6a2 100644 --- a/templates/landing.mako +++ b/templates/landing.mako @@ -1,11 +1,9 @@ -<%inherit file="_layout.mako"/> -<%block name="lefthead"> - - - - ${g.config.get("corp.name")} - +<%inherit file="_base.mako"/> <%block name="righthead"> -

Hello, world!

+
+ % for paragraph in g.config.get("welcome").split("\n\n"): +

${paragraph.replace("\n", " ")}

+ % endfor +