Improved templating engine wrapping.

This commit is contained in:
flash 2025-04-03 14:37:19 +00:00
parent e4c3e4c052
commit ceb6bece09
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
86 changed files with 784 additions and 515 deletions

View file

@ -12,7 +12,7 @@
<a href="https://patchii.net/flashii/misuzu/src/tag/{{ git_tag }}" target="_blank" rel="noopener" class="footer__link">{{ git_tag }}</a>
{% endif %}
# <a href="https://patchii.net/flashii/misuzu/commit/{{ git_commit_hash(true) }}" target="_blank" rel="noopener" class="footer__link">{{ git_commit_hash() }}</a>
{% if globals.display_timings_info %}
{% if auth_display_timings() %}
/ Index {{ ndx_version() }}
/ {{ sql_query_count()|number_format }} queries
/ {{ (startup_time() - startup_time(constant('MSZ_TPL_RENDER')))|number_format(5) }} load

View file

@ -1,14 +1,15 @@
{% from 'macros.twig' import avatar %}
{% from '_layout/input.twig' import input_checkbox_raw %}
{% if globals.auth_info.impersonating %}
{% set real_user_info = globals.auth_info.realUserInfo %}
{% if auth_impersonating() %}
{% set real_user_id = auth_get_real_user_info('id') %}
{% set real_user_name = auth_get_real_user_info('name') %}
<div class="impersonate">
<div class="impersonate-content">
<div class="impersonate-user">
You are <a href="{{ url('user-profile', {'user': real_user_info.id}) }}" class="impersonate-user-link">
<div class="avatar impersonate-user-avatar">{{ avatar(real_user_info.id, 20, real_user_info.name) }}</div>
{{ real_user_info.name }}
You are <a href="{{ url('user-profile', {'user': real_user_id}) }}" class="impersonate-user-link">
<div class="avatar impersonate-user-avatar">{{ avatar(real_user_id, 20, real_user_name) }}</div>
{{ real_user_name }}
</a>
</div>
<div class="impersonate-options">
@ -26,8 +27,8 @@
<div class="header__background"></div>
<div class="header__desktop">
<a class="header__desktop__logo" href="{{ url('index') }}" title="{{ globals.site_info.name }}">
{{ globals.site_info.name }}
<a class="header__desktop__logo" href="{{ url('index') }}" title="{{ site_get_info('name') }}">
{{ site_get_info('name') }}
</a>
<div class="header__desktop__menus">
@ -56,10 +57,11 @@
</a>
{% endfor %}
{% if globals.auth_info.loggedIn %}
{% set user_info = globals.auth_info.userInfo %}
<a href="{{ url('user-profile', {'user': user_info.id}) }}" class="avatar header__desktop__user__avatar" title="{{ user_info.name }}">
{{ avatar(user_info.id, 60, user_info.name) }}
{% if auth_logged_in() %}
{% set header_user_id = auth_get_user_info('id') %}
{% set header_user_name = auth_get_user_info('name') %}
<a href="{{ url('user-profile', {'user': header_user_id}) }}" class="avatar header__desktop__user__avatar" title="{{ header_user_name }}">
{{ avatar(header_user_id, 60, header_user_name) }}
</a>
{% else %}
<a href="{{ url('auth-login') }}" class="avatar header__desktop__user__avatar">
@ -76,13 +78,12 @@
</label>
<a class="header__mobile__logo header__mobile__icon" href="{{ url('index') }}">
{{ globals.site_info.name }}
{{ site_get_info('name') }}
</a>
<label class="header__mobile__icon header__mobile__avatar" for="toggle-mobile-header">
{% if globals.auth_info.loggedIn %}
{% set user_info = globals.auth_info.userInfo %}
{{ avatar(user_info.id, 40, user_info.name) }}
{% if auth_logged_in() %}
{{ avatar(auth_get_user_info('id'), 40, auth_get_user_info('name')) }}
{% else %}
{{ avatar(0, 40, 'Log in') }}
{% endif %}

View file

