make banners not retarded + increase future scalability

remotes/1693176582716663532/tmp_refs/heads/watchparty
gooseman 2022-11-14 17:28:43 -08:00 committed by TLSM
parent eba6625b81
commit 16e23e6f54
24 changed files with 42 additions and 43 deletions

View File

@ -6357,3 +6357,11 @@ div.markdown {
object-fit: contain;
-o-object-fit: contain;
}
img[alt*="banner"] {
width: 100%;
}
img[alt*="banner"][alt^="/h/"]{
object-fit: cover;
max-height: min(42vh,30vw) !important;
}

View File

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 246 KiB

View File

Before

Width:  |  Height:  |  Size: 218 KiB

After

Width:  |  Height:  |  Size: 218 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 194 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 186 KiB

View File

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 209 KiB

View File

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 216 KiB

View File

Before

Width:  |  Height:  |  Size: 203 KiB

After

Width:  |  Height:  |  Size: 203 KiB

View File

Before

Width:  |  Height:  |  Size: 296 KiB

After

Width:  |  Height:  |  Size: 296 KiB

View File

Before

Width:  |  Height:  |  Size: 242 KiB

After

Width:  |  Height:  |  Size: 242 KiB

View File

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 186 KiB

View File

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 194 KiB

View File

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

View File

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 171 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 179 KiB

View File

@ -1,6 +1,6 @@
import time
from os import environ, listdir
from os import environ, listdir, path
from jinja2 import pass_context
@ -44,7 +44,7 @@ def timestamp(timestamp):
def inject_constants():
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL,
"AUTOJANNY_ID":AUTOJANNY_ID, "PUSHER_ID":PUSHER_ID,
"CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "AEVANN_ID":AEVANN_ID,
"CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "os_path":path, "AEVANN_ID":AEVANN_ID,
"PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR,
"COLORS":COLORS, "time":time, "PERMS":PERMS, "FEATURES":FEATURES,
"HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED,

View File

@ -1,5 +1,6 @@
{%- import 'util/helpers.html' as help -%}
{%- import 'html_head.html' as html_head with context -%}
{%- import 'util/macros.html' as macros with context -%}
<!DOCTYPE html>
<html lang="en">
{% if request.path == '/' %}
@ -29,45 +30,16 @@
{% block Banner %}
{% include "modals/expanded_image.html" %}
{% if '@' not in request.path %}
{% if sub and SITE_NAME != 'WPD' %}
<a href="{{sub.banner_url}}">
<img alt="/h/{{sub}} banner" onclick="expandDesktopImage()" src="{{sub.banner_url}}" width=100% style="object-fit:cover;max-height:min(42vh,30vw)!important">
</a>
{% elif SITE_NAME == 'rDrama' %}
<a rel="nofollow noopener" href="https://secure.transequality.org/site/Donation2?df_id=1480">
{% if v and (v.is_banned or v.agendaposter) %}
<img alt="site banner" src="/i/{{SITE_NAME}}/banner2.webp?v=2000" width="100%">
{% else %}
{% set path = "assets/images/" + SITE_NAME + "/banners" %}
{% set image = "/" + path + "/" + listdir('files/' + path)|random() + '?v=25' %}
<img alt="site banner" src="{% if v %}{{image}}{% else %}{{'cached.webp' | asset_siteimg}}{% endif %}" width="100%">
{% endif %}
</a>
{% elif SITE_NAME == 'WPD' %}
{% if v %}
{% set path = "assets/images/" + SITE_NAME + "/banners" %}
{% set banner = "/" + path + "/" + listdir('files/' + path)|random() + '?v=1' %}
{% else %}
{% set banner = 'cached.webp' | asset_siteimg %}
{% endif %}
<a href="{{banner}}">
<img alt="site banner" onclick="expandDesktopImage()" src="{{banner}}" width="100%">
</a>
{% else %}
{% if SITE_NAME == 'PCM' %}
{# set path = "assets/images/" + SITE_NAME + "/banners" #}
{# set banner = "/" + path + "/" + listdir('files/' + path)|max + '?v=1' #}
{% set path = "assets/images/" + SITE_NAME + "/banner_rotation" %}
{% set banner = "/" + path + "/" + listdir('files/' + path)|random() + '?v=1' %}
{% else %}
{% set banner = 'banner.webp' | asset_siteimg %}
{% endif %}
{% if '@' not in request.path %}
<a href="{{banner}}">
<img alt="site banner" onclick="expandDesktopImage()" src="{{banner}}" width="100%">
</a>
{% if sub and SITE_NAME != WPD %}
{% set src = sub.banner_url %}
{% set alt = ['/h/', sub, 'banner']|join %}
{% elif SITE_NAME == "rDrama" %}
{% set href = "https://secure.transequality.org/site/Donation2?df_id=1480" %}
{% endif %}
{{ macros.banner(src, href, alt) }}
{% endif %}
{% endblock %}

View File

@ -1,8 +1,7 @@
<div class="col sidebar text-left {% if '/sidebar' not in request.path %}d-none d-lg-block{% endif %} pt-3" {% if request.path != '/sidebar' %}id="sidebar-content"{% endif %}>
{%- if v -%}
{%- set art_path = 'assets/images/WPD/sidebar' -%}
{%- set art_image = '/' + art_path + '/' + listdir('files/' + art_path)|random() + '?v=45' -%}
{%- set art_image = macros.random_image("sidebar") -%}
{%- else -%}
{%- set art_image = '/i/' + SITE_NAME + '/sidebar.webp?v=3000' -%}
{%- endif -%}

View File

@ -3,8 +3,7 @@
{% if sub %}
{% set image=sub.sidebar_url %}
{% else %}
{% set path = "assets/images/" + SITE_NAME + "/sidebar" %}
{% set image = "/" + path + "/" + listdir('files/' + path)|random() + '?v=45' %}
{% set image = macros.random_image("sidebar") %}
{% endif %}
{% if request.path != '/sidebar' %}

View File

@ -0,0 +1,21 @@
{% macro banner(src, href, alt) %}
<a href="{{href|default(src)}}">
<img onclick = "expandDesktopImage()" alt="{{alt|default('site banner')}}" src="{{src|default(live_banner())}}">
</a>
{% endmacro %}
{% macro live_banner() %}
{% set path = "files/assets/images/" + SITE_NAME %}
{% if not v and os_path.exists(path + "/cached.webp") %}
{{ 'cached.webp' | asset_siteimg }}
{% elif os_path.exists(path + "/banners") %}
{{ random_image("banners") }}
{% else %}
{{ 'banner.webp' | asset_siteimg }}
{% endif %}
{% endmacro %}
{% macro random_image(assetdir) %}
{% set path = "assets/images/" + SITE_NAME + "/" + assetdir %}
{{ "/" + path + "/" + listdir('files/' + path)|random() + '?v=45' }}
{% endmacro %}