update twig to 2.9

This commit is contained in:
fowr
2023-03-29 18:59:28 -03:00
parent 08c9929eb0
commit d2bb450b1a
44 changed files with 710 additions and 606 deletions

View File

@@ -2,15 +2,17 @@
<p>
Any changes you make here will simply be appended to <code>{{ file }}</code>. If you wish to make the most of Tinyboard's customizability, you can instead edit the file directly. This page is intended for making quick changes and for those who don't have a basic understanding of PHP code.
</p>
{% if boards|count %}
{% if boards|length %}
<ul>
{% if board %}
<li><a href="?/config">Edit site-wide config</a></li>
{% endif %}
{% for _board in boards if _board.uri != board %}
<li>
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
</li>
{% for _board in boards %}
{% if _board.uri != board %}
<li>
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}

View File

@@ -6,10 +6,12 @@
{% if board %}
<li><a href="?/config">Edit site-wide config</a></li>
{% endif %}
{% for _board in boards if _board.uri != board %}
<li>
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
</li>
{% for _board in boards %}
{% if _board.uri != board %}
<li>
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
@@ -22,54 +24,56 @@
<th class="minimal">{% trans 'Type' %}</th>
<th>{% trans 'Description' %}</th>
</tr>
{% for var in conf if var.type != 'array' %}
{% if var.name|length == 1 %}
{% set name = 'cf_' ~ var.name %}
{% else %}
{% set name = 'cf_' ~ var.name|join('/') %}
{% endif %}
<tr>
<th class="minimal">
{% if var.name|length == 1 %}
{{ var.name }}
{% else %}
{{ var.name|join(' &rarr; ') }}
{% endif %}
</th>
{% for var in conf %}
{% if var.type != 'array' %}
{% if var.name|length == 1 %}
{% set name = 'cf_' ~ var.name %}
{% else %}
{% set name = 'cf_' ~ var.name|join('/') %}
{% endif %}
<td>
{% if var.type == 'string' %}
<input name="{{ name }}" type="text" value="{{ var.value|e }}">
{% elseif var.permissions %}
<select name="{{ name }}">
{% for group_value, group_name in config.mod.groups %}
<option value="{{ group_value }}"{% if var.value == group_value %} selected{% endif %}>
{{ group_name }}
</option>
{% endfor %}
</select>
{% elseif var.type == 'integer' %}
<input name="{{ name }}" type="number" value="{{ var.value|e }}">
{% elseif var.type == 'boolean' %}
<input name="{{ name }}" type="checkbox" {% if var.value %}checked{% endif %}>
{% else %}
?
{% endif %}
<tr>
<th class="minimal">
{% if var.name|length == 1 %}
{{ var.name }}
{% else %}
{{ var.name|join(' &rarr; ') }}
{% endif %}
</th>
{% if var.type == 'integer' or var.type == 'boolean' %}
<small>Default: <code>{{ var.default }}</code></small>
{% endif %}
</td>
<td class="minimal">
{{ var.type|e }}
</td>
<td style="word-wrap:break-word;width:50%">
{{ var.comment|join(' ') }}
</td>
</tr>
<td>
{% if var.type == 'string' %}
<input name="{{ name }}" type="text" value="{{ var.value|e }}">
{% elseif var.permissions %}
<select name="{{ name }}">
{% for group_value, group_name in config.mod.groups %}
<option value="{{ group_value }}"{% if var.value == group_value %} selected{% endif %}>
{{ group_name }}
</option>
{% endfor %}
</select>
{% elseif var.type == 'integer' %}
<input name="{{ name }}" type="number" value="{{ var.value|e }}">
{% elseif var.type == 'boolean' %}
<input name="{{ name }}" type="checkbox" {% if var.value %}checked{% endif %}>
{% else %}
?
{% endif %}
{% if var.type == 'integer' or var.type == 'boolean' %}
<small>Default: <code>{{ var.default }}</code></small>
{% endif %}
</td>
<td class="minimal">
{{ var.type|e }}
</td>
<td style="word-wrap:break-word;width:50%">
{{ var.comment|join(' ') }}
</td>
</tr>
{% endif %}
{% endfor %}
</table>

View File

