Browse Source

Dynamic lairs page w/ slider and zoom

master
Brandon Cornejo 4 years ago
parent
commit
d07b9a0055
  1. 1
      acks/templates/base.html
  2. 80
      acks/templates/lair_gallery.html
  3. 42
      acks/views.py

1
acks/templates/base.html

@ -7,6 +7,7 @@
('/npc/spells', 'spells', 'Spells'),
('/quest/list', 'questlist', 'Quests'),
('/wiki', 'wiki', 'Wiki'),
('/lairs', lairs', 'Lairs'),
] %}
{% set generation_bar = [
('/npc/party', 'npcparty', 'NPC Party'),

80
acks/templates/lair_gallery.html

@ -0,0 +1,80 @@
{% extends "base.html" %}
{% set active_page = "lairs" %}
{% block title %}Maps{% 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>Dynamic Lairs</h1>
</div>
<br/>
<div class="uk-container uk-container-small">
<!-- Animal Lairs -->
<h2 class="uk-text-center"><strong>Animal Lairs</strong></h2>
<div uk-slider>
<div class="uk-position-relative">
<div class="uk-slider-container uk-light">
<ul id="animal-lairs" class="uk-slider-items uk-child-width-1-2 uk-child-width-1-3@s uk-child-width-1-4@m">
{% for i in animal %}
<li data-src="{{ i }}" class="gallery-img-li"><img src="{{ i }}"/></li>
{% endfor %}
</ul>
</div>
<a class="uk-position-center-left-out" href="#" uk-slidenav-previous uk-slider-item="previous"></a>
<a class="uk-position-center-right-out" href="#" uk-slidenav-next uk-slider-item="next"></a>
</div>
<ul class="uk-slider-nav uk-dotnav uk-flex-center uk-margin"></ul>
</div>
<!-- Humanoid Lairs -->
<h2 class="uk-text-center"><strong>Humanoid Lairs</strong></h2>
<div uk-slider>
<div class="uk-position-relative">
<div class="uk-slider-container uk-light">
<ul id="humanoid-lairs" class="uk-slider-items uk-child-width-1-2 uk-child-width-1-3@s uk-child-width-1-4@m">
{% for i in humanoid %}
<li data-src="{{ i }}" class="gallery-img-li"><img src="{{ i }}"/></li>
{% endfor %}
</ul>
</div>
<a class="uk-position-center-left uk-position-small uk-hidden-hover" href="#" uk-slidenav-previous uk-slider-item="previous"></a>
<a class="uk-position-center-right uk-position-small uk-hidden-hover" href="#" uk-slidenav-next uk-slider-item="next"></a>
</div>
<ul class="uk-slider-nav uk-dotnav uk-flex-center uk-margin"></ul>
</div>
</div>
<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">
lightGallery(document.getElementById('animal-lairs'));
lightGallery(document.getElementById('humanoid-lairs'));
</script>
{% endblock %}
{% block head %}
<style>
h1 strong {
display: block;
font-size: 50%;
opacity: 0.65;
}
li.gallery-img-li {
overflow: hidden;
border-radius: 4px;
border: 2px solid #fff;
height: 300px;
width: 300px;
}
li.gallery-img-li > img {
width: 100%;
height: 100%;
object-fit: cover;
}
</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 %}

42
acks/views.py

@ -1,3 +1,5 @@
import os
from flask import Blueprint, render_template, url_for, redirect
from flask_basicauth import BasicAuth
@ -23,29 +25,17 @@ def wiki():
def worldmap():
return render_template('worldmap.html')
#@default_views.route('/treasure')
#@default_views.route('/treasure/<string:treasure_type>')
def treasure(treasure_type=None):
# import requests
# from lxml import html
# Unused, we can't tap into Autarch's generator, so just link to a new tab
# in navigation bar now
if treasure_type is not None:
with requests.Session() as s:
# First grab the page to pull a fresh form_build_id
treasure_page = s.get('http://autarch.co/treasure')
dom_tree = html.fromstring(treasure_page.content)
form_build_id = dom_tree.find('.//input[@name="form_build_id"]').attrib['value']
# Use that form_build_id to make a request for generated treasure
headers = {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}
payload = {
"form_id": "acks_treasure_form",
"form_build_id": form_build_id,
"treasure_type": treasure_type
}
response = s.post("http://autarch.co/system/ajax", data=payload, headers=headers)
print("TG Response: {}, Payload: {}".format(response.text, payload))
generated_treasure = response.json()[1]["data"].replace('class="form-textarea"', 'class="uk-textarea"')
return render_template('treasure.html', generated_treasure=generated_treasure, treasure_type=treasure_type)
return render_template('treasure.html')
@default_views.route('/lairs')
def lair_gallery():
base_path = "/srv/www/atr0phy.net/acks/img/dynamic_lairs/"
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)
humanoid_lairs = []
for filename in os.listdir(base_path + "humanoid/"):
humanoid_lairs.append(base_url + "humanoid/" + filename)
return render_template('lair_gallery.html', animal=animal_lairs, humanoid=humanoid_lairs)
Loading…
Cancel
Save