{%- macro share(site = None, site_label = None, icon = False) -%} {% if icon == False %}{% if site_label %}{{ site_label }}{% else %}{{ site }}{% endif %}{% endif %} {%- endmacro -%} {%- macro inbox_message_snippet(message) -%}
{{ gravatar(message.user, 16) }} {{ message.user.username|escape }} {{ message.message_type }} ({{ timeago(message.timestamp) }}) {#
{{ message.snippet }}
#}
{{ message.content }}
{%- endmacro -%} {%- macro mailto_link(email) -%} {{ email }} {%- endmacro -%} {%- macro moderation_queue_message(message) -%}
{{ gravatar(message.user, 16) }} {{ message.user.username|escape }} | {% if message['memo_type'] == 'edit' %} {{ mailto_link(message.user.email) }} | ip={{ message.ip_addr }} | {% endif %} {{ message.message_type }} ({{ timeago(message.timestamp) }}) {#
{{ message.snippet }}
#}
{{ message.content }}
{%- endmacro -%} {%- macro post_vote_buttons(post = None) -%}
{{ post.score }}
{%- endmacro -%} {%- macro post_contributor_avatar_and_credentials(revision) -%} {% if revision.is_anonymous %} {% trans %}anonymous user{% endtrans %}

{{ revision.author.get_anonymous_name() }}

{% else %} {{ user_card(revision.author) }} {% endif %} {% if settings.GROUPS_ENABLED %} {{ user_primary_group(revision.author) }} {% endif %} {%- endmacro -%} {%- macro post_last_updater_and_creator_info(post) -%} {% if post.wiki %}

{%- if post.post_type == 'question' -%} {% set action_performed=settings.WORDS_ASKED|escape %} {% elif post.post_type == 'answer' %} {% set action_performed=settings.WORDS_ANSWERED|escape %} {% else %} {%- set action_performed=gettext('posted') %} {% endif %} {{ timeago(post.added_at, action_performed=action_performed) }}

{% trans %}this post is marked as community wiki{% endtrans %} {% set wiki_min_rep = settings.MIN_REP_TO_EDIT_WIKI %}

{% trans %}This post is a wiki. Anyone with karma >{{wiki_min_rep}} is welcome to improve it.{% endtrans %}

{% else %} {% set first_rev = post.get_earliest_revision() %} {% set last_rev = post.get_latest_revision() %} {{ post_contributor_info(first_rev, "original_author") }} {% if first_rev != last_rev %} {{ post_contributor_info(last_rev, "last_updater") }} {% endif %} {% endif %} {%- endmacro -%} {%- macro post_contributor_info(revision, contributor_type) -%}
{% if contributor_type=="original_author" %} {% if revision.post.post_type == 'question' %} {% set action_label = settings.WORDS_ASKED|escape %} {% elif revision.post.post_type == 'answer' %} {% set action_label = settings.WORDS_ANSWERED|escape %} {% else %} {% set action_label = gettext('posted') %} {% endif %} {% else %} {% set action_label = gettext('updated') %} {% endif %} {% if revision.post.post_type in ('question', 'answer') %} {% set original_author = revision.post.author %} {% else %} {% set original_author = None %} {% endif %}

{{ timeago(revision.revised_at, action_performed=action_label) }}

{% set show_user_info = (contributor_type == 'original_author' or (contributor_type == 'last_updater' and original_author != revision.author )) %} {% if show_user_info %} {{ post_contributor_avatar_and_credentials(revision) }} {% endif %}
{%- endmacro -%} {%- macro if_else(condition, if_true, if_false) -%} {%- if condition == True -%} {{if_true}} {%- else -%} {{if_false}} {%- endif -%} {%- endmacro -%} {%- macro tag_cloud(tags = None, font_sizes = None, search_state = None) -%} {% for tag in tags %} {{ tag.name|escape }} {% endfor %} {%- endmacro -%} {%- macro tag_list_widget( tags, id=None, deletable=False, make_links=True, search_state=None, css_class=None, truncate_long_tags=False ) -%} {%- endmacro -%} {%- macro user_group_link(group) -%} {{ group.name|escape }} {%- endmacro -%} {%- macro user_group(group, membership_info, show_count=False) -%} {{ user_group_link(group) }} {% if show_count %} {{ group.users_count }} {% endif %} {% if group.description %} {{ group.description.summary }} {% endif %} {% if membership_info %}
{{ group_join_button( group_id = group.id, acceptance_level = membership_info['aceptance_level'], membership_level = membership_info['membership_level'] ) }} {% endif %} {%- endmacro -%} {%- macro user_primary_group(user) -%} {% set group=user.get_primary_group() %} {% if group %} {{ group.name|replace('-', ' ')|escape }} {% endif %} {%- endmacro -%} {%- macro group_join_button( group_id=None, acceptance_level='closed', membership_level='none') -%} {% if acceptance_level in ('open', 'moderated') %} {% endif %} {%- endmacro -%} {# todo: remove the extra content argument to make its usage more explicit #} {%- macro tag_widget( tag, deletable=False, is_link=True, css_class=None, search_state=None, extra_content='', truncate_long_tag=False ) -%} {% if not search_state %} {# get empty SearchState() if there's none; CAUTION: for some reason this doesn't work inside `spaceless` tag below! #} {% set search_state=search_state|get_empty_search_state %} {% endif %} {% filter trim %}
<{% if is_link %}a{% else %}span{% endif %} class="js-tag-name{% if css_class %} {{ css_class }}{% endif %}" rel="tag" {% if is_link and not tag.endswith('*') %} href="{{ search_state.add_tag(tag).full_url() }}" {% endif %} data-tag-name="{{ tag|escape }}" >{% if truncate_long_tag -%} {{ tag|truncate(17, True)|escape|replace('*', '✽')}} {%- else -%} {{ tag|escape|replace('*', '✽') }} {%- endif -%} {% if deletable %} × {% endif %} {% if extra_content %} {{ extra_content }} {% endif %}
{% endfilter %} {%- endmacro -%} {%- macro radio_select(name = None, value = None, choices = None) -%} {% for choice in choices %}

{% set id = "id_" ~ name ~ "_" ~ choice[0] %}

{% endfor %} {%- endmacro -%} {%- macro question_summary(thread, question, extra_class=None, search_state=None, visitor = None) -%} {%include "widgets/question_summary.html" %} {%- endmacro -%} {# Warning! Any changes to the comment markup here must be duplicated in post.js for the purposes of the AJAX comment editor #} {%- macro comments_widget_buttons(post = None, max_comments = None) -%} {% if post.comment_count > max_comments %} {% if settings.COMMENTS_REVERSED == False %} {% endif %} {% if settings.COMMENTS_REVERSED %} {% trans %}load older comments{% endtrans %} {% else %} {% trans %}see more comments{% endtrans %} {% endif %} {% else %} {% if settings.COMMENTS_REVERSED == False %} {% trans %}add a comment{% endtrans %} {% endif %} {% endif %} {%- endmacro -%} {%- macro csrf_middleware_token(csrf_token) -%}
{%- endmacro -%} {%- macro comment_widget(comment, csrf_token=None) -%} {# Warning! Any changes to the comment markup must be duplicated in post.js for the purposes of the AJAX comment editor #}
{% if comment.score > 0 %}{{ comment.score }}{% endif %}
{% if comment.id %} {% endif %}
{% if comment.needs_moderation() %}

{% trans %}This post is awaiting moderation, please do not repost the same content!{% endtrans %}

{% endif %}
{{ comment.summary }}
{# important - the same number for avatar size must be in question/javascript.html #} {% if hasattr(comment.author, 'is_terminated') and comment.author.is_terminated() %} {#comment.author.is_terminated() %#} {% trans %}anonymous user{% endtrans %} {{ comment.author.get_anonymous_name() }} {% else %} {{ gravatar(comment.author, 16) }} {{ comment.author.username|escape }} {% endif %}  ({{ timeago(comment.added_at) }}) {% trans %}edit{% endtrans %}
{{ csrf_input }}
{% if comment.id %} {% endif %} {%- endmacro -%} {%- macro post_comments_widget( post=None, show_post=None, show_comment=None, show_comment_position=None, user=None, max_comments=None, csrf_token=None ) -%} {% filter trim %} {% if show_post == post and show_comment and show_comment_position > max_comments %} {% set comments = post.get_cached_comments()[:show_comment_position] %} {% else %} {% set comments = post.get_cached_comments()[:max_comments] %} {% endif %} {% set comments_count = comments|length %} {% if comments_count > 0 or settings.COMMENTS_REVERSED %}

{% trans %}Comments{% endtrans %}

{% endif %}
{% if settings.COMMENTS_REVERSED %}
{% set prompt=gettext('add a comment...') %} {% include "widgets/mock_editor.html" %}
{% endif %}
{% for comment in comments %} {{ comment_widget(comment, csrf_token) }} {% endfor %}
{% if show_post == post and show_comment and show_comment_position > max_comments %} {{ comments_widget_buttons(post=post, max_comments=show_comment_position) }} {% else %} {{ comments_widget_buttons(post=post, max_comments=max_comments) }} {% endif %}
{% endfilter %} {%- endmacro -%} {%- macro reversible_sort_button(button_sort_criterium=None, asc_tooltip=None, desc_tooltip=None, label=None, current_sort_method=None, search_state=None) -%} {# sort button where descending sort is default and the search method is togglable between ascending and descending buttons are rendered as links with id constructed as "by_" + button_sort_criterium class "on" is added when current_sort_method is one of button_sort_criterium + "asc" or "desc" #} {% set key_name = button_sort_criterium %} {% if current_sort_method == key_name + "-asc" %}{# "worst" first #} {{label}} ▲ {% elif current_sort_method == key_name + "-desc" %}{# "best first" #} {{label}} ▼ {% else %}{# default, when other button is active #} {{label}} {% endif %} {%- endmacro %} {%- macro checkbox_in_div(checkbox_field, class = 'checkbox') -%} {{ checkbox_field.errors }} {{ checkbox_field }} {{ checkbox_field.label_tag() }} {%- endmacro -%} {%- macro edit_post(post_form, settings, post_html=None) -%} {# todo: retire this macro, this will require renaming or using "set" on some template variables #} {% include "editors/rich_text.html" %} {%- endmacro -%} {%- macro tag_autocomplete_js(id = '#id_tags') -%} var tagAc = new AutoCompleter({ url: '{{ url('get_tag_list') }}', minChars: 1, useCache: true, matchInside: true, maxCacheLength: 100, delay: 10 }); tagAc.decorate($("{{ id }}")); {%- endmacro -%} {%- macro answer_classes(answer, question) -%} {% if answer.endorsed %}accepted-answer{% endif %} {% if answer.author_id==question.author_id %} answered-by-owner{% endif %} {% if answer.deleted %}deleted{% endif -%} {%- endmacro -%} {%- macro user_long_score_and_badge_summary(user) -%} {%- include "widgets/user_long_score_and_badge_summary.html" -%} {%- endmacro -%} {%- macro user_country_flag(user) -%} {% if user.country and user.country.code != 'none' and user.show_country %} {% trans
                    country=user.country.name
                    %}flag of {{country}}{%
                endtrans %} {% endif %} {%- endmacro -%} {%- macro user_country_name_and_flag(user) -%} {% if user.country and user.show_country %} {{ user.country.name }} {{ user_country_flag(user) }} {% endif %} {%- endmacro -%} {%- macro user_full_location(user) -%} {% if user.location %} {{ user.location|escape }}, {% endif %} {{ user_country_name_and_flag(user) }} {%- endmacro -%} {% macro user_card(user) %} {% include "widgets/user_card.html" %} {% endmacro %} {%- macro user_list(users) -%} {% include "widgets/user_list.html" %} {%- endmacro -%} {#todo: rename this to avatar #} {%- macro gravatar(user, size) -%} {% filter trim %} {% trans username=user.username|escape %}{{username}} gravatar image{% endtrans %} {% endfilter %} {%- endmacro -%} {%- macro user_website_link(user, max_display_length=25, force_show=False) -%} {% if user.website and (force_show or (not (user.is_blocked() or user.is_watched()))) %} {{user.website|truncate(length=max_display_length, killwords=True, end='...')}} {% endif %} {%- endmacro -%} {%- macro paginator(p, position='left', anchor='') -%}{# p is paginator context dictionary #} {% filter trim %} {% if p.is_paginated %}
« {% trans %}previous{% endtrans %} 1 ... {% for num in p.page_numbers %} {% if num == p.page %} {{ num }} {% else %} {{ num }} {% endif %} {% endfor %} {# the "last page" navigation #} ... {{ p.pages }} {# "next" nav link #} {% trans %}next{% endtrans %} »
{% endif %} {% endfilter %} {%- endmacro -%} {%- macro paginator_main_page(p, position, search_state) -%} {# p is paginator context dictionary #} {% filter trim %} {% if p.is_paginated %}
{% if p.has_previous %} « {% trans %}previous{% endtrans %} {% endif %} {% if not p.in_leading_range %} {% for num in p.pages_outside_trailing_range %} {{ num }} {% endfor %} ... {% endif %} {% for num in p.page_numbers %} {% if num == p.page and p.pages != 1%} {{ num }} {% else %} {{ num }} {% endif %} {% endfor %} {% if not p.in_trailing_range %} ... {% for num in p.pages_outside_leading_range|reverse %} {{ num }} {% endfor %} {% endif %} {% if p.has_next %} {% trans %}next page{% endtrans %} » {% endif %}
{% endif %} {% endfilter %} {%- endmacro -%} {%- macro inbox_link(user) -%} {% if user.new_response_count %} {% trans username=user.username|escape %}responses for {{username}}{% endtrans %} {% endif %} {%- endmacro -%} {%- macro moderation_items_link(user, moderation_items) -%} {% if moderation_items %} {% if moderation_items['new_count'] > 0 %} 0 %} alt="{% trans new=moderation_items['new_count'], seen=moderation_items['seen_count']%}{{new}} new flagged posts and {{seen}} previous{% endtrans %}" title="{% trans new=moderation_items['new_count'], seen=moderation_items['seen_count']%}{{new}} new flagged posts and {{seen}} previous{% endtrans %}" {% else %} alt="{% trans new=moderation_items['new_count'] %}{{new}} new flagged posts{% endtrans %}" title="{% trans new=moderation_items['new_count'] %}{{new}} new flagged posts{% endtrans %}" {% endif %} /> {% elif moderation_items['seen_count'] > 0 %} {% trans seen=moderation_items['seen_count'] %}{{seen}} flagged posts{% endtrans %} {% endif %} {% endif %} {%- endmacro -%} {%- macro timeago(datetime_object, action_performed=None) -%} {% set when='' ~ datetime_object.replace(microsecond=0)|add_tz_offset ~ '' %} {% if action_performed %} {# action and time can be reversed, depending on language #} {% trans %}{{ action_performed }} {{ when }}{% endtrans %} {% else %} {{ when }} {% endif %} {%- endmacro -%} {% macro one_shot_form_js(form=None, submit_button=None) %} {% endmacro %} {% macro form_field_with_errors(field) %} {% if field.errors %}

{{ field.errors|join(", ") }}

{% endif %} {{ field }} {% endmacro %}