@@ -36,7 +36,7 @@
<legend>{% trans 'Messages' %}</legend>
<ul>
{% if mod|hasPermission(config.mod.noticeboard) %}
{% if noticeboard|count > 0 %}
{% if noticeboard|length > 0 %}
<li>
{% trans 'Noticeboard' %}:
<ul>
@@ -132,7 +132,7 @@
</fieldset>
{% endif %}
{% if config.mod.dashboard_links and config.mod.dashboard_links|count %}
{% if config.mod.dashboard_links and config.mod.dashboard_links|length %}
<fieldset>
<legend>{% trans 'Other' %}</legend>

View File

@@ -6,13 +6,15 @@
<th class="minimal">Expires</th>
<th class="minimal">Size</th>
</tr>
{% for var in cached_vars if (var.ctime is defined ? var.ctime : var.creation_time) + var.ttl > time() %}
<tr>
<td class="minimal">{{ var.key is defined ? var.key : var.info }}</td>
<td class="minimal">{{ var.nhits is defined ? var.nhits : var.num_hits }}</td>
<td class="minimal">{{ (var.ctime is defined ? var.ctime : var.creation_time)|ago }} ago</td>
<td class="minimal">{{ ((var.ctime is defined ? var.ctime : var.creation_time) + var.ttl)|until }} (ttl: {{ (time() + var.ttl)|until }})</td>
<td class="minimal">{{ var.mem_size }} bytes</td>
</tr>
{% for var in cached_vars %}
{% if (var.ctime is defined ? var.ctime : var.creation_time) + var.ttl > time() %}
<tr>
<td class="minimal">{{ var.key is defined ? var.key : var.info }}</td>
<td class="minimal">{{ var.nhits is defined ? var.nhits : var.num_hits }}</td>
<td class="minimal">{{ (var.ctime is defined ? var.ctime : var.creation_time)|ago }} ago</td>
<td class="minimal">{{ ((var.ctime is defined ? var.ctime : var.creation_time) + var.ttl)|until }} (ttl: {{ (time() + var.ttl)|until }})</td>
<td class="minimal">{{ var.mem_size }} bytes</td>
</tr>
{% endif %}
{% endfor %}
</table>

View File

@@ -33,7 +33,7 @@
</table>
<p style="text-align:center">
Most recent {{ posts|count }} posts:
Most recent {{ posts|length }} posts:
</p>
<table class="modlog" style="word-wrap: break-word;">
<tr>

View File

@@ -1,4 +1,4 @@
{% if messages|count == 0 %}
{% if messages|length == 0 %}
<p style="text-align:center" class="unimportant">({% trans 'No private messages for you.' %})</p>
{% else %}
<table class="modlog">

View File

@@ -49,7 +49,7 @@
{% endfor %}
</table>
{% if count > logs|count %}
{% if count > logs|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.modlog_page) %}
{% if public %}

View File

@@ -22,13 +22,15 @@
<th>{% trans 'Target board' %}</th>
<td>
<ul style="list-style:none;padding:0">
{% for targetboard in boards if targetboard.uri != board %}
<li>
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|count == 2 %}checked{% endif %}>
<label style="display:inline" for="ban-board-{{ targetboard.uri }}">
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
</label>
</li>
{% for targetboard in boards %}
{% if targetboard.uri != board %}
<li>
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|length == 2 %}checked{% endif %}>
<label style="display:inline" for="ban-board-{{ targetboard.uri }}">
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
</label>
</li>
{% endif %}
{% endfor %}
</ul>
</td>

View File

@@ -15,7 +15,7 @@
<ul style="list-style:none;padding:0">
{% for targetboard in boards %}
<li>
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|count == 2 %}checked{% endif %}>
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|length == 2 %}checked{% endif %}>
<label style="display:inline" for="ban-board-{{ targetboard.uri }}">
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
</label>

View File

@@ -62,7 +62,7 @@
</div>
{% endfor %}
{% if count > news|count %}
{% if count > news|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.news_page) %}
<a href="?/news/{{ i + 1 }}">[{{ i + 1 }}]</a>

View File

@@ -57,7 +57,7 @@
</div>
{% endfor %}
{% if count > noticeboard|count %}
{% if count > noticeboard|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.noticeboard_page) %}
<a href="?/noticeboard/{{ i + 1 }}">[{{ i + 1 }}]</a>

View File