@ -1,27 +1,29 @@
{% apply spaceless %}
{% set description = description|default(globals.site_info.description) %}
{% set site_name = site_get_info('name') %}
{% set site_description = description|default(site_get_info('desc')) %}
{% set site_url = site_get_info('url') %}
{% if title is defined %}
{% set browser_title = title ~ ' :: ' ~ globals.site_info.name %}
{% set browser_title = title ~ ' :: ' ~ site_name %}
{% else %}
{% set browser_title = globals.site_info.name %}
{% set browser_title = site_name %}
{% endif %}
<title>{{ browser_title }}</title>
<meta property="og:title" content="{{ title|default(globals.site_info.name) }}">
<meta property="og:site_name" content="{{ globals.site_info.name }}">
<meta property="og:title" content="{{ title|default(site_name) }}">
<meta property="og:site_name" content="{{ site_name }}">
{% if description|length > 0 %}
<meta name="description" content="{{ description }}">
<meta property="og:description" content="{{ description }}">
{% if site_description|length > 0 %}
<meta name="description" content="{{ site_description }}">
<meta property="og:description" content="{{ site_description }}">
{% endif %}
<meta property="og:type" content="object">
{% if image is defined %}
{% if image|slice(0, 1) == '/' %}
{% set image = globals.site_info.url is not empty ? (globals.site_info.url ~ image) : '' %}
{% set image = site_url ~ image %}
{% endif %}
{% if image|length > 0 %}
@ -31,7 +33,7 @@
{% if canonical_url is defined %}
{% if canonical_url|slice(0, 1) == '/' %}
{% set canonical_url = globals.site_info.url is not empty ? (globals.site_info.url ~ canonical_url) : '' %}
{% set canonical_url = site_url ~ canonical_url %}
{% endif %}
{% if canonical_url|length > 0 %}

View file

@ -2,7 +2,7 @@
{% from 'macros.twig' import container_title %}
{% set error_string = '%03d %s'|format(error_code, error_text) %}
{% set html_title = error_string ~ ' :: ' ~ globals.site_info.name %}
{% set html_title = error_string ~ ' :: ' ~ site_get_info('name') %}
{% block html_head %}
<meta name="description" content="{{ error_blerb }}">
@ -20,15 +20,15 @@
<div class="error-wrapper">
<div class="error-container">
<nav class="error-top">
<div class="error-logo"><a href="{{ globals.site_info.url }}"><img src="/images/logos/imouto-default.png" alt=""></a></div>
<div class="error-home"><a href="{{ globals.site_info.url }}">{{ globals.site_info.name }}</a></div>
<div class="error-logo"><a href="{{ site_get_info('url') }}"><img src="/images/logos/imouto-default.png" alt=""></a></div>
<div class="error-home"><a href="{{ site_get_info('url') }}">{{ site_get_info('name') }}</a></div>
{% if error_code >= 500 %}
<div class="error-nav">
{% if globals.site_info.email is not empty %}
<a href="mailto:{{ globals.site_info.email }}" rel="noopener" target="_blank">E-mail</a>
{% if site_has_info('email') %}
<a href="mailto:{{ site_get_info('email') }}" rel="noopener" target="_blank">E-mail</a>
{% endif %}
{% if globals.site_info.bsky is not empty %}
<a href="{{ globals.site_info.bsky }}" rel="noopener" target="_blank">Bluesky</a>
{% if site_has_info('bsky') %}
<a href="{{ site_get_info('bsky') }}" rel="noopener" target="_blank">Bluesky</a>
{% endif %}
</div>
{% endif %}

View file

@ -44,7 +44,7 @@
<div class="landingv2-header-content">
<div class="landingv2-welcome">
<a href="{{ url('index') }}">
<img src="/images/landing-logo.png" alt="{{ globals.site_info.name }}">
<img src="/images/landing-logo.png" alt="{{ site_get_info('name') }}">
</a>
</div>
@ -89,7 +89,7 @@
{% endif %}
# <a href="https://github.com/flashwave/misuzu/commit/{{ git_commit_hash(true) }}" target="_blank" rel="noreferrer noopener">{{ git_commit_hash() }}</a>
</div>
{% if globals.display_timings_info %}
{% if auth_display_timings() %}
<div class="landingv2-footer-copyright-line">
{{ sql_query_count()|number_format }} queries / {{ (startup_time() - startup_time(constant('MSZ_TPL_RENDER')))|number_format(5) }} load / {{ startup_time(constant('MSZ_TPL_RENDER'))|number_format(5) }} template / {{ startup_time()|number_format(5) }} total
</div>

