Changed internal parser selection value from integers to a string enum.

This commit is contained in:
flash 2025-02-08 17:51:18 +00:00
parent 4d53565139
commit d9f35594e7
32 changed files with 301 additions and 213 deletions

View file

@ -85,7 +85,7 @@
{% macro input_select_option(value, key, selected) %}
{% apply spaceless %}
<option{% if key|length > 0 %} value="{{ key }}"{% endif %}{% if selected %} selected{% endif %}>
<option{% if key is not null %} value="{{ key }}"{% endif %}{% if selected %} selected{% endif %}>
{{ value }}
</option>
{% endapply %}
@ -101,7 +101,7 @@
{% endfor %}>
{% for key, value in options %}
{% set option_value = value_name|length > 0 ? value[value_name] : value %}
{% set option_key = only_values ? '' : (key_name|length > 0 ? value[key_name] : key) %}
{% set option_key = only_values ? null : (key_name|length > 0 ? value[key_name] : key) %}
{{ input_select_option(option_value, option_key, option_key|default(option_value) == selected) }}
{% endfor %}
</select>

View file

@ -60,7 +60,7 @@
<h1>{{ title }}</h1>
{% if change_info.body is not empty %}
{{ change_info.body|escape|parse_text(2)|raw }}
{{ change_info.body|escape|parse_md|raw }}
{% else %}
<p>This change has no additional notes.</p>
{% endif %}

View file

@ -466,7 +466,7 @@
{% set post_edited = post.info.editedTime %}
{% set post_is_deleted = post.info.deleted %}
{% set post_is_op = post.isOriginalPost %}
{% set post_body = post.info.body|escape|parse_text(post.info.parser) %}
{% set post_body = post.info.body|escape|parse_text(post.info.bodyFormat) %}
{% set post_is_markdown = post.info.isBodyMarkdown %}
{% set post_show_signature = post.info.shouldDisplaySignature %}
{% set post_can_be_deleted = post.info.canBeDeleted %}
@ -482,7 +482,7 @@
{% set author_created = post.user.createdTime %}
{% set author_posts_count = post.postsCount %}
{% set author_is_op = post.isOriginalPoster %}
{% set signature_body = post.user.signatureBody|default('')|escape|parse_text(post.user.signatureBodyParser) %}
{% set signature_body = post.user.signatureBody|default('')|escape|parse_text(post.user.signatureBodyFormat) %}
{% set signature_is_markdown = post.user.isSignatureBodyMarkdown %}
{% endif %}

View file

@ -80,9 +80,8 @@
<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)),
'post[parser]', parser_options(),
posting_defaults.parser|default(posting_post.info.bodyFormat|default(posting_user_preferred_parser)).value,
null, null, false, 'forum__post__dropdown js-forum-posting-parser'
) }}
{% if is_opening and posting_types|length > 1 %}

View file

@ -169,7 +169,7 @@
{% for post in featured_news %}
<div class="landingv2-news-post markdown">
<h1>{{ post.title }}</h1>
<p>{{ post.firstParagraph|escape|parse_text(2)|raw }}</p>
<p>{{ post.firstParagraph|escape|parse_md|raw }}</p>
<div class="landingv2-news-post-options">
<a href="{{ url('news-post', {'post': post.id}) }}" class="landingv2-news-post-option">Continue reading</a>
| <time datetime="{{ post.createdTime|date('c') }}" title="{{ post.createdTime|date('r') }}">{{ post.createdTime|time_format }}</time>

View file

@ -57,7 +57,7 @@
{% if not note_new and note_info.body is not empty %}
<div class="manage__note__body markdown manage__note--viewing">
{{ note_info.body|escape|parse_text(2)|raw }}
{{ note_info.body|escape|parse_md|raw }}
</div>
{% else %}
<div class="manage__note__nobody manage__note--viewing">

View file

@ -71,9 +71,9 @@
{% if note.info.body is not empty %}
<div class="manage__notes__item__body markdown">
{% if notes_filtering %}
{{ note.info.body|escape|parse_text(2)|raw }}
{{ note.info.body|escape|parse_md|raw }}
{% else %}
{{ note.info.firstParagraph|escape|parse_text(2)|raw }}
{{ note.info.firstParagraph|escape|parse_md|raw }}
{% endif %}
</div>
{% else %}

View file

