| @@ -1,6 +1,6 @@ | |||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||
| from flask import abort, g | |||||
| from flask import abort, g, request | |||||
| from flask_mako import render_template | from flask_mako import render_template | ||||
| from ._provided import blueprint, config | from ._provided import blueprint, config | ||||
| @@ -16,7 +16,12 @@ def get_current(): | |||||
| def home(): | def home(): | ||||
| """Render and return the main campaign page.""" | """Render and return the main campaign page.""" | ||||
| return render_template("campaigns/campaign.mako", current=get_current()) | |||||
| current = get_current() | |||||
| if current: | |||||
| campaign = config["campaigns"][current] | |||||
| return render_template( | |||||
| "campaigns/campaign.mako", name=current, campaign=campaign) | |||||
| return render_template("campaigns/empty.mako") | |||||
| def navitem(): | def navitem(): | ||||
| """Render and return the navigation item for this module.""" | """Render and return the navigation item for this module.""" | ||||
| @@ -30,10 +35,11 @@ def campaign(): | |||||
| """Render and return the current campaign page.""" | """Render and return the current campaign page.""" | ||||
| return home() | return home() | ||||
| @blueprint.rroute("/settings/campaign/<campaign>", methods=["POST"]) | |||||
| def set_campaign(campaign): | |||||
| @blueprint.rroute("/settings/campaign", methods=["POST"]) | |||||
| def set_campaign(): | |||||
| """Update the user's currently selected campaign.""" | """Update the user's currently selected campaign.""" | ||||
| campaign = request.args.get("campaign") | |||||
| if campaign not in config["enabled"]: | if campaign not in config["enabled"]: | ||||
| abort(404) | |||||
| abort(400) | |||||
| g.auth.set_character_modprop("campaigns", "current", campaign) | g.auth.set_character_modprop("campaigns", "current", campaign) | ||||
| return "", 204 | return "", 204 | ||||
| @@ -4,12 +4,12 @@ | |||||
| # List of active campaigns, in your preferred order: | # List of active campaigns, in your preferred order: | ||||
| enabled: | enabled: | ||||
| - Foo | |||||
| - Bar | |||||
| - foo | |||||
| - bar | |||||
| campaigns: | campaigns: | ||||
| # ... | # ... | ||||
| Foo: | |||||
| a: b | |||||
| Bar: | |||||
| a: b | |||||
| foo: | |||||
| title: Foo | |||||
| bar: | |||||
| title: Bar | |||||
| @@ -322,6 +322,27 @@ footer ul li:not(:last-child)::after { | |||||
| } | } | ||||
| /* ================================ Modules ================================ */ | /* ================================ Modules ================================ */ | ||||
| /* ------------------------------- Campaigns ------------------------------- */ | |||||
| #campaigns-select { | |||||
| display: inline-block; | |||||
| padding-right: 1em; | |||||
| background: transparent 100% 50%/contain no-repeat; | |||||
| border-width: 1px; | |||||
| } | |||||
| #campaigns-select select { | |||||
| max-width: 120px; | |||||
| padding: 0 0.25em; | |||||
| font-size: 100%; | |||||
| color: inherit; | |||||
| background: transparent; | |||||
| border: none; | |||||
| appearance: none; | |||||
| -webkit-appearance: none; | |||||
| -moz-appearance: none; | |||||
| } | |||||
| /* -------------------------------- Members -------------------------------- */ | /* -------------------------------- Members -------------------------------- */ | ||||
| #members-list { | #members-list { | ||||
| @@ -3,6 +3,8 @@ var overlaps = function(needle, haystack) { | |||||
| }; | }; | ||||
| $(function() { | $(function() { | ||||
| /* ============================= Universal ============================= */ | |||||
| // Install logout auto-POST form: | // Install logout auto-POST form: | ||||
| $("#logout").click(function() { | $("#logout").click(function() { | ||||
| $("<form>", { | $("<form>", { | ||||
| @@ -43,4 +45,12 @@ $(function() { | |||||
| .prop("disabled", false); | .prop("disabled", false); | ||||
| $(this).addClass("cur").find(":submit").prop("disabled", true); | $(this).addClass("cur").find(":submit").prop("disabled", true); | ||||
| }); | }); | ||||
| /* ============================== Modules ============================== */ | |||||
| // Campaigns: enable form auto-submit on campaign change: | |||||
| $("#campaigns-select select").change(function() { | |||||
| this.form.submit(); | |||||
| }); | |||||
| $('#campaigns-select input[type="submit"]').hide(); | |||||
| }); | }); | ||||
| @@ -17,3 +17,7 @@ a { | |||||
| a:hover { | a:hover { | ||||
| color: #DDBE68; | color: #DDBE68; | ||||
| } | } | ||||
| #campaigns-select { | |||||
| background-image: url('data:image/svg+xml;utf8,<?xml version="1.0" standalone="no"?><svg height="60" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><polygon points="13,20 48,20 30,45" style="fill:#584A26;"/></svg>'); | |||||
| } | |||||
| @@ -17,3 +17,7 @@ a { | |||||
| a:hover { | a:hover { | ||||
| color: #88BBDD; | color: #88BBDD; | ||||
| } | } | ||||
| #campaigns-select { | |||||
| background-image: url('data:image/svg+xml;utf8,<?xml version="1.0" standalone="no"?><svg height="60" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><polygon points="13,20 48,20 30,45" style="fill:#364A5F;"/></svg>'); | |||||
| } | |||||
| @@ -17,3 +17,7 @@ a { | |||||
| a:hover { | a:hover { | ||||
| color: #60AA90; | color: #60AA90; | ||||
| } | } | ||||
| #campaigns-select { | |||||
| background-image: url('data:image/svg+xml;utf8,<?xml version="1.0" standalone="no"?><svg height="60" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><polygon points="13,20 48,20 30,45" style="fill:#284A36;"/></svg>'); | |||||
| } | |||||
| @@ -17,3 +17,7 @@ a { | |||||
| a:hover { | a:hover { | ||||
| color: #C88070; | color: #C88070; | ||||
| } | } | ||||
| #campaigns-select { | |||||
| background-image: url('data:image/svg+xml;utf8,<?xml version="1.0" standalone="no"?><svg height="60" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><polygon points="13,20 48,20 30,45" style="fill:#5F3632;"/></svg>'); | |||||
| } | |||||
| @@ -1,7 +1,6 @@ | |||||
| <%inherit file="../_default.mako"/> | <%inherit file="../_default.mako"/> | ||||
| % if current: | |||||
| <h2><span class="understate">Campaign:</span> ${current} <!-- select ... --></h2> | |||||
| <p>Hello! ...</p> | |||||
| % else: | |||||
| <p>No campaigns currently.</p> | |||||
| % endif | |||||
| <%block name="title"> | |||||
| ${campaign["title"] | h} – Campaign – ${g.config.get("corp.name") | h} | |||||
| </%block> | |||||
| <h2><span class="understate">Campaign:</span> ${campaign["title"] | h}</h2> | |||||
| <p>Hello! ...</p> | |||||
| @@ -0,0 +1,2 @@ | |||||
| <%inherit file="../_default.mako"/> | |||||
| <p>No campaigns currently.</p> | |||||
| @@ -1,6 +1,16 @@ | |||||
| Campaign: | Campaign: | ||||
| % if request.url_rule.endpoint == "campaigns.campaign": | % if request.url_rule.endpoint == "campaigns.campaign": | ||||
| <strong>${current}</strong> | |||||
| <form id="campaigns-select" action="${url_for('campaigns.set_campaign')}" method="post" class="styled-border"> | |||||
| <select name="campaign"> | |||||
| <% config = g.config.modules.campaigns.config %> | |||||
| % for name in config["enabled"]: | |||||
| <% params = config["campaigns"][name] %> | |||||
| <option value="${name | h}"${" selected" if name == current else ""}>${params["title"] | h}</option> | |||||
| % endfor | |||||
| </select> | |||||
| <input type="submit" value="Change"> | |||||
| </form> | |||||
| % else: | % else: | ||||
| <a href="${url_for('campaigns.campaign')}">${current}</a> | |||||
| <% campaign = g.config.modules.campaigns.config["campaigns"][current] %> | |||||
| <a href="${url_for('campaigns.campaign')}">${campaign["title"]}</a> | |||||
| % endif | % endif | ||||
| @@ -1,4 +1,7 @@ | |||||
| <%inherit file="../_default.mako"/> | <%inherit file="../_default.mako"/> | ||||
| <%block name="title"> | |||||
| Members – ${g.config.get("corp.name") | h} | |||||
| </%block> | |||||
| <h2>Members</h2> | <h2>Members</h2> | ||||
| % if members: | % if members: | ||||
| <ul id="members-list"> | <ul id="members-list"> | ||||