misuzu/templates/forum/posting.twig
2023-08-28 01:17:34 +00:00

184 lines
11 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_button, 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="{{ posting_post.colour|default(posting_user_colour)|html_colour('--accent-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 forum__post__actions--bbcode" hidden>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-bold" title="Bold [b]<text>[/b]" data-tag-open="[b]" data-tag-close="[/b]">
<i class="fas fa-bold fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-italic" title="Italic [i]<text>[/i]" data-tag-open="[i]" data-tag-close="[/i]">
<i class="fas fa-italic fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-underline" title="Underline [u]<text>[/u]" data-tag-open="[u]" data-tag-close="[/u]">
<i class="fas fa-underline fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-strike" title="Strikethrough [s]<text>[/s]" data-tag-open="[s]" data-tag-close="[/s]">
<i class="fas fa-strikethrough fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-link" title="Link [url]<url>[/url] or [url=<url>]<text>[/url]" data-tag-open="[url=]" data-tag-close="[/url]">
<i class="fas fa-link fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-image" title="Image [img]<url>[/img]" data-tag-open="[img]" data-tag-close="[/img]">
<i class="fas fa-image fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-audio" title="Audio [audio]<url>[/url]" data-tag-open="[audio]" data-tag-close="[/audio]">
<i class="fas fa-music fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-video" title="Video [video]<url>[/video]" data-tag-open="[video]" data-tag-close="[/video]">
<i class="fas fa-video fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-code" title="Code [code]<code>[/code]" data-tag-open="[code]" data-tag-close="[/code]">
<i class="fas fa-code fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--bb-zalgo" title="Zalgo [zalgo]<text>[/zalgo]" data-tag-open="[zalgo]" data-tag-close="[/zalgo]">
<i class="fas fa-frog fa-fw"></i>
</div>
</div>
<div class="forum__post__actions forum__post__actions--markdown" hidden>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-bold" title="Bold **<text>**" data-tag-open="**" data-tag-close="**">
<i class="fas fa-bold fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-italic" title="Italic *<text>* or _<text>_" data-tag-open="*" data-tag-close="*">
<i class="fas fa-italic fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-underline" title="Underline __<text>__" data-tag-open="__" data-tag-close="__">
<i class="fas fa-underline fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-strike" title="Strikethrough ~~<text>~~" data-tag-open="~~" data-tag-close="~~">
<i class="fas fa-strikethrough fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-link" title="Link [<text>](<url>)" data-tag-open="[](" data-tag-close=")">
<i class="fas fa-link fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-image" title="Image ![<alt text>](<url>)" data-tag-open="![](" data-tag-close=")">
<i class="fas fa-image fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-audio" title="Audio ![<alt text>](<url>)" data-tag-open="![](" data-tag-close=")">
<i class="fas fa-music fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-video" title="Video ![<alt text>](<url>)" data-tag-open="![](" data-tag-close=")">
<i class="fas fa-video fa-fw"></i>
</div>
<div class="forum__post__action forum__post__action--tag forum__post__action--md-code" title="Code `<code>` or ```<code>```" data-tag-open="```" data-tag-close="```">
<i class="fas fa-code fa-fw"></i>
</div>
</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_type_selected %} 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="forumPostingCloseOK = true;">Submit</button>
</div>
</div>
</div>
</div>
</form>
{% if globals.eeprom.path is not empty %}
<script type="text/javascript">
const peepPath = '{{ globals.eeprom.path }}', peepApp = '{{ globals.eeprom.app }}';
</script>
{% endif %}
{% endblock %}