Browse Source

player-auth for licenced assets - lightgallery replace ui-lightbox on maps page

master
Brandon Cornejo 1 year ago
parent
commit
b00520b532
  1. 3
      acks/__init__.py
  2. 20
      acks/templates/worldmap.html
  3. 10
      acks/views.py

3
acks/__init__.py

@ -14,8 +14,9 @@ def create_app():
db.init_app(app)
# Prep basic auth
from acks.views import basic_auth
from acks.views import basic_auth, player_auth
basic_auth.init_app(app)
player_auth.init_app(app)
# Load our views
from acks.views import default_views

20
acks/templates/worldmap.html

@ -13,10 +13,10 @@
<li><a href="#">Continent Overview</a></li>
<li><a href="#">Continent Full</a></li>
</ul>
<ul class="uk-switcher uk-margin" uk-lightbox>
<li><a href="{{ url_for('static', filename='WorldMap.png') }}"><img src="{{ url_for('static', filename='WorldMap.png') }}"/></a></li>
<li><div>1 hex = 96 miles</div><a href="{{ url_for('static', filename='PalismaWorld.png') }}"><img src="{{ url_for('static', filename='PalismaWorld.png') }}"/></a></li>
<li><div>1 hex = 24 miles</div><a href="{{ url_for('static', filename='PalismaContinent.png') }}"><img src="{{ url_for('static', filename='PalismaContinent.png') }}"/></a></li>
<ul class="uk-switcher uk-margin" id="map-gallery">
<li data-src="{{ url_for('static', filename='WorldMap.png') }}"><img src="{{ url_for('static', filename='WorldMap.png') }}"/></li>
<li data-src="{{ url_for('static', filename='PalismaWorld.png') }}"><img src="{{ url_for('static', filename='PalismaWorld.png') }}"/></li>
<li data-src="{{ url_for('static', filename='PalismaContinent.png') }}"><img src="{{ url_for('static', filename='PalismaContinent.png') }}"/></li>
</ul>
</div>
{% endblock %}
@ -29,4 +29,16 @@ h1 strong {
opacity: 0.65;
}
</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">
lightGallery(document.getElementById('map-gallery'));
</script>
{% endblock %}

10
acks/views.py

@ -5,7 +5,16 @@ from flask_basicauth import BasicAuth
class PlayerAuth(BasicAuth):
def init_app(self, app):
super().init_app(app)
self.player_password = app.config['PLAYER_BASIC_AUTH_PASSWORD']
def check_credentials(self, username, password):
return (password == self.player_password)
basic_auth = BasicAuth()
player_auth = PlayerAuth()
default_views = Blueprint('default_views', __name__, url_prefix='/')
@default_views.route('/')
@ -43,6 +52,7 @@ def lair_gallery():
return render_template('lair_gallery.html', animal=animal_lairs, humanoid=humanoid_lairs)
@default_views.route('/player_tokens')
@player_auth.required
def token_gallery():
base_path = "/srv/www/atr0phy.net/acks/img/player_tokens/"
base_url = "https://www.atr0phy.net/acks/img/player_tokens/"

Loading…
Cancel
Save