@@ -0,0 +1,5 @@ | |||||
# -*- coding: utf-8 -*- | |||||
from .getters import get_current, get_count, get_summary, get_unit | |||||
from .routes import home, navitem | |||||
from .._provided import config |
@@ -0,0 +1,47 @@ | |||||
# -*- coding: utf-8 -*- | |||||
from flask import g | |||||
from .._provided import config | |||||
__all__ = ["get_current", "get_count", "get_summary", "get_unit"] | |||||
def get_current(): | |||||
"""Return the name of the currently selected campaign, or None.""" | |||||
if not config["enabled"]: | |||||
return None | |||||
setting = g.auth.get_character_modprop("campaigns", "current") | |||||
if not setting or setting not in config["enabled"]: | |||||
return config["enabled"][0] | |||||
return setting | |||||
def get_count(cname, opname): | |||||
"""Return the primary operation count for the given campaign/operation.""" | |||||
key = cname + "." + opname | |||||
operation = config["campaigns"][cname]["operations"][opname] | |||||
optype = operation["type"] | |||||
qualifiers = operation["qualifiers"] | |||||
... | |||||
import random | |||||
return [random.randint(0, 500), random.randint(10000, 500000), random.randint(10000000, 50000000000)][random.randint(0, 2)] | |||||
def get_summary(name, opname, limit=5): | |||||
"""Return a sample fraction of results for the given campaign/operation.""" | |||||
... | |||||
return [] | |||||
def get_unit(operation, num): | |||||
"""Return the correct form of the unit tracked by the given operation.""" | |||||
types = { | |||||
"killboard": "ship|ships", | |||||
"collection": "item|items" | |||||
} | |||||
if "unit" in operation: | |||||
unit = operation["unit"] | |||||
else: | |||||
unit = types[operation["type"]] | |||||
if "|" in unit: | |||||
return unit.split("|")[0 if num == 1 else 1] | |||||
return unit |
@@ -3,16 +3,11 @@ | |||||
from flask import abort, g, redirect, request, url_for | from flask import abort, g, redirect, request, url_for | ||||
from flask_mako import render_template | from flask_mako import render_template | ||||
from ._provided import blueprint, config | |||||
from .getters import get_current | |||||
from .._provided import blueprint, config | |||||
def get_current(): | |||||
"""Return the name of the currently selected campaign, or None.""" | |||||
if not config["enabled"]: | |||||
return None | |||||
setting = g.auth.get_character_modprop("campaigns", "current") | |||||
if not setting or setting not in config["enabled"]: | |||||
return config["enabled"][0] | |||||
return setting | |||||
__all__ = ["home", "navitem", "current_campaign", "campaign", "operation", | |||||
"set_campaign"] | |||||
def home(): | def home(): | ||||
"""Render and return the main campaign page.""" | """Render and return the main campaign page.""" |
@@ -36,6 +36,7 @@ campaigns: | |||||
titan: | titan: | ||||
title: Let's Build a Titan | title: Let's Build a Titan | ||||
type: collection | type: collection | ||||
unit: unit|units | |||||
qualifiers: |- | qualifiers: |- | ||||
return item_type == "Tritanium" | return item_type == "Tritanium" | ||||
bar: | bar: | ||||
@@ -376,24 +376,24 @@ h2 .disabled::after { | |||||
justify-content: space-between; | justify-content: space-between; | ||||
} | } | ||||
.operation .stats .primary { | |||||
.operation .overview .num { | |||||
line-height: 60px; | line-height: 60px; | ||||
height: 60px; | height: 60px; | ||||
} | } | ||||
.operation .stats .primary .big { | |||||
.operation .overview .num.big { | |||||
font-size: 300%; | font-size: 300%; | ||||
} | } | ||||
.operation .stats .primary .medium { | |||||
.operation .overview .num.medium { | |||||
font-size: 200%; | font-size: 200%; | ||||
} | } | ||||
.operation .stats .primary .small { | |||||
.operation .overview .num.small { | |||||
font-size: 150%; | font-size: 150%; | ||||
} | } | ||||
.operation .stats .unit { | |||||
.operation .overview .unit { | |||||
font-style: italic; | font-style: italic; | ||||
} | } | ||||
@@ -421,11 +421,11 @@ h2 .disabled::after { | |||||
margin: 0.5em 0; | margin: 0.5em 0; | ||||
} | } | ||||
.operation .stats > div { | |||||
.operation .overview > div { | |||||
display: inline-block; | display: inline-block; | ||||
} | } | ||||
.operation .stats .unit { | |||||
.operation .overview .unit { | |||||
margin-left: 0.25em; | margin-left: 0.25em; | ||||
} | } | ||||
} | } | ||||
@@ -6,28 +6,33 @@ | |||||
<span class="understate">Campaign:</span> | <span class="understate">Campaign:</span> | ||||
<span${"" if enabled else ' class="disabled"'}>${campaign["title"] | h}</span> | <span${"" if enabled else ' class="disabled"'}>${campaign["title"] | h}</span> | ||||
</h2> | </h2> | ||||
<% mod = g.config.modules.campaigns %> | |||||
<div id="operations"> | <div id="operations"> | ||||
% for section in campaign["layout"]: | % for section in campaign["layout"]: | ||||
<% klass = "loose" if len(section) < 3 else "tight" %> | <% klass = "loose" if len(section) < 3 else "tight" %> | ||||
<section class="${klass}"> | <section class="${klass}"> | ||||
% for opname in section: | % for opname in section: | ||||
<% operation = campaign["operations"][opname] %> | |||||
<% | |||||
operation = campaign["operations"][opname] | |||||
num = mod.get_count(name, opname) | |||||
summary = mod.get_summary(name, opname, limit=5) | |||||
klass = "big" if num < 1000 else "medium" if num < 1000000 else "small" | |||||
%> | |||||
<div class="operation"> | <div class="operation"> | ||||
<h3><a href="${url_for('campaigns.operation', cname=name, opname=opname)}">${operation["title"] | h}</a></h3> | |||||
<div class="stats"> | |||||
<!-- ... --> | |||||
<% | |||||
random = __import__("random") | |||||
n = [random.randint(0, 500), random.randint(10000, 500000), random.randint(10000000, 50000000000)][random.randint(0, 2)] | |||||
%> | |||||
<% | |||||
klass = "big" if n < 1000 else "medium" if n < 1000000 else "small" | |||||
%> | |||||
<div class="primary"> | |||||
<span class="${klass}">${"{:,}".format(n)}</span> | |||||
</div> | |||||
<div class="unit">${"ships" if klass == "big" else "points" if klass == "medium" else "ISK"}</div> <!-- ... plural --> | |||||
<h3> | |||||
<a href="${url_for('campaigns.operation', cname=name, opname=opname)}">${operation["title"] | h}</a> | |||||
</h3> | |||||
<div class="overview"> | |||||
<div class="num ${klass}">${"{:,}".format(num)}</div> | |||||
<div class="unit">${mod.get_unit(operation, num)}</div> | |||||
</div> | </div> | ||||
% if summary: | |||||
<ul class="summary"> | |||||
% for item in summary: | |||||
<li>${item}</li> | |||||
% endfor | |||||
</ul> | |||||
% endif | |||||
</div> | </div> | ||||
% endfor | % endfor | ||||
</section> | </section> | ||||