From 9aee5edaf3db49210c651941524cea919a7fad91 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 9 Mar 2024 11:35:59 +0200 Subject: [PATCH] add expanded art --- files/helpers/const_stateful.py | 10 +++++++++- files/routes/jinja2.py | 7 ++++++- files/templates/sidebar_rDrama.html | 8 ++++++-- files/templates/view_art.html | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/files/helpers/const_stateful.py b/files/helpers/const_stateful.py index d9771017d..76ae89ead 100644 --- a/files/helpers/const_stateful.py +++ b/files/helpers/const_stateful.py @@ -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() diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index f084830dc..61dec3172 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -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()) diff --git a/files/templates/sidebar_rDrama.html b/files/templates/sidebar_rDrama.html index 9223a951f..9ec3c8806 100644 --- a/files/templates/sidebar_rDrama.html +++ b/files/templates/sidebar_rDrama.html @@ -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 @@ sidebar image {% elif not (hole and hole.name == 'chudrama' and v and not v.can_see_chudrama) %} - - sidebar image + {% if not expanded_image %} + {% set expanded_image = image %} + {% endif %} + + sidebar image {% endif %} {% endif %} diff --git a/files/templates/view_art.html b/files/templates/view_art.html index 016e7689c..d1316cec3 100644 --- a/files/templates/view_art.html +++ b/files/templates/view_art.html @@ -4,8 +4,8 @@

{{title}}

{% for url in urls %} - - + + {% endfor %}