Преглед на файлове

Restructure template inheritance and add sample config.

master
Ben Kurtovic преди 8 години
родител
ревизия
a290942e7a
променени са 9 файла, в които са добавени 86 реда и са изтрити 57 реда
  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 Целия файл

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

config/*
data/*

!config/config.yml.sample

+ 8
- 1
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

...

+ 2
- 2
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)


+ 22
- 0
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.

+ 35
- 14
templates/_base.mako Целия файл

@@ -1,12 +1,9 @@
<%!
from datetime import datetime
%>\
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
<%block name="title">${g.config.get("corp.name")}</%block>
<%block name="title">${g.config.get("corp.name") | h}</%block>
</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='styles/minmatar.css')}" />
@@ -15,16 +12,40 @@
% endfor
</head>
<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>
</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>
</html>

+ 2
- 5
templates/_default.mako Целия файл

@@ -1,9 +1,6 @@
<%inherit file="_layout.mako"/>
<%inherit file="_base.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>
${parent.lefthead()}
<nav>
Campaign: XYZ | Map | Intel | Members...
</nav>


+ 0
- 14
templates/_layout.mako Целия файл

@@ -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 Целия файл

@@ -1,15 +1,10 @@
<%inherit file="_base.mako"/>
<%block name="title">
Error &ndash; ${g.config.get("corp.name")}
Error &ndash; ${g.config.get("corp.name") | h}
</%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>

+ 6
- 8
templates/landing.mako Целия файл

@@ -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">
<img id="login-button" class="aligned" src="${url_for('staticv', filename='images/eve-login.png')}"/>
</%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>

Зареждане…
Отказ
Запис