diff --git a/files/classes/badges.py b/files/classes/badges.py index 673f61d1d..9f770a2c5 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -68,7 +68,7 @@ class Badge(Base): @property @lazy def path(self): - return f"/assets/images/badges/{self.badge_id}.webp" + return f"/i/badges/{self.badge_id}.webp" @property @lazy diff --git a/files/classes/sub.py b/files/classes/sub.py index a35c53afa..9fafda22e 100644 --- a/files/classes/sub.py +++ b/files/classes/sub.py @@ -31,13 +31,13 @@ class Sub(Base): @lazy def sidebar_url(self): if self.sidebarurl: return SITE_FULL + self.sidebarurl - return f'/assets/images/{SITE_NAME}/sidebar.webp?v=1041' + return f'/i/{SITE_NAME}/sidebar.webp?v=1041' @property @lazy def banner_url(self): if self.bannerurl: return SITE_FULL + self.bannerurl - return f'/assets/images/{SITE_NAME}/banner.webp?v=1048' + return f'/i/{SITE_NAME}/banner.webp?v=1048' @property @lazy diff --git a/files/classes/user.py b/files/classes/user.py index a6b123c06..46b9add0b 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -353,8 +353,9 @@ class User(Base): def bio_html_eager(self): if self.bio_html == None: return '' return self.bio_html.replace('data-src', 'src') \ - .replace('src="/assets/images/loading.webp?v=2"', '') \ - .replace('src="/assets/images/loading.webp"', '') + .replace('src="/i/loading.webp?v=2"', '') \ + .replace('src="/i/loading.webp"', '') \ + .replace('src="/i/l.webp"', '') @property @lazy @@ -581,7 +582,7 @@ class User(Base): @lazy def banner_url(self): if self.bannerurl: return self.bannerurl - else: return f"/assets/images/{SITE_NAME}/site_preview.webp?v=1016" + else: return f"/i/{SITE_NAME}/site_preview.webp?v=1016" @property @lazy diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index bb64653b1..8649e990b 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -148,10 +148,10 @@ def render_emoji(html, regexp, edit, marseys_used, b=False): if emoji.endswith('pat'): if path.isfile(f"files/assets/images/emojis/{emoji.replace('pat','')}.webp"): - emoji_html = f'{emoji_partial_pat.format(old, f"/e/{emoji[:-3]}.webp", attrs)}' + emoji_html = f'{emoji_partial_pat.format(old, f"/e/{emoji[:-3]}.webp", attrs)}' elif emoji.startswith('@'): if u := get_user(emoji[1:-3], graceful=True): - emoji_html = f'{emoji_partial_pat.format(old, f"/pp/{u.id}", attrs)}' + emoji_html = f'{emoji_partial_pat.format(old, f"/pp/{u.id}", attrs)}' elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'): emoji_html = emoji_partial.format(old, f'/e/{emoji}.webp', attrs) @@ -222,7 +222,7 @@ def sanitize(sanitized, alert=False, edit=False): if tag.get("src") and not tag["src"].startswith('/pp/'): tag["loading"] = "lazy" tag["data-src"] = tag["src"] - tag["src"] = "/assets/images/loading.webp?v=2" + tag["src"] = "/i/l.webp" tag['alt'] = f'![]({tag["data-src"]})' tag['referrerpolicy'] = "no-referrer" diff --git a/files/routes/static.py b/files/routes/static.py index f4d149d0b..707665d32 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -243,6 +243,20 @@ def emoji(emoji): resp.headers.add("Content-Type", "image/webp") return resp +@app.get('/i/') +@limiter.exempt +def image(image): + resp = make_response(send_from_directory('assets/images', image)) + if request.path.endswith('.webp') or request.path.endswith('.gif') or request.path.endswith('.ttf') or request.path.endswith('.woff2'): + resp.headers.remove("Cache-Control") + resp.headers.add("Cache-Control", "public, max-age=3153600") + + if request.path.endswith('.webp'): + resp.headers.remove("Content-Type") + resp.headers.add("Content-Type", "image/webp") + + return resp + @app.get('/assets/') @app.get('/static/assets/') @limiter.exempt diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 61fab8a53..6ab14e808 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -12,7 +12,7 @@ - + {% block pagetitle %}{{SITE_NAME}}{% endblock %} @@ -24,7 +24,7 @@ {% if v.agendaposter %} {% endif %} @@ -165,14 +165,14 @@
your profile picture {% if v.is_cakeday %} - + {% endif %}
{{v.username}}
-
coins{{v.coins}} Coin{{ help.plural(v.coins) }}
+
coins{{v.coins}} Coin{{ help.plural(v.coins) }}
{% if SITE_NAME not in ('Cringetopia', 'WPD') %} -
marseybux{{v.procoins}} Marseybux
+
marseybux{{v.procoins}} Marseybux
{% endif %}
@@ -307,10 +307,10 @@ {% if v and not v.animations -%} {%- endif %} - + diff --git a/files/templates/log.html b/files/templates/log.html index 3bf154c99..63a6f1040 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -11,7 +11,7 @@ {% if v.agendaposter %}
- Blade's toe + Blade's toe
{% if p.award_count("toe") > 1 %} @@ -257,7 +257,7 @@ }
- Blade's toe + Blade's toe
{% endif %} @@ -273,7 +273,7 @@ }
- Blade's toe + Blade's toe
{% endif %} @@ -289,7 +289,7 @@ }
- Blade's toe + Blade's toe
{% endif %} {% endif %} @@ -370,7 +370,7 @@
- Blade's toe + Blade's toe
@@ -378,7 +378,7 @@ {% if p.award_count("toe") > 1 %} - Blade's toe + Blade's toe {% endif %} @@ -386,7 +386,7 @@ {% if p.award_count("toe") > 2 %} - Blade's toe + Blade's toe {% endif %} @@ -394,7 +394,7 @@ {% if p.award_count("toe") > 3 %} - Blade's toe + Blade's toe {% endif %} @@ -497,24 +497,24 @@ - croag + croag {% if p.award_count("croag") > 1 %} - croag + croag {% endif %} {% if p.award_count("croag") > 2 %} - croag + croag {% endif %} {% if p.award_count("croag") > 3 %} - croag + croag {% endif %} {% endif %} @@ -741,7 +741,7 @@ 👻 {% else %} {% if SITE_NAME=='rDrama' and p.author.house %} - House {{p.author.house}} + House {{p.author.house}} {% endif %} {% if p.author.verified %} @@ -749,7 +749,7 @@ {% if p.author.is_cakeday %} - + {% endif %} {{p.author_name}} @@ -1186,13 +1186,13 @@ {% if p.award_count("shit") %} - + {% endif %} {% if p.award_count("fireflies") %} - + {% endif %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index bfe2d83fb..37cf29b62 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -188,7 +188,7 @@ 👻 {% else %} {% if SITE_NAME=='rDrama' and p.author.house %} - House {{p.author.house}} + House {{p.author.house}} {% endif %} {% if p.author.verified %} @@ -196,7 +196,7 @@ {% if p.author.is_cakeday %} - + {% endif %} {{p.author_name}} @@ -345,7 +345,7 @@ {% if p.is_image and not p.over_18 and ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %} {% elif p.is_video %} diff --git a/files/templates/submit.html b/files/templates/submit.html index 45b01f9b1..c9d681383 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -12,7 +12,7 @@ - + {% if request.host == 'pcmemes.net' %} {% set cc='Splash Mountain' %} @@ -33,7 +33,7 @@ {% if v.agendaposter %}