summaryrefslogtreecommitdiffstats
path: root/askbot/skins/default/templates/macros/macros.html
diff options
context:
space:
mode:
Diffstat (limited to 'askbot/skins/default/templates/macros/macros.html')
-rw-r--r--askbot/skins/default/templates/macros/macros.html757
1 files changed, 757 insertions, 0 deletions
diff --git a/askbot/skins/default/templates/macros/macros.html b/askbot/skins/default/templates/macros/macros.html
new file mode 100644
index 00000000..282553e4
--- /dev/null
+++ b/askbot/skins/default/templates/macros/macros.html
@@ -0,0 +1,757 @@
+{%- macro user_score_and_badge_summary(user) -%}
+ <span class="reputation-score"
+ title="{{user.get_karma_summary}}"
+ >{{user.reputation}}</span>
+ {% if user.gold or user.silver or user.bronze %}
+ <span title="{{user.get_badge_summary}}">
+ {% if user.gold %}
+ <span class='badge1'>&#9679;</span>
+ <span class="badgecount">{{user.gold}}</span>
+ {% endif %}
+ {% if user.silver %}
+ <span class='badge2'>&#9679;</span>
+ <span class="badgecount">{{user.silver}}</span>
+ {% endif %}
+ {% if user.bronze %}
+ <span class='badge3'>&#9679;</span>
+ <span class="badgecount">{{user.bronze}}</span>
+ {% endif %}
+ </span>
+ {% endif %}
+{%- endmacro -%}
+
+{%- macro share(site = None, site_label = None, icon = False) -%}
+ <a class="{{ site }}-share{% if icon == True %} icon{% endif %}"
+ title="{% trans %}Share this question on {{site}}{% endtrans %}"
+ >{% if icon == False %}{% if site_label %}{{ site_label }}{% else %}{{ site }}{% endif %}{% endif %}</a>
+{%- endmacro -%}
+
+{%- macro follow_toggle(follow, name, alias, id) -%}
+ {# follow - boolean; name - object type name; alias - e.g. users name; id - object id #}
+ <div
+ class="follow-toggle"
+ id="follow-{{ name }}-{{ id }}"
+ >
+ {% if follow %}
+ <div class="follow">{% trans %}follow {{alias}}{% endtrans %}</div>
+ {% else %}
+ <div class="unfollow">
+ <div class="unfollow-red">{% trans %}unfollow {{alias}}{% endtrans %}</div>
+ <div class="unfollow-green">{% trans %}following {{alias}}{% endtrans %}</div>
+ </div>
+ {% endif %}
+ </div>
+{%- endmacro -%}
+
+{%- macro follow_user_toggle(visitor = None, subject = None) -%}
+ {% if visitor.is_anonymous() %}
+ {{ follow_toggle(True, 'user', subject.username, subject.id) }}
+ {% else %}
+ {% if visitor != subject %}
+ {% if visitor.is_following(subject) %}
+ {{ follow_toggle(False, 'user', subject.username, subject.id) }}
+ {% else %}
+ {{ follow_toggle(True, 'user', subject.username, subject.id) }}
+ {% endif %}
+ {% endif %}
+ {% endif %}
+{%- endmacro -%}
+
+{%- macro user_long_score_and_badge_summary(user) -%}
+ <a class="user-micro-info"
+ href="{{user.get_absolute_url()}}?sort=reputation"
+ >{% trans %}karma:{% endtrans %} {{user.reputation}}</a>
+ {%- if user.gold or user.silver or user.bronze %}
+ <a class="user-micro-info"
+ href="{{user.get_absolute_url()}}#badges"
+ ><span title="{{user.get_badge_summary}}">{% trans %}badges:{% endtrans %}
+ {% if user.gold %}
+ <span class='badge1'>&#9679;</span>
+ <span class="badgecount">{{user.gold}}</span>
+ {% endif %}
+ {% if user.silver %}
+ <span class='badge2'>&#9679;</span>
+ <span class="badgecount">{{user.silver}}</span>
+ {% endif %}
+ {% if user.bronze %}
+ <span class='badge3'>&#9679;</span>
+ <span class="badgecount">{{user.bronze}}</span>
+ {%- endif -%}
+ </span></a>
+ {%- endif -%}
+{%- endmacro -%}
+
+{%- macro user_country_flag(user) -%}
+ {% if user.country and user.show_country %}
+ <img class="flag"
+ src="{{ ('/images/flags/' ~ user.country.code|lower ~ '.gif')|media }}"
+ alt="{% trans
+ country=user.country.name
+ %}flag of {{country}}{%
+ endtrans %}"
+ title="{% trans
+ country=user.country.name,
+ person=user.username %}{{person}} is from {{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 }},
+ {% endif %}
+ {{ user_country_name_and_flag(user) }}
+{%- endmacro -%}
+
+{%- macro user_list(users, profile_section = None) -%}
+<div class="userList">
+ <table class="list-table">
+ <tr>
+ <td class="list-td">
+ {% for user in users %}
+ <div class="user">
+ <ul>
+ <li class="thumb">{{ gravatar(user, 32) }}</li>
+ <li><a href="{% url user_profile user.id, user.username|slugify %}{% if profile_section %}?sort={{profile_section}}{% endif %}">{{user.username}}</a>{{ user_country_flag(user) }}</li>
+ <li>{{ user_score_and_badge_summary(user) }}</li>
+ </ul>
+ </div>
+ {% if loop.index is divisibleby 7 %}
+ </td>
+ <td>
+ {% endif %}
+ {% endfor %}
+ </td>
+ </tr>
+ </table>
+</div>
+{%- endmacro -%}
+
+{%- macro paginator(p, position='left') -%}{# p is paginator context dictionary #}
+{% spaceless %}
+ {% if p.is_paginated %}
+ <div class="paginator" style="float:{{position}}">
+ {% if p.has_previous %}
+ <span class="prev"><a href="{{p.base_url}}page={{ p.previous }}{{ p.extend_url }}" title="{% trans %}previous{% endtrans %}">
+ &laquo; {% trans %}previous{% endtrans %}</a></span>
+ {% endif %}
+ {% if not p.in_leading_range %}
+ {% for num in p.pages_outside_trailing_range %}
+ <span class="page"><a href="{{p.base_url}}page={{ num }}{{ p.extend_url }}" >{{ num }}</a></span>
+ {% endfor %}
+ ...
+ {% endif %}
+
+ {% for num in p.page_numbers %}
+ {% if num == p.page and p.pages != 1%}
+ <span class="curr" title="{% trans %}current page{% endtrans %}">{{ num }}</span>
+ {% else %}
+ <span class="page"><a href="{{p.base_url}}page={{ num }}{{ p.extend_url }}" title="{% trans %}page number {{num}}{% endtrans %}">{{ num }}</a></span>
+ {% endif %}
+ {% endfor %}
+
+ {% if not p.in_trailing_range %}
+ ...
+ {% for num in p.pages_outside_leading_range|reverse %}
+ <span class="page"><a href="{{p.base_url}}page={{ num }}{{ p.extend_url }}" title="{% trans %}page number {{ num }}{% endtrans %}">{{ num }}</a></span>
+ {% endfor %}
+ {% endif %}
+ {% if p.has_next %}
+ <span class="next"><a href="{{p.base_url}}page={{ p.next }}{{ p.extend_url }}" title="{% trans %}next page{% endtrans %}">{% trans %}next page{% endtrans %} &raquo;</a></span>
+ {% endif %}
+ </div>
+ {% endif %}
+{% endspaceless %}
+{%- endmacro -%}
+
+{%- macro pagesize_switch(p, position='left') -%}{# p is paginator context #}
+{% spaceless %}
+{% if p.is_paginated %}
+ <div class="paginator" style="float:{{position}}">
+ <span class="text">{% trans %}posts per page{% endtrans %}</span>
+ {% if p.page_size == 10 %}
+ <span class="curr">10</span>
+ {% else %}
+ <span class="page"><a href="{{p.base_url}}page_size=10">10</a></span>
+ {% endif %}
+
+ {% if p.page_size == 30 %}
+ <span class="curr">30</span>
+ {% else %}
+ <span class="page"><a href="{{p.base_url}}page_size=30">30</a></span>
+ {% endif %}
+
+ {% if p.page_size == 50 %}
+ <span class="curr">50</span>
+ {% else %}
+ <span class="page"><a href="{{p.base_url}}page_size=50">50</a></span>
+ {% endif %}
+ </div>
+{% endif %}
+{% endspaceless %}
+{%- endmacro -%}
+
+{#todo: rename this to avatar #}
+{%- macro gravatar(user, size) -%}
+{% spaceless %}
+<a style="text-decoration:none"
+ href="{{ user.get_absolute_url() }}"
+><img class="gravatar"
+ width="{{size}}" height="{{size}}"
+ src="{{ user.get_avatar_url(size) }}"
+ title="{{user.username}}"
+ alt="{% trans username=user.username %}{{username}} gravatar image{% endtrans %}"
+/></a>
+{% endspaceless %}
+{%- endmacro -%}
+
+{%- macro user_website_link(user, max_display_length=25) -%}
+ {% if user.website %}
+ <a
+ href="{{user.website}}"
+ title="{% trans username=user.username|escape, url=user.website %}{{username}}'s website is {{url}}{% endtrans %}"
+ {% if user.can_have_strong_url() == False %}
+ rel="nofollow"
+ {% endif %}
+ >
+ {{user.website|truncate(length=max_display_length, killwords=True, end='...')}}
+ </a>
+ {% endif %}
+{%- endmacro -%}
+
+{%- macro post_contributor_avatar_and_credentials(post, user) -%}
+ {% if post.is_anonymous %}
+ <img alt="{% trans %}anonymous user{% endtrans %}" src="{{ '/images/anon.png'|media }} " class="gravatar" width="32" height="32" />
+ <p>{{ user.get_anonymous_name() }}</p>
+ {% else %}
+ {{ gravatar(user, 32) }}
+ {{ user.get_profile_link()}}{{ user_country_flag(user) }}<br/>
+ {{ user_score_and_badge_summary(user) }}<br/>
+ {{ user_website_link(user) }}
+ {% endif %}
+{%- endmacro -%}
+
+{%- macro post_contributor_info(post, contributor_type, is_wiki, wiki_min_rep) -%}
+{# there is a whole bunch of trickery here, probably indicative of
+poor design of the data or methods on data objects #}
+{% if contributor_type=="original_author" %}
+ <div class='post-update-info'>
+ {% if is_wiki %}
+ <p>
+ {%- if post.post_type == 'question' -%}
+ {%- trans %}asked{% endtrans %}
+ {% elif post.post_type == 'answer' %}
+ {%- trans %}answered{% endtrans %}
+ {% else %}
+ {%- trans %}posted{% endtrans %}
+ {% endif %}
+ <strong>{{post.added_at|diff_date}}</strong>
+ </p>
+ <img
+ src="{{'/images/wiki.png'|media}}"
+ alt="{% trans %}this post is marked as community wiki{% endtrans %}"
+ style="float:left"
+ />
+ <p class="tip">{% trans %}This post is a wiki.
+ Anyone with karma &gt;{{wiki_min_rep}} is welcome to improve it.{% endtrans %}</p>
+ {% else %}
+ <p style="line-height:12px;">
+ {# todo: access to class names needs to be removed here #}
+ {% if post.post_type == 'question' %}
+ {% trans %}asked{% endtrans %}
+ {% elif post.post_type == 'answer' %}
+ {% trans %}answered{% endtrans %}
+ {% else %}
+ {% trans %}posted{% endtrans %}
+ {% endif %}
+ {% if post.__class__.__name__ in ('QuestionRevision', 'AnswerRevision') %}
+ <strong>{{post.revised_at|diff_date}}</strong>
+ {% else %}
+ <strong>{{post.added_at|diff_date}}</strong>
+ {% endif %}
+ </p>
+ {{ post_contributor_avatar_and_credentials(post, post.author) }}
+ {% endif %}
+ </div>
+{% elif contributor_type=="last_updater" %}
+ {% if post.post_type in ('question', 'answer') %}
+ {% set last_edited_at = post.last_edited_at %}
+ {% set original_author = post.author %}
+ {% set update_author = post.last_edited_by %}
+ {% elif post.__class__.__name__ in ('QuestionRevision', 'AnswerRevision') %}
+ {% set last_edited_at = post.revised_at %}
+ {% set original_author = None %}{# fake value to force display widget in the revision views #}
+ {% set update_author = post.author %}
+ {% endif %}
+ {% if last_edited_at %}
+ <div class='post-update-info'>
+ <p style="line-height:12px;">
+ <a
+ {% if post.post_type == 'question' %}
+ href="{% url question_revisions post.id %}"
+ {% else %}
+ href="{% url answer_revisions post.id %}"
+ {% endif %}
+ >{% trans %}updated{% endtrans %} <strong>{{ last_edited_at|diff_date }}</strong></a>
+ </p>
+ {% if original_author != update_author or is_wiki %}
+ {{ post_contributor_avatar_and_credentials(post, update_author) }}
+ {% endif %}
+ </div>
+ {% endif %}
+{% 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) -%}
+ {% for tag in tags %}
+ <span class="tag-size-{{ font_sizes[tag.name] }}">
+ <a class="link-typeA" title="Number of entries: {{ tag.used_count }}" href="{% url questions %}?tags={{ tag.name }}">{{ tag.name }}</a>
+ </span>
+ {% endfor %}
+{%- endmacro -%}
+
+{%- macro tag_list_widget(
+ tags,
+ id = None,
+ deletable = False,
+ make_links = True,
+ url_params = None,
+ css_class = None
+ )
+-%}
+<ul {% if id %}id="{{ id }}"{% endif %}
+ class="tags{% if css_class %} {{css_class}}{% endif %}"
+>
+ {% if tags %}
+ {% for tag in tags %}
+ {{ tag_widget(
+ tag,
+ deletable = deletable,
+ is_link = make_links,
+ url_params = url_params,
+ html_tag = 'li'
+ )}}
+ {% endfor %}
+ {% endif %}
+</ul>
+{%- endmacro -%}
+
+{# todo: remove the extra content argument to make its usage more explicit #}
+{%- macro tag_widget(
+ tag,
+ deletable = False,
+ is_link = True,
+ delete_link_title = None,
+ css_class = None,
+ url_params = None,
+ html_tag = 'div',
+ extra_content = ''
+ )
+-%}
+ {% spaceless %}
+ <{{ html_tag }} class="tag-left{% if deletable %} deletable-tag{% endif %}">
+ <{% if not is_link or tag[-1] == '*' %}span{% else %}a{% endif %}
+ class="tag tag-right{% if css_class %} {{ css_class }}{% endif %}"
+ {% if is_link %}
+ href="{% url questions %}?tags={{tag|urlencode}}{{
+ if_else(
+ url_params != None,
+ '&' ~ url_params,
+ ''
+ )|escape
+ }}"
+ title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}"
+ {% endif %}
+ rel="tag"
+ >{{ tag|replace('*', '&#10045;') }}</{% if not is_link or tag[-1] == '*' %}span{% else %}a{% endif %}>
+ {% if deletable %}
+ <span class="delete-icon"
+ {% if delete_link_title %}
+ title="{{ delete_link_title }}"
+ {% endif %}
+ ></span>
+ {% endif %}
+ </{{ html_tag }}>
+ {{ extra_content }}
+ {% endspaceless %}
+{%- endmacro -%}
+
+{%- macro radio_select(name = None, value = None, choices = None) -%}
+ {% for choice in choices %}
+ <p class="choice">
+ {% set id = "id_" ~ name ~ "_" ~ choice[0] %}
+ <input
+ id="{{ id }}"
+ name="{{ name }}"
+ value="{{ choice[0] }}"
+ type="radio"
+ {% if value == choice[0] %}
+ checked="checked"
+ {% endif %}
+ />
+ <label for="{{ id }}">{{ choice[1] }}</label>
+ </p>
+ {% endfor %}
+{%- endmacro -%}
+
+{%- macro question_summary(question, extra_class=None) -%}
+ <div class="short-summary{% if extra_class %} {{extra_class}}{% endif %}" id="question-{{question.id}}">
+ <div class="counts">
+ <div class="views
+ {% if question.view_count == 0 -%}
+ no-views
+ {% else -%}
+ some-views
+ {%- endif -%}">
+ <span class="item-count">{{question.view_count|humanize_counter}}</span>
+ <div>
+ {% trans cnt=question.view_count %}view{% pluralize %}views{% endtrans %}
+ </div>
+ </div>
+ <div class="answers
+ {% if question.answer_count == 0 -%}
+ no-answers
+ {% else -%}
+ {%- if question.answer_accepted -%}
+ accepted
+ {%- else -%}
+ some-answers
+ {%- endif -%}
+ {%- endif -%}">
+ <span
+ class="item-count"
+ >{{question.answer_count|humanize_counter}}{% if question.answer_accepted%}&#10003;{% endif %}</span>
+ <div>
+ {% trans cnt=question.answer_count %}answer{% pluralize %}answers{% endtrans %}
+ </div>
+ </div>
+ <div class="votes
+ {% if question.score == 0 -%}
+ no-votes
+ {% else -%}
+ some-votes
+ {%- endif -%}">
+ <span class="item-count">{{question.score|humanize_counter}}</span>
+ <div>
+ {% trans cnt=question.score %}vote{% pluralize %}votes{% endtrans %}
+ </div>
+ </div>
+
+ <div style="clear:both"></div>
+ <div class="userinfo">
+ <span class="relativetime" title="{{question.last_activity_at}}">{{ question.last_activity_at|diff_date }}</span>
+ {% if question.is_anonymous %}
+ <span class="anonymous">{{ question.last_activity_by.get_anonymous_name() }}</span>
+ {% else %}
+ <a href="{% url user_profile question.last_activity_by.id, question.last_activity_by.username|slugify %}">{{question.last_activity_by.username}}</a>{{ user_country_flag(question.last_activity_by) }}
+ {#{user_score_and_badge_summary(question.last_activity_by)}#}
+ {% endif %}
+ </div>
+ </div>
+ <h2><a title="{{question.summary|escape}}" href="{{ question.get_absolute_url() }}">{{question.get_question_title()|escape}}</a></h2>
+ {{ tag_list_widget(question.get_tag_names()) }}
+ </div>
+{%- endmacro -%}
+
+{%- macro comment_votes(comment = None) -%}
+ <div class="comment-votes">
+ {% if comment.score > 0 %}
+ <div class="upvote{% if comment.upvoted_by_user %} upvoted{% endif %}">{{comment.score}}</div>
+ {% else %}
+ <div class="upvote"></div>
+ {% endif %}
+ </div>
+{%- endmacro -%}
+
+{# Warning! Any changes to the comment markup here must be duplicated in post.js
+for the purposes of the AJAX comment editor #}
+
+{%- macro comment_list(comments = None, user = None) -%}
+ {% for comment in comments %}
+ <div class="comment" id="comment-{{comment.id}}">
+ {{ comment_votes(comment = comment) }}
+ <div class="comment-delete">
+ {% if user|can_delete_comment(comment) %}
+ <span class="delete-icon" title="{% trans %}delete this comment{% endtrans %}"></span>
+ {% endif %}
+ </div>
+ <div class="comment-body">
+ {{comment.html}}
+ <a
+ class="author"
+ href="{{comment.user.get_profile_url()}}"
+ >{{comment.user.username}}</a>
+ <span class="age">&nbsp;({{comment.added_at|diff_date}})</span>
+ {% if user|can_edit_comment(comment) %}
+ <a class="edit">{% trans %}edit{% endtrans %}</a>
+ {% endif %}
+ </div>
+ </div>
+ {% endfor %}
+{%- endmacro -%}
+
+{%- macro add_or_show_comments_button(post = None, can_post = None, max_comments = None, widget_id = None) -%}
+ <script type="text/javascript">
+ askbot['data']['{{widget_id}}'] = {
+ can_post: {% if can_post %}true{% else %}false{% endif %},
+ truncated: {% if post.comment_count > max_comments %}true{% else %}false{% endif %}
+ };
+ </script>
+ {% if post.comment_count > max_comments %}
+ {% set remaining_comments = post.comment_count - max_comments %}
+ <a class="button">
+ {% if can_post %}
+ {% trans %}add comment{% endtrans %} /
+ {% trans counter=remaining_comments %}see <strong>{{counter}}</strong> more{% pluralize %}see <strong>{{counter}}</strong> more{% endtrans %}
+ {% else %}
+ {% trans counter=remaining_comments %}see <strong>{{counter}}</strong> more comment{% pluralize %}see <strong>{{counter}}</strong> more comments
+ {% endtrans %}
+ {% endif %}
+ </a>
+ {% elif can_post %}
+ <a class="button">{% trans %}add comment{% endtrans %}</a>
+ {% endif %}
+{%- endmacro -%}
+
+{%- macro post_comments_widget(post=None, show_post = None, show_comment = None, comment_order_number = None, user=None, max_comments=None) -%}
+ {% spaceless %}
+ {% set widget_id = 'comments-for-' + post.post_type + '-' + post.id|string %}
+ <div class="comments" id="{{widget_id}}">
+ <div class="content">
+ {% if show_post == post and show_comment %}
+ {% if comment_order_number > max_comments %}
+ {% set comments = post.get_comments(visitor = user)[:comment_order_number] %}
+ {{ comment_list(comments = comments, user = user) }}
+ {% else %}
+ {% set comments = post.get_comments(visitor = user)[:max_comments] %}
+ {{ comment_list(comments = comments, user = user) }}
+ {% endif %}
+ {% else %}
+ {% set comments = post.get_comments(visitor = user)[:max_comments] %}
+ {{ comment_list(comments = comments, user = user) }}
+ {% endif %}
+ </div>
+ <div class="controls">
+ {% set can_post = user|can_post_comment(post) %}
+ {% if show_post == post and show_comment %}
+ {% if comment_order_number > max_comments %}
+ {{
+ add_or_show_comments_button(
+ post = post,
+ can_post = can_post,
+ max_comments = comment_order_number,
+ widget_id = widget_id
+ )
+ }}
+ {% else %}
+ {{
+ add_or_show_comments_button(
+ post = post,
+ can_post = can_post,
+ max_comments = max_comments,
+ widget_id = widget_id
+ )
+ }}
+ {% endif %}
+ {% else %}
+ {{
+ add_or_show_comments_button(
+ post = post,
+ can_post = can_post,
+ max_comments = max_comments,
+ widget_id = widget_id
+ )
+ }}
+ {% endif %}
+ </div>
+ </div>
+ {% endspaceless %}
+{%- endmacro -%}
+
+{%- macro reversible_sort_button(button_sort_criterium=None, asc_tooltip=None,
+ desc_tooltip=None, label=None, current_sort_method=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 %}
+ {% set sort = current_sort_method %}
+ {% if sort == key_name + "-asc" %}{# "worst" first #}
+ <a id="by_{{key_name}}"
+ href="?sort={{key_name}}-desc"
+ class="rev on"
+ title="{{desc_tooltip}}"><span>{{label}} &#9650;</span></a>
+ {% elif sort == key_name + "-desc" %}{# "best first" #}
+ <a id="by_{{key_name}}"
+ href="?sort={{key_name}}-asc"
+ class="rev on"
+ title="{{asc_tooltip}}"><span>{{label}} &#9660;</span></a>
+ {% else %}{# default, when other button is active #}
+ <a id="by_{{key_name}}"
+ href="?sort={{key_name}}-desc"
+ class="off"
+ title="{{desc_tooltip}}"><span>{{label}}</span></a>
+ {% endif %}
+ <script type="text/javascript">{# need to pass on text translations to js #}
+ var sortButtonData = sortButtonData || {};
+ sortButtonData["{{key_name}}"] = {
+ label: "{{label}}",
+ asc_tooltip: "{{asc_tooltip}}",
+ desc_tooltip: "{{desc_tooltip}}"
+ };
+ </script>
+{%- endmacro %}
+
+{%- macro checkbox_in_div(checkbox_field, class = 'checkbox') -%}
+ <div{% if class %} class="{{class}}"{% endif %}
+ title="{{checkbox_field.help_text}}">
+ {{ checkbox_field }}
+ {{ checkbox_field.label_tag() }}
+ {{ checkbox_field.errors }}
+ </div>
+{%- endmacro -%}
+
+{%- macro edit_post(
+ post_form,
+ post_type = None,
+ mandatory_tags = None,
+ edit_title = False
+ )
+-%}
+ {% if edit_title %}
+ <div class="form-item">
+ <label for="id_title" ><strong>{{ post_form.title.label_tag() }}:</strong></label> <span class="form-error"></span><br/>
+ {{ post_form.title }} {{ post_form.title.errors }}
+ <div class="title-desc">
+ {{ post_form.title.help_text }}
+ </div>
+ </div>
+ {% endif %}
+ <div id="wmd-button-bar" class="wmd-panel"></div>
+ <div class="form-item">
+ {{ post_form.text }}{# this element is resizable and will be wrapped by js #}
+ <label for="editor" class="form-error">{{ post_form.text.errors }}</label>
+ </div>
+ {# need label element for resizable input, b/c form validation won't find span #}
+ {% if post_type == 'question' %}
+ <div class="form-item">
+ {% if mandatory_tags %}
+ <label for="id_tags">
+ <strong>{% trans %}tags{% endtrans %},</strong>
+ {% trans %}one of these is required{% endtrans %}
+ </label>
+ {{
+ tag_list_widget(
+ mandatory_tags,
+ make_links = False,
+ css_class = 'clearfix'
+ )
+ }}
+ {% else %}
+ <label for="id_tags">
+ <strong>{% trans %}tags{% endtrans %}:</strong>
+ {% trans %}(required){% endtrans %}
+ </label>
+ {% endif %}
+ <span class="form-error">{{ post_form.tags.errors }}</span><br/>
+ {{ post_form.tags }}
+ <div class="title-desc">
+ {{ post_form.tags.help_text }}
+ </div>
+ </div>
+ {% endif %}
+ {% if 'summary' in post_form['fields'] %}
+ <div class="form-item">
+ <strong>{{ post_form.summary.label_tag() }}</strong> <br/>
+ {{ post_form.summary }}
+ <div class="title-desc">
+ {{ post_form.summary.help_text }}
+ </div>
+ <div class="form-error" >{{ post_form.summary.errors }}</div>
+ </div>
+ {% endif %}
+ <div class="preview-toggle">
+ <span
+ id="pre-collapse"
+ title="{% trans %}Toggle the real time Markdown editor preview{% endtrans %}"
+ >
+ [{% trans %}hide preview{% endtrans %}]
+ </span>
+ </div>
+ <div id="previewer" class="wmd-preview"></div>
+{%- endmacro -%}
+
+{%- macro inbox_link(user) -%}
+ {% if user.new_response_count > 0 or user.seen_response_count > 0 %}
+ <a id='ab-responses' href="{{user.get_absolute_url()}}?sort=inbox&section=forum">
+ <img
+ alt="{% trans username=user.username %}responses for {{username}}{% endtrans %}"
+ {% if user.new_response_count > 0 %}
+ src="{{ "/images/mail-envelope-full.png"|media }}"
+ title="{% trans response_count=user.new_response_count %}you have a new response{% pluralize %}you have {{response_count}} new responses{% endtrans %}"
+ {% elif user.seen_response_count > 0 %}
+ src="{{ "/images/mail-envelope-empty.png"|media }}"
+ title="{% trans %}no new responses yet{% endtrans %}"
+ {% endif %}
+ />
+ </a>
+ {% endif %}
+{%- endmacro -%}
+
+{%- macro moderation_items_link(user, moderation_items) -%}
+ {% if moderation_items %}
+ <a id="ab-responses"
+ href="{{user.get_absolute_url()}}?sort=inbox&section=flags"
+ >
+ {% if moderation_items['new_count'] > 0 %}
+ <img src="{{'/images/dialog-warning.png'|media}}"
+ {% if moderation_items['seen_count'] > 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 %}
+ <img src={{'/images/dialog-warning-off.png'|media}}
+ alt="{% trans seen=moderation_items['seen_count'] %}{{seen}} flagged posts{% endtrans %}"
+ title="{% trans seen=moderation_items['seen_count'] %}{{seen}} flagged posts{% endtrans %}"
+ />
+ {% endif %}
+ </a>
+ {% endif %}
+{%- endmacro -%}
+
+{%- macro tag_autocomplete_js(id = '#id_tags') -%}
+ var tagAc = new AutoCompleter({
+ url: '{% url "get_tag_list" %}',
+ preloadData: true,
+ minChars: 1,
+ useCache: true,
+ matchInside: true,
+ maxCacheLength: 100,
+ delay: 10
+ });
+ tagAc.decorate($("{{ id }}"));
+{%- endmacro -%}