misuzu/templates/forum/posting.twig

119 lines
6.2 KiB
Twig

{% extends 'forum/master.twig' %}
{% from 'macros.twig' import avatar %}
{% from 'forum/macros.twig' import forum_header %}
{% from '_layout/input.twig' import input_hidden, input_csrf, input_text, input_select, input_checkbox %}
{% set title = 'Posting' %}
{% set is_reply = posting_topic is defined %}
{% set is_opening = not is_reply or posting_post.isOriginalPost|default(false) %}
{% block content %}
<form method="post" action="{{ url('forum-' ~ (is_reply ? 'post' : 'topic') ~ '-create') }}" class="js-forum-posting">
{{ input_hidden('post[' ~ (is_reply ? 'topic' : 'forum') ~ ']', is_reply ? posting_topic.id : posting_forum.id) }}
{{ input_hidden('post[mode]', posting_mode) }}
{{ input_csrf() }}
{{ forum_header(
is_reply and not is_opening
? posting_topic.title
: input_text(
'post[title]',
'forum__header__input',
posting_defaults.title|default(posting_topic.title|default('')),
'text',
'Enter your title here...'
),
posting_breadcrumbs,
false,
is_reply and not is_opening
? url('forum-topic', {'topic': posting_topic.id})
: ''
) }}
{% if posting_post is defined %}
{{ input_hidden('post[id]', posting_post.info.id) }}
{% endif %}
{% if posting_notices|length > 0 %}
<div class="warning">
<div class="warning__content">
{% for notice in posting_notices %}
<p>{{ notice }}</p>
{% endfor %}
</div>
</div>
{% endif %}
<div class="container forum__post" style="--accent-colour: {{ posting_post.colour|default(posting_user_colour) }}">
<div class="forum__post__info">
<div class="forum__post__info__background"></div>
<div class="forum__post__info__content">
<span class="forum__post__avatar">{{ avatar(posting_post.user.id|default(posting_user.id), 120, posting_post.user.name|default(posting_user.name)) }}</span>
<span class="forum__post__username">{{ posting_post.user.name|default(posting_user.name) }}</span>
<div class="forum__post__icons">
<div class="flag flag--{{ posting_post.user.countryCode|default(posting_user.countryCode)|lower }}" title="{{ posting_post.user.countryCode|default(posting_user.countryCode)|country_name }}"></div>
<div class="forum__post__posts-count">{{ posting_post.postsCount|default(posting_user_posts_count)|number_format }} posts</div>
</div>
<div class="forum__post__joined">
joined <time datetime="{{ posting_post.user.createdTime|default(posting_user.createdTime)|date('c') }}" title="{{ posting_post.user.createdTime|default(posting_user.createdTime)|date('r') }}">{{ posting_post.user.createdTime|default(posting_user.createdTime)|time_format }}</time>
</div>
</div>
</div>
<div class="forum__post__content">
<div class="forum__post__details">
<span class="forum__post__mode js-forum-posting-mode">
{% if posting_post is defined %}
Editing
{% elseif is_reply %}
Replying
{% else %}
Creating
{% endif %}
</span>
</div>
<textarea name="post[text]" class="forum__post__text forum__post__text--edit js-forum-posting-text js-ctrl-enter-submit" placeholder="Type your post content here...">{{ posting_defaults.text|default(posting_post.info.body|default('')) }}</textarea>
<div class="forum__post__text js-forum-posting-preview" hidden></div>
<div class="forum__post__actions js-forum-posting-actions"></div>
<div class="forum__post__options">
<div class="forum__post__settings">
{{ input_select(
'post[parser]',
constant('\\Misuzu\\Parsers\\Parser::NAMES'),
posting_defaults.parser|default(posting_post.info.parser|default(posting_user_preferred_parser)),
null, null, false, 'forum__post__dropdown js-forum-posting-parser'
) }}
{% if is_opening and posting_types|length > 1 %}
<select class="input__select forum__post__dropdown" name="post[type]">
{% for type_name, type_title in posting_types %}
<option value="{{ type_name }}"{% if type_name == posting_topic.typeString|default('discussion') %} selected{% endif %}>{{ type_title }}</option>
{% endfor %}
</select>
{% endif %}
{{ input_checkbox(
'post[signature]',
'Display Signature',
posting_defaults.signature is not null
? posting_defaults.signature : (
posting_post.info.shouldDisplaySignature is defined
? posting_post.info.shouldDisplaySignature
: true
)
) }}
</div>
<div class="forum__post__buttons js-forum-posting-buttons">
<button class="input__button" onclick="MszForumEditorAllowClose = true;">Submit</button>
</div>
</div>
</div>
</div>
</form>
{% if globals.eeprom_path is not empty and globals.eeprom_app is not empty %}
<script type="text/javascript">
const peepPath = '{{ globals.eeprom_path }}', peepApp = '{{ globals.eeprom_app }}';
</script>
{% endif %}
{% endblock %}