Browse Source

player token database

master
Brandon Cornejo 2 years ago
parent
commit
eada4c8adf
  1. 34
      acks/quest/views.py
  2. 4
      acks/templates/base.html
  3. 62
      acks/templates/player_tokens.html
  4. 35
      acks/views.py

34
acks/quest/views.py

@ -39,37 +39,3 @@ def quest_detail(level, quest_name):
def quest_download(level, quest_name):
archive = get_quest_archive(level, quest_name)
return send_file(archive, attachment_filename="acks_{0}.zip".format(quest_name), as_attachment=True)
'''
@npc_views.route('/party')
@npc_views.route('/party/<int:base_level>')
def generate_npc_party(base_level=None):
party = None
if base_level:
party = create_party(base_level)
# If asked for JSON, return the party, otherwise render HTML template
if request.args.get('format', 'html') == 'json':
return jsonify([npc.roll20_format for npc in party])
return render_template('generate_npc_party.html', party=party, base_level=base_level)
@npc_views.route('/single')
@npc_views.route('/single/<int:base_level>/<int:guild_id>')
def generate_single_npc(base_level=None, guild_id=0):
guilds = CharacterClass.query.filter(CharacterClass.bucket.notin_(['Demi-Human'])).all()
npc = None
if base_level:
npc = create_npc(base_level, guild_id)
# If asked for JSON, return the npc, otherwise render HTML template
if request.args.get('format', 'html') == 'json':
return jsonify(npc)
return render_template('generate_single_npc.html', npc=npc, base_level=base_level, guilds=guilds, guild_id=guild_id)
@npc_views.route('/spells')
def spell_list():
spells = Spell.query.all()
return render_template('spell_list.html', spells=spells)
'''

4
acks/templates/base.html

@ -4,11 +4,11 @@
('https://reddit.com/r/PalismaACKS/wiki', 'redditwiki', 'Wiki', true),
] %}
{% set judge_bar = [
('/npc/party', 'npcparty', 'Generate Party', false),
('/npc/single', 'npcsingle', 'Generate NPC', false),
('/lairs', 'lairs', 'Lairs', false),
('http://autarch.co/treasure', 'treasure', 'Treasure', true),
('/quest/list', 'questlist', 'Quests', false),
('/npc/party', 'npcparty', 'Generate Party', false),
('/npc/single', 'npcsingle', 'Generate NPC', false),
('/wiki', 'wiki', 'Wiki', false),
]%}

62
acks/templates/player_tokens.html

@ -0,0 +1,62 @@
{% extends "base.html" %}
{% set active_page = "tokens" %}
{% block title %}Player Tokens{% endblock %}
{% block content %}
<div class="uk-flex uk-flex-center uk-margin-bottom uk-margin-top">
<h1 class="uk-text-center"><strong>Adventurer Conqueror King</strong>Player Tokens</h1>
</div>
<br/>
<div class="uk-container uk-container-small">
<h2 class="uk-text-center">Categories</h2>
<div class="uk-grid-medium uk-grid-match uk-flex-center" uk-grid>
{% for name,tokens in categories %}
<div class="acks-npc-card" data-name="{{ name }}">
<div class="uk-card uk-card-body uk-card-default uk-box-shadow-hover-large">
<h4 class="uk-card-title uk-margin-small-top">{{ name|capitalize }}</h4>
<div class="uk-card-badge uk-label uk-label-primary">{{ tokens|length }}</div>
<div class="uk-text-center uk-margin-bottom">
<div>
<img src="{{ (tokens|random)['src'] }}" class="category-thumbnail" />
</div>
<div>
<strong>Browse {{ name|capitalize }}</strong>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
{% block head %}
<style>
div.acks-npc-card > div > div > div > img.category-thumbnail {
width: 150px;
height: 150px;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js@1.4.0/dist/css/lightgallery.min.css" integrity="sha256-s47mXWRWvrLQNL9VRQX0ykfkIVSLfNJuingF/SZztsM=" crossorigin="anonymous">
{% endblock %}
{% block scripts %}
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js@1.4.0/dist/js/lightgallery.min.js" integrity="sha256-0Zhc9IDI5elFpwJZlvdAM4u/6qlxi4qIOUlHDVl5wjU=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/lg-thumbnail.js@1.2.0/dist/lg-thumbnail.min.js" integrity="sha256-h70L9O3prxviKHrPHwrId33HakkgnURiB1KBHDyZOJc=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/lg-fullscreen.js@1.2.0/dist/lg-fullscreen.min.js" integrity="sha256-5VFY2GRRpY51CgT/ku3jPvpWybxJ2n+pbDNz05amGwk=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/lg-zoom.js@1.3.0/dist/lg-zoom.min.js" integrity="sha256-pw9GIEB9jGoek+S5xfa2Uz/8dZVjZsIYVJxy3jK3qgI=" crossorigin="anonymous"></script>
<script type="text/javascript">
var categories = {{ data | tojson }};
for(let category of document.querySelectorAll('div.acks-npc-card')) {
category.addEventListener('click', function() {
lightGallery(category, {
dynamic: true,
dynamicEl: categories[category.dataset.name]
})
});
}
</script>
{% endblock %}

35
acks/views.py

@ -1,4 +1,4 @@
import os
from pathlib import Path
from flask import Blueprint, render_template, url_for, redirect
from flask_basicauth import BasicAuth
@ -31,11 +31,36 @@ def lair_gallery():
base_url = "https://www.atr0phy.net/acks/img/dynamic_lairs/"
animal_lairs = []
for filename in os.listdir(base_path + "animal/"):
animal_lairs.append(base_url + "animal/" + filename)
fs = Path(base_path + "animal/")
for filename in fs.iterdir():
animal_lairs.append(base_url + "animal/" + filename.name)
humanoid_lairs = []
for filename in os.listdir(base_path + "humanoid/"):
humanoid_lairs.append(base_url + "humanoid/" + filename)
fs = Path(base_path + "humanoid/")
for filename in fs.iterdir():
humanoid_lairs.append(base_url + "humanoid/" + filename.name)
return render_template('lair_gallery.html', animal=animal_lairs, humanoid=humanoid_lairs)
@default_views.route('/player_tokens')
def token_gallery():
base_path = "/srv/www/atr0phy.net/acks/img/player_tokens/"
base_url = "https://www.atr0phy.net/acks/img/player_tokens/"
def to_gallery_src(src):
return {"src": src, "thumb": src}
tokens = {}
parent_fs = Path(base_path)
for category in parent_fs.iterdir():
if not category.is_dir():
continue
category_fs = Path(base_path + category.name + "/")
tokens[category.name] = []
for token in category_fs.iterdir():
tokens[category.name].append(to_gallery_src(base_url + category.name + "/" + token.name))
categories = [(k, v) for k, v in tokens.items()]
categories = sorted(categories, key=lambda category: len(category[1]), reverse=True)
return render_template('player_tokens.html', categories=categories, data=tokens)
Loading…
Cancel
Save