View file

@ -5,7 +5,7 @@
<link href="/vendor/fontawesome/css/all.min.css" rel="stylesheet">
<link href="{{ asset('common.css') }}" rel="stylesheet">
<link href="{{ asset('misuzu.css') }}" rel="stylesheet">
{% for name, value in globals.meta %}
{% for name, value in get_meta_vars() %}
{% if value is not empty %}<meta name="msz-{{ name }}" content="{{ value }}">{% endif %}
{% endfor %}
{% if main_css_vars is defined and main_css_vars is iterable and main_css_vars is not empty %}
@ -36,12 +36,13 @@
</div>
</noscript>
{% if globals.active_ban_info is not null %}
{% set active_ban_info = auth_get_ban_info() %}
{% if active_ban_info is not null %}
<div class="warning warning--red">
<div class="warning__content">
<p>You have been banned {% if globals.active_ban_info.permanent %}<strong>permanently</strong>{% else %}for <strong title="{{ globals.active_ban_info.expiresTime|date('r') }}">{{ globals.active_ban_info.remainingString }}</strong>{% endif %} since <strong><time datetime="{{ globals.active_ban_info.createdTime|date('c') }}" title="{{ globals.active_ban_info.createdTime|date('r') }}">{{ globals.active_ban_info.createdTime|time_format }}</time></strong>.</p>
{% if globals.active_ban_info.publicReason is not empty %}
<p>Reason: {{ globals.active_ban_info.publicReason }}</p>
<p>You have been banned {% if active_ban_info.permanent %}<strong>permanently</strong>{% else %}for <strong title="{{ active_ban_info.expiresTime|date('r') }}">{{ active_ban_info.remainingString }}</strong>{% endif %} since <strong><time datetime="{{ active_ban_info.createdTime|date('c') }}" title="{{ active_ban_info.createdTime|date('r') }}">{{ active_ban_info.createdTime|time_format }}</time></strong>.</p>
{% if active_ban_info.publicReason is not empty %}
<p>Reason: {{ active_ban_info.publicReason }}</p>
{% endif %}
</div>
</div>

View file

@ -1,6 +1,6 @@
{% extends 'html.twig' %}
{% set html_title = (title is defined ? (title ~ ' :: ') : '') ~ globals.site_info.name %}
{% set html_title = (title is defined ? (title ~ ' :: ') : '') ~ site_get_info('name') %}
{% block html_head %}
<link href="{{ asset('common.css') }}" rel="stylesheet">
@ -27,7 +27,7 @@
<div class="oauth2-body">
<div class="oauth2-banner">
<div class="oauth2-banner-text">{{ body_title|default('') }}</div>
<div class="oauth2-banner-logo">{{ globals.site_info.name }}</div>
<div class="oauth2-banner-logo">{{ site_get_info('name') }}</div>
</div>
{% block body_content %}{% endblock %}

View file

@ -1,6 +1,6 @@
{% extends 'redirects/master.twig' %}
{% set html_title = globals.site_info.name ~ ' Redirect Service' %}
{% set html_title = site_get_info('name') ~ ' Redirect Service' %}
{% block content %}
<div class="redir-landing">
@ -8,7 +8,7 @@
<article class="redir-landing-body">
<p><div class="redir-landing-logo"></div></p>
<h1>{{ html_title }}</h1>
<p>Short URL Service for <a href="{{ globals.site_info.url }}" rel="noopener">{{ globals.site_info.name }}</a></p>
<p>Short URL Service for <a href="{{ site_get_info('url') }}/" rel="noopener">{{ site_get_info('name') }}</a></p>
</article>
<footer class="redir-landing-footer">
<p>