@@ -1,5 +1,5 @@
<script src="{{ config.additional_javascript_url }}js/mod/recent-posts.js"></script>
{% if not posts|count %}
{% if not posts|length %}
<p style="text-align:center" class="unimportant">({% trans 'There are no active posts.' %})</p>
{% else %}
<h4>Viewing last {{ limit|e }} posts</h4>

View File

@@ -259,7 +259,7 @@
</table>
{% endif %}
{% if result_count > results|count %}
{% if result_count > results|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (result_count - 1) / config.mod.search_page) %}
<a href="?/search/{{ search_type }}/{{ search_query_escaped }}/{{ i + 1 }}">[{{ i + 1 }}]</a>

View File

@@ -1,4 +1,4 @@
{% if themes|count == 0 %}
{% if themes|length == 0 %}
<p style="text-align:center" class="unimportant">({% trans 'There are no themes available.' %})</p>
{% else %}
<table class="modlog">

View File

@@ -32,11 +32,13 @@
<th>{% trans 'Group' %}</th>
<td>
<ul style="padding:5px 8px;list-style:none">
{% for group_value, group_name in config.mod.groups if group_name != 'Disabled' %}
<li>
<input type="radio" name="type" id="group_{{ group_name }}" value="{{ group_value }}">
<label for="group_{{ group_name }}">{% trans group_name %}</label>
</li>
{% for group_value, group_name in config.mod.groups %}
{% if group_name != 'Disabled' %}
<li>
<input type="radio" name="type" id="group_{{ group_name }}" value="{{ group_value }}">
<label for="group_{{ group_name }}">{% trans group_name %}</label>
</li>
{% endif %}
{% endfor %}
</ul>
</td>
@@ -87,7 +89,7 @@
</ul>
</form>
{% if logs and logs|count > 0 %}
{% if logs and logs|length > 0 %}
<table class="modlog" style="width:600px">
<tr>
<th>{% trans 'IP address' %}</th>

View File

@@ -14,11 +14,11 @@
{% if mod|hasPermission(config.mod.view_notes) %}
<fieldset id="notes">
<legend>
{% set notes_on_record = 'note' ~ (notes|count != 1 ? 's' : '') ~ ' on record' %}
<legend>{{ notes|count }} {% trans notes_on_record %}</legend>
{% set notes_length = notes|length %}
<legend>{{ notes_length }} {% trans %}note on record{% plural notes_length %}notes on record{% endtrans %}</legend>
</legend>
{% if notes|count > 0 %}
{% if notes|length > 0 %}
<table class="modlog">
<tr>
<th>{% trans 'Staff' %}</th>
@@ -84,11 +84,11 @@
{% if mod|hasPermission(config.mod.view_telegrams) %}
<fieldset id="telegrams">
<legend>
{% set telegrams_on_record = 'telegram' ~ (telegrams|count != 1 ? 's' : '') ~ ' on record' %}
<legend>{{ telegrams|count }} {% trans telegrams_on_record %}</legend>
{% set telegrams_length = telegrams|length %}
<legend>{{ telegrams_length }} {% trans %}telegram on record{% plural notes_length %}telegrams on record{% endtrans %}</legend>
</legend>
{% if telegrams|count > 0 %}
{% if telegrams|length > 0 %}
<table class="modlog">
<tr>
<th>{% trans 'Staff' %}</th>
@@ -159,10 +159,10 @@
</fieldset>
{% endif %}
{% if bans|count > 0 and mod|hasPermission(config.mod.view_ban) %}
{% if bans|length > 0 and mod|hasPermission(config.mod.view_ban) %}
<fieldset id="bans">
{% set bans_on_record = 'ban' ~ (bans|count != 1 ? 's' : '') ~ ' on record' %}
<legend>{{ bans|count }} {% trans bans_on_record %}</legend>
{% set bans_length = bans|length %}
<legend>{{ bans_length }} {% trans %}ban on record{% plural notes_length %}bans on record{% endtrans %}</legend>
{% for ban in bans %}
<form action="" method="post" style="text-align:center">
@@ -184,7 +184,7 @@
</fieldset>
{% endif %}
{% if logs|count > 0 %}
{% if logs|length > 0 %}
<fieldset id="history">
<legend>History</legend>
<table class="modlog" style="width:100%">