@ -28,7 +28,7 @@
<div class="warning">
<div class="warning__content">
<p>UI is VERY not final. It will be not awful before 2025 I promise for real this time!!!</p>
<p>UI is VERY not final. It will be not awful before <del>2025</del> 2026 I promise for real this time!!!</p>
<p>I need to clean up a lot of code first because a lot of things are specifically written for the forum editor and it will become a big mess otherwise.</p>
</div>
</div>
@ -54,7 +54,7 @@
<div class="messages-reply-actions js-messages-reply-actions" hidden></div>
<div class="messages-reply-options">
<div class="messages-reply-settings">
{{ input_select('parser', constant('\\Misuzu\\Parsers\\Parser::NAMES'), '1', null, null, null, 'js-messages-reply-parser') }}
{{ input_select('format', parser_options(), 'bb', null, null, null, 'js-messages-reply-parser') }}
</div>
<div class="messages-reply-buttons">
<button class="input__button js-messages-reply-save" name="draft" value="1">Save draft</button>

View file

@ -92,7 +92,7 @@
<div class="messages-message-subject">
<h1>{{ message.info.title }}</h1>
</div>
<div class="messages-message-body{% if message.info.isBodyMarkdown %} markdown{% endif %}">{{ message.info.body|escape|parse_text(message.info.parser)|raw }}</div>
<div class="messages-message-body{% if message.info.isBodyMarkdown %} markdown{% endif %}">{{ message.info.body|escape|parse_text(message.info.bodyFormat)|raw }}</div>
</article>
{% if can_send_messages %}
@ -127,7 +127,7 @@
<div class="messages-reply-actions js-messages-reply-actions" hidden></div>
<div class="messages-reply-options">
<div class="messages-reply-settings">
{{ input_select('parser', constant('\\Misuzu\\Parsers\\Parser::NAMES'), draft_info.parser|default('1'), null, null, null, 'js-messages-reply-parser') }}
{{ input_select('format', parser_options(), draft_info.bodyFormat.value|default('bb'), null, null, null, 'js-messages-reply-parser') }}
</div>
<div class="messages-reply-buttons">
<button class="input__button js-messages-reply-save" name="draft" value="1">Save draft</button>

View file

@ -36,7 +36,7 @@
</div>
<div class="news__preview__content markdown">
<div class="news__preview__text">
{{ post.post.firstParagraph|escape|parse_text(2)|raw }}
{{ post.post.firstParagraph|escape|parse_md|raw }}
</div>
<div class="news__preview__links">
<a href="{{ url('news-post', {'post': post.post.id}) }}" class="news__preview__link">Continue reading</a>
@ -91,7 +91,7 @@
<div class="news__post__text markdown">
<h1>{{ post.title }}</h1>
{{ post.body|escape|parse_text(2)|raw }}
{{ post.body|escape|parse_md|raw }}
</div>
</div>
{% endmacro %}

View file

@ -266,12 +266,12 @@
{% if profile_is_editing %}
<div class="profile__signature__editor">
{{ input_select('about[parser]', constant('\\Misuzu\\Parsers\\Parser::NAMES'), profile_user.aboutBodyParser, '', '', false, 'profile__about__select') }}
{{ input_select('about[parser]', parser_options(), profile_user.aboutBodyFormat.value, '', '', false, 'profile__about__select') }}
<textarea name="about[text]" class="input__textarea profile__about__text" id="about-textarea">{{ profile_user.aboutBody }}</textarea>
</div>
{% else %}
<div class="profile__about__content{% if profile_is_editing %} profile__about__content--edit{% elseif profile_user.isAboutBodyMarkdown %} markdown{% endif %}">
{{ profile_user.aboutBody|escape|parse_text(profile_user.aboutBodyParser)|raw }}
{{ profile_user.aboutBody|escape|parse_text(profile_user.aboutBodyFormat)|raw }}
</div>
{% endif %}
</div>
@ -283,12 +283,12 @@
{% if profile_is_editing %}
<div class="profile__signature__editor">
{{ input_select('signature[parser]', constant('\\Misuzu\\Parsers\\Parser::NAMES'), profile_user.signatureBodyParser, '', '', false, 'profile__signature__select') }}
{{ input_select('signature[parser]', parser_options(), profile_user.signatureBodyFormat.value, '', '', false, 'profile__signature__select') }}
<textarea name="signature[text]" class="input__textarea profile__signature__text" id="signature-textarea">{{ profile_user.signatureBody }}</textarea>
</div>
{% else %}
<div class="profile__signature__content{% if profile_is_editing %} profile__signature__content--edit{% elseif profile_user.isSignatureBodyMarkdown %} markdown{% endif %}">
{{ profile_user.signatureBody|escape|parse_text(profile_user.signatureBodyParser)|raw }}
{{ profile_user.signatureBody|escape|parse_text(profile_user.signatureBodyFormat)|raw }}
</div>
{% endif %}
</div>