Browse Source

Restructure template inheritance and add sample config.

master
Ben Kurtovic 8 years ago
parent
commit
a290942e7a
9 changed files with 86 additions and 57 deletions
  1. +5
    -2
      .gitignore
  2. +8
    -1
      README.md
  3. +2
    -2
      app.py
  4. +22
    -0
      config/config.yml.sample
  5. +35
    -14
      templates/_base.mako
  6. +2
    -5
      templates/_default.mako
  7. +0
    -14
      templates/_layout.mako
  8. +6
    -11
      templates/error.mako
  9. +6
    -8
      templates/landing.mako

+ 5
- 2
.gitignore View File

@@ -1,5 +1,8 @@
*.pyc *.pyc
__pycache__/ __pycache__/
config/
data/
venv/ venv/

config/*
data/*

!config/config.yml.sample

+ 8
- 1
README.md View File

@@ -17,8 +17,15 @@ Guide


### Setup ### Setup


cp config.yml.sample config.yml
vim config.yml
... ...


### Run
### Test

./app.py
# go to http://localhost:8080

### Deploy


... ...

+ 2
- 2
app.py View File

@@ -6,7 +6,7 @@ from pathlib import Path
from flask import Flask, g from flask import Flask, g
from flask_mako import MakoTemplates, render_template from flask_mako import MakoTemplates, render_template


from calefaction import __version__ as version
import calefaction
from calefaction.config import Config from calefaction.config import Config
from calefaction.eve import EVE from calefaction.eve import EVE
from calefaction.util import catch_errors, set_up_hash_versioning from calefaction.util import catch_errors, set_up_hash_versioning
@@ -23,7 +23,7 @@ set_up_hash_versioning(app)
def prepare_request(): def prepare_request():
g.config = config g.config = config
g.eve = eve g.eve = eve
g.version = version
g.version = calefaction.__version__


@app.route("/") @app.route("/")
@catch_errors(app) @catch_errors(app)


+ 22
- 0
config/config.yml.sample View File

@@ -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.

+ 35
- 14
templates/_base.mako View File

@@ -1,12 +1,9 @@
<%!
from datetime import datetime
%>\
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title> <title>
<%block name="title">${g.config.get("corp.name")}</%block>
<%block name="title">${g.config.get("corp.name") | h}</%block>
</title> </title>
<link rel="stylesheet" type="text/css" href="${url_for('staticv', filename='main.css')}" /> <link rel="stylesheet" type="text/css" href="${url_for('staticv', filename='main.css')}" />
<link rel="stylesheet" type="text/css" href="${url_for('staticv', filename='styles/minmatar.css')}" /> <link rel="stylesheet" type="text/css" href="${url_for('staticv', filename='styles/minmatar.css')}" />
@@ -15,16 +12,40 @@
% endfor % endfor
</head> </head>
<body> <body>
${next.body()}
<footer>
<div>
<% copyright_year = datetime.now().year %>
Copyright &copy; ${copyright_year} ${g.config.get("corp.copyright")}
&bull;
Running <a href="https://github.com/earwig/calefaction">Calefaction</a> ${g.version}
&bull;
<a href="https://eveonline.com">EVE Online</a> and all related trademarks are property of <a href="https://ccpgames.com">CCP hf</a>.
<%block name="header">
<header>
<div>
<div class="left">
<%block name="lefthead">
<a href="/">
<img id="corp-masthead" class="aligned" src="${g.eve.image.corp(g.config.get('corp.id'), 256)}"/>
</a>
<a href="/" class="aligned">${g.config.get("corp.name") | h}</a>
</%block>
</div><!--
--><div class="right">
<%block name="righthead"/>
</div>
</div>
</header>
</%block>
<%block name="container">
<div id="container">
<div>
<main>
${next.body()}
</main>
</div>
</div> </div>
</footer>
</%block>
<%block name="footer">
<footer>
<div>
Running <a href="https://github.com/earwig/calefaction">Calefaction</a> ${g.version}
&bull;
<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>
</%block>
</body> </body>
</html> </html>

+ 2
- 5
templates/_default.mako View File

@@ -1,9 +1,6 @@
<%inherit file="_layout.mako"/>
<%inherit file="_base.mako"/>
<%block name="lefthead"> <%block name="lefthead">
<a href="/">
<img id="corp-masthead" class="aligned" src="${g.eve.image.corp(g.config.get('corp.id'), 256)}"/>
</a>
<a href="/" class="aligned">${g.config.get("corp.name")}</a>
${parent.lefthead()}
<nav> <nav>
Campaign: XYZ | Map | Intel | Members... Campaign: XYZ | Map | Intel | Members...
</nav> </nav>


+ 0
- 14
templates/_layout.mako View File

@@ -1,14 +0,0 @@
<%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>

+ 6
- 11
templates/error.mako View File

@@ -1,15 +1,10 @@
<%inherit file="_base.mako"/> <%inherit file="_base.mako"/>
<%block name="title"> <%block name="title">
Error &ndash; ${g.config.get("corp.name")}
Error &ndash; ${g.config.get("corp.name") | h}
</%block> </%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>
<%block name="header"/>
<h1>Error!</h1>
<p>You may report the following information to the developers:</p>
<div id="error">
<pre>${traceback | trim,h}</pre>
</div> </div>

+ 6
- 8
templates/landing.mako View File

@@ -1,11 +1,9 @@
<%inherit file="_layout.mako"/>
<%block name="lefthead">
<a href="/">
<img id="corp-masthead" class="aligned" src="${g.eve.image.corp(g.config.get('corp.id'), 256)}"/>
</a>
<a href="/" class="aligned">${g.config.get("corp.name")}</a>
</%block>
<%inherit file="_base.mako"/>
<%block name="righthead"> <%block name="righthead">
<img id="login-button" class="aligned" src="${url_for('staticv', filename='images/eve-login.png')}"/> <img id="login-button" class="aligned" src="${url_for('staticv', filename='images/eve-login.png')}"/>
</%block> </%block>
<p>Hello, world!</p>
<div id="welcome">
% for paragraph in g.config.get("welcome").split("\n\n"):
<p>${paragraph.replace("\n", " ")}</p>
% endfor
</div>

Loading…
Cancel
Save