add expanded art

master
Aevann 2024-03-09 11:35:59 +02:00
parent 797a201e13
commit 9aee5edaf3
4 changed files with 23 additions and 6 deletions

View File

@ -3,6 +3,9 @@ from os import path
from files.classes import Emoji, Hole
from files.helpers.config.const import *
if FEATURES['ART_SUBMISSIONS']:
from files.classes.art_submissions import ArtSubmission
SNAPPY_KONGS = []
MARSEYS_CONST = []
MARSEYS_CONST2 = []
@ -14,9 +17,10 @@ SNAPPY_QUOTES_HOMOWEEN = []
GIGABOOSTED_HOLES = []
NSFW_EMOJIS = []
ALPHABET_MARSEYS = []
MIN_ART_ID_FOR_HQ = 999999999
def const_initialize():
global MARSEYS_CONST, MARSEYS_CONST2, MARSEY_MAPPINGS, SNAPPY_KONGS, SNAPPY_MARSEYS, SNAPPY_QUOTES, SNAPPY_QUOTES_FISTMAS, SNAPPY_QUOTES_HOMOWEEN, GIGABOOSTED_HOLES, NSFW_EMOJIS, ALPHABET_MARSEYS
global MARSEYS_CONST, MARSEYS_CONST2, MARSEY_MAPPINGS, SNAPPY_KONGS, SNAPPY_MARSEYS, SNAPPY_QUOTES, SNAPPY_QUOTES_FISTMAS, SNAPPY_QUOTES_HOMOWEEN, GIGABOOSTED_HOLES, NSFW_EMOJIS, ALPHABET_MARSEYS, MIN_ART_ID_FOR_HQ
db = db_session()
@ -39,6 +43,10 @@ def const_initialize():
NSFW_EMOJIS = [x[0] for x in db.query(Emoji.name).filter_by(nsfw=True)]
if FEATURES['ART_SUBMISSIONS']:
MIN_ART = db.query(ArtSubmission.id).order_by(ArtSubmission.id).first()
if MIN_ART: MIN_ART_ID_FOR_HQ = MIN_ART[0]
db.commit()
db.close()

View File

@ -16,7 +16,7 @@ from files.classes.emoji import Emoji
from files.classes.group import Group
from files.helpers.assetcache import assetcache_path
from files.helpers.config.const import *
from files.helpers.const_stateful import NSFW_EMOJIS
from files.helpers.const_stateful import *
from files.helpers.regex import *
from files.helpers.settings import *
from files.helpers.cloudflare import *
@ -95,6 +95,11 @@ def seeded_random(choices, p):
random.seed(p.id)
return random.choice(choices)
@app.template_filter("expand_art")
def expand_art(url):
id = int(url.split('?')[0].split('/')[-1].replace('.webp', ''))
if id < MIN_ART_ID_FOR_HQ: return url
return f"{SITE_FULL_IMAGES}/asset_submissions/art/original/{id}.webp"
def current_registered_users():
return "{:,}".format(g.db.query(User).count())

View File

@ -26,6 +26,7 @@
{% set image = macros.random_image("assets/events/" ~ IS_EVENT() ~ "/images/sidebar") %}
{% else %}
{% set image = macros.random_image("assets/images/" ~ SITE_NAME ~ "/sidebar") %}
{% set expanded_image = image|expand_art %}
{% endif %}
{% if request.path != '/sidebar' %}
@ -36,8 +37,11 @@
<img class="mb-4 sidebar-img" alt="sidebar image" data-nonce="{{g.nonce}}" data-onclick="expandImage()" loading="lazy" src="{{SITE_FULL_IMAGES}}/i/{{SITE_NAME}}/sidebar2.webp">
</a>
{% elif not (hole and hole.name == 'chudrama' and v and not v.can_see_chudrama) %}
<a href="{{image}}">
<img class="mb-4 sidebar-img" alt="sidebar image" data-nonce="{{g.nonce}}" data-onclick="expandImage()" loading="lazy" src="{{image}}">
{% if not expanded_image %}
{% set expanded_image = image %}
{% endif %}
<a href="{{expanded_image}}">
<img class="mb-4 sidebar-img" alt="sidebar image" data-nonce="{{g.nonce}}" data-onclick="expandImage('{{expanded_image}}')" loading="lazy" src="{{image}}">
</a>
{% endif %}
{% endif %}

View File

@ -4,8 +4,8 @@
<div class="text-center">
<h2 class="mt-4">{{title}}</h2>
{% for url in urls %}
<a href="{{url}}">
<img class="mt-4 mr-3" style="max-width:80vw" src="{{url}}" loading="lazy" data-nonce="{{g.nonce}}" data-onclick="expandImage()">
<a href="{{url|expand_art}}">
<img class="mt-4 mr-3" style="max-width:80vw" src="{{url}}" loading="lazy" data-nonce="{{g.nonce}}" data-onclick="expandImage('{{url|expand_art}}')">
</a>
{% endfor %}
</div>