git / moonbite-network / templates/partials/forum_macros.html · raw
{# Forum building blocks shared by discussions.html and discussion_thread.html. #}{% macro av(name, size="", official=False) -%}{%- if official -%}<span class="fx-av off{{ ' ' ~ size if size }}" aria-hidden="true"><svg viewBox="-150 -150 300 300" width="60%" height="60%"><path fill="#0B0D12" d="M 13.99 -99.02 A 100 100 0 1 0 99.02 -13.99 A 62 62 0 0 1 13.99 -99.02 Z"/></svg></span>{%- else -%}{%- set a = forum_avatar(name) -%}<span class="fx-av t{{ a.t }}{{ ' ' ~ size if size }}" aria-hidden="true">{{ a.i }}</span>{%- endif -%}{%- endmacro %}{# Author name plus, for the official account, the verified badge; automated posts also say so. Only server-side code can create official posts. #}{% macro author(item, tag="b") -%}<{{ tag }}{% if tag != 'b' %} class="who"{% endif %}>{{ item.author }}</{{ tag }}>{%- if item.is_official %} <span class="fx-verified" title="Official MoonBite account. Only the MoonBite server can post as it."><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#D9A441"/><path d="M4.8 8.3l2.1 2.1 4.3-4.6" fill="none" stroke="#0B0D12" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>Verified moderator</span>{% endif %}{%- if item.automated %} <span class="fx-auto" title="Posted automatically by the MoonBite server, not typed by a person.">Automated</span>{% endif %}{%- endmacro %}{# "3h" -> "3h ago"; "now" and calendar dates stay as they are #}{% macro ago(s) -%}{{ s }}{{ ' ago' if s[-1] in 'mhd' else '' }}{%- endmacro %}{% macro stack(names, limit=4) -%}<span class="fx-stack" title="{{ names|join(', ') }}"> {%- for n in names[:limit] %}{{ av(n) }}{% endfor -%} {%- if names|length > limit %}<span class="more">+{{ names|length - limit }}</span>{% endif -%}</span>{%- endmacro %}{# Up/down vote control. kind: 't' thread or 'r' reply; mine: -1, 0 or 1. #}{% macro vote(kind, id, score, mine=0, layout="col") -%}<div class="fx-vote {{ layout }}{{ ' v1' if mine == 1 }}" data-kind="{{ kind }}" data-id="{{ id }}" data-mine="{{ mine }}" data-score="{{ score }}"> <button type="button" class="up" aria-label="Upvote" aria-pressed="{{ 'true' if mine == 1 else 'false' }}"><svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><path d="M9 2.5l6 7H11v6H7v-6H3z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/></svg></button> <span class="sc" aria-label="score">{{ score }}</span> <button type="button" class="dn" aria-label="Downvote" aria-pressed="{{ 'true' if mine == -1 else 'false' }}"><svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><path d="M9 15.5l6-7H11v-6H7v6H3z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/></svg></button></div>{%- endmacro %}{% macro icon_comment() -%}<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 3.5h11v7h-6l-3 3v-3h-2z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>{%- endmacro %}{% macro icon_share() -%}<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2v8M5 5l3-3 3 3M3 9v4.5h10V9" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>{%- endmacro %}{% macro rules() -%}<section class="fx-panel" aria-labelledby="rules-h"> <h2 id="rules-h">Board rules</h2> <ol class="fx-rules"> <li><span><b>Be kind.</b> Argue with ideas, not people.</span></li> <li><span><b>Vote for useful,</b> not for agree. Votes are one per browser and network, not per person.</span></li> <li><span><b>No price talk.</b> No pumping, shilling or predictions.</span></li> <li><span><b>Never post a seed phrase</b> or private key, not even "just to check".</span></li> <li><span><b>Nobody from MoonBite DMs first.</b> Anyone who does is a scammer.</span></li> <li><span><b>Names aren't verified.</b> Anyone can post under any name.</span></li> </ol> <p class="fx-credit">Emoji artwork: <a href="https://github.com/jdecked/twemoji" rel="noopener" target="_blank">Twemoji</a>, CC-BY 4.0.</p></section>{%- endmacro %}{% macro emoji_button() -%}<button type="button" class="fx-act-btn fx-emoji-btn" data-emoji aria-label="Insert emoji" aria-haspopup="dialog"><svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><circle cx="9" cy="9" r="7.2" fill="none" stroke="currentColor" stroke-width="1.5"/><circle cx="6.5" cy="7.5" r="1" fill="currentColor"/><circle cx="11.5" cy="7.5" r="1" fill="currentColor"/><path d="M5.8 10.6c.8 1.4 1.9 2.1 3.2 2.1s2.4-.7 3.2-2.1" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>Emoji</button>{%- endmacro %}{% macro format_hint() -%}<span class="hint">{{ emoji_button() }} Blank line for a new paragraph, <code>></code> to quote, <code>`code`</code>, <code>:rocket:</code> for emoji. <span class="fx-kbd">Ctrl</span> + <span class="fx-kbd">Enter</span> posts.</span>{%- endmacro %}{# Moderator-only pieces. The macros file is imported "with context" so these can see is_mod and forum_csrf; for everyone else they render nothing. #}{% macro as_official() -%}{%- if is_mod %}<label class="fx-asoff"><input type="checkbox" name="as_official" value="1"> Post as <b>MoonBite</b> (verified moderator)</label><input type="hidden" name="csrf" value="{{ forum_csrf }}">{%- endif %}{%- endmacro %}{% macro mod_button(kind, id, action, label, next) -%}{%- if is_mod %}<form class="fx-modf" method="post" action="{{ url_for('discussions_mod_action') }}"> <input type="hidden" name="csrf" value="{{ forum_csrf }}"><input type="hidden" name="kind" value="{{ kind }}"> <input type="hidden" name="id" value="{{ id }}"><input type="hidden" name="action" value="{{ action }}"> <input type="hidden" name="next" value="{{ next }}"> <button type="submit" class="fx-act-btn fx-mod-btn{{ ' danger' if action == 'remove' }}">{{ label }}</button></form>{%- endif %}{%- endmacro %}{% macro report_button(kind, id) -%}<button type="button" class="fx-act-btn" data-report="{{ kind }}:{{ id }}"><svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 14V2.5M3.5 3h8l-1.6 3 1.6 3h-8" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg> Report</button>{%- endmacro %}{% macro honeypot() -%}<div class="fx-hp" aria-hidden="true"><label>Leave this empty <input type="text" name="website" tabindex="-1" autocomplete="off"></label></div>{%- endmacro %}