Minor template clean-up.

This commit is contained in:
flash 2020-06-01 19:38:02 +00:00
parent a165f9cffd
commit 3521d06cef
8 changed files with 13 additions and 95 deletions

View file

@ -208,7 +208,7 @@ if($authToken->isValid()) {
} else {
$userDisplayInfo = DB::prepare('
SELECT
u.`user_id`, u.`username`, u.`user_background_settings`, u.`user_deleted`,
u.`user_id`, u.`username`,
COALESCE(u.`user_colour`, r.`role_colour`) AS `user_colour`
FROM `msz_users` AS u
LEFT JOIN `msz_roles` AS r

View file

@ -12,8 +12,6 @@ final class TwigMisuzu extends Twig_Extension {
new Twig_Filter('html_colour', 'html_colour'),
new Twig_Filter('country_name', 'get_country_name'),
new Twig_Filter('byte_symbol', 'byte_symbol'),
new Twig_Filter('html_link', 'html_link'),
// deprecate this call, convert to html in php
new Twig_Filter('parse_text', fn(string $text, int $parser): string => Parser::instance($parser)->parseText($text)),
new Twig_Filter('perms_check', 'perms_check'),
new Twig_Filter('bg_settings', 'user_background_settings_strings'),

View file

@ -5,16 +5,16 @@
{% set git_tag = git_tag() %}
{% set git_branch = git_branch() %}
<div class="footer__copyright">
{{ 'https://flash.moe'|html_link('Flashwave', 'footer__link') }} 2013-{{
''|date('Y') }} /
<a href="https://flash.moe" target="_blank" rel="noreferrer noopener" class="footer__link">Flashwave</a>
2013-{{ ''|date('Y') }} /
{% set git_branch = git_branch() %}
{% if git_branch != 'HEAD' %}
{{ ('https://github.com/flashwave/misuzu/tree/' ~ git_branch)|html_link(git_branch, 'footer__link') }}
<a href="https://github.com/flashwave/misuzu/tree/{{ git_branch }}" target="_blank" rel="noreferrer noopener" class="footer__link">{{ git_branch }}</a>
{% else %}
{% set git_tag = git_tag() %}
{{ ('https://github.com/flashwave/misuzu/tree/' ~ git_tag)|html_link(git_tag, 'footer__link') }}
<a href="https://github.com/flashwave/misuzu/tree/{{ git_tag }}" target="_blank" rel="noreferrer noopener" class="footer__link">{{ git_tag }}</a>
{% endif %}
# {{ ('https://github.com/flashwave/misuzu/commit/' ~ git_commit_hash(true))|html_link(git_commit_hash(), 'footer__link') }}
# <a href="https://github.com/flashwave/misuzu/commit/{{ git_commit_hash(true) }}" target="_blank" rel="noreferrer noopener" class="footer__link">{{ git_commit_hash() }}</a>
{% if constant('MSZ_DEBUG') or current_user.user_id|default(0) == 1 %}
/ SQL Queries: {{ sql_query_count()|number_format }}
/ Took: {{ startup_time()|number_format(5) }} seconds

View file

@ -111,7 +111,7 @@
{% for item in site_menu %}
{% if item.display is not defined or item.display %}
<div class="header__desktop__menu">
{{ item.url|html_link(item.title, {'class': 'header__desktop__link header__desktop__menu__link'})|raw }}
<a href="{{ item.url }}" class="header__desktop__link header__desktop__menu__link">{{ item.title }}</a>
{% if item.menu is defined and item.menu is iterable %}
<div class="header__desktop__submenu">
@ -119,7 +119,7 @@
<div class="header__desktop__submenu__content">
{% for subitem in item.menu %}
{% if subitem.display is not defined or subitem.display %}
{{ subitem.url|html_link(subitem.title, {'class': 'header__desktop__link header__desktop__submenu__link'})|raw }}
<a href="{{ subitem.url }}" class="header__desktop__link header__desktop__submenu__link">{{ subitem.title }}</a>
{% endif %}
{% endfor %}
</div>
@ -183,12 +183,12 @@
<div class="header__mobile__navigation">
{% for item in site_menu %}
{% if item.display is not defined or item.display %}
{{ item.url|html_link(item.title, {'class': 'header__mobile__link header__mobile__link--primary'})|raw }}
<a href="{{ item.url }}" class="header__mobile__link header__mobile__link--primary">{{ item.title }}</a>
{% if item.menu is defined and item.menu is iterable %}
{% for subitem in item.menu %}
{% if subitem.display is not defined or subitem.display %}
{{ subitem.url|html_link(subitem.title, {'class': 'header__mobile__link'})|raw }}
<a href="{{ subitem.url }}" class="header__mobile__link">{{ subitem.title }}</a>
{% endif %}
{% endfor %}
{% endif %}

View file

@ -1,56 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>{{ title|default(globals.site_name) }}</title>
<link href="/vendor/fontawesome/css/all.min.css" type="text/css" rel="stylesheet"/>
<link href="/assets/misuzu.css" type="text/css" rel="stylesheet"/>
</head>
<body class="main">
<nav class="header">
<div class="header__background"></div>
<div class="header__desktop">
<a class="header__desktop__logo" href="{{ url('index') }}" title="{{ globals.site_name }}">
{{ globals.site_name }}
</a>
</div>
<div class="header__mobile">
<div class="header__mobile__icons">
<a class="header__mobile__logo header__mobile__icon" href="{{ url('index') }}">
{{ globals.site_name }}
</a>
</div>
</div>
</nav>
<div class="main__wrapper">
{% block content %}
This page has no content!
{% endblock %}
</div>
<footer class="footer">
<div class="footer__background"></div>
<div class="footer__wrapper">
{% autoescape false %}
<div class="footer__copyright">
{{ 'https://flash.moe'|html_link('Flashwave', 'footer__link') }} 2013-{{
''|date('Y') }} /
{% set git_branch = git_branch() %}
{% if git_branch != 'HEAD' %}
{{ ('https://github.com/flashwave/misuzu/tree/' ~ git_branch)|html_link(git_branch, 'footer__link') }}
{% else %}
{% set git_tag = git_tag() %}
{{ ('https://github.com/flashwave/misuzu/tree/' ~ git_tag)|html_link(git_tag, 'footer__link') }}
{% endif %}
# {{ ('https://github.com/flashwave/misuzu/commit/' ~ git_commit_hash(true))|html_link(git_commit_hash(), 'footer__link') }}
</div>
{% endautoescape %}
</div>
</footer>
</body>
</html>

View file

@ -42,9 +42,9 @@
{% endif %}
<div class="profile__header__country">
<div class="flag flag--{{ profile_user.user_country|lower }}"></div>
<div class="flag flag--{{ profile_user.country|lower }}"></div>
<div class="profile__header__country__name">
{{ profile_user.user_country|country_name }}{% if profile_user.user_age > 0 %}, {{ profile_user.user_age }} year{{ profile_user.user_age != 's' ? 's' : '' }} old{% endif %}
{{ profile_user.countryName }}{% if profile_user.user_age > 0 %}, {{ profile_user.user_age }} year{{ profile_user.user_age != 's' ? 's' : '' }} old{% endif %}
</div>
</div>
{% else %}

View file

@ -127,7 +127,7 @@
{% if field.format_link is empty %}
{{ profile_field_value }}
{% else %}
{{ field.format_link|format(field.field_value)|html_link(profile_field_value, 'profile__accounts__link')|raw }}
<a href="{{ field.format_link|format(field.field_value) }}" class="profile__accounts__link" target="_blank" rel="noreferrer noopener">{{ profile_field_value }}</a>
{% endif %}
</div>
{% endif %}

View file

@ -183,30 +183,6 @@ function render_info_or_json(bool $json, string $message, int $httpCode = 200, s
return render_info($message, $httpCode, $template);
}
function html_link(string $url, ?string $content = null, $attributes = []): string {
$content = $content ?? $url;
$attributes = array_merge(
is_string($attributes) ? ['class' => $attributes] : $attributes,
['href' => $url]
);
if(mb_strpos($url, '://') !== false) {
$attributes['target'] = '_blank';
$attributes['rel'] = 'noreferrer noopener';
}
$html = '<a';
foreach($attributes as $name => $value) {
$value = str_replace('"', '\"', $value);
$html .= " {$name}=\"{$value}\"";
}
$html .= ">{$content}</a>";
return $html;
}
function html_colour(?int $colour, $attribs = '--user-colour'): string {
$colour = $colour == null ? \Misuzu\Colour::none() : new \Misuzu\Colour($colour);