_macro.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {% import 'base/link.html' as link %}
  2. {% macro votes(topic) -%}
  3. <div class="votes">
  4. {% if topic.vote and topic.vote > 0 -%}
  5. {{ vote_a('up',topic.vote) }}
  6. {% else %}
  7. {{ vote_a('up') }}
  8. {%- endif %}
  9. {% if topic.vote and topic.vote < 0 %}
  10. {{ vote_a('down',topic.vote) }}
  11. {% else %}
  12. {{ vote_a('down') }}
  13. {%- endif %}
  14. </div>
  15. {%- endmacro %}
  16. {% macro vote_a(vo,count=None) -%}
  17. {% if count -%}
  18. <a id="topic-{{ vo }}-vote" class="vote" href="javascript:void(0)" style="text-decoration:none;">
  19. <i class="fa fa-chevron-{{ vo }}">{{ count }}</i>
  20. </a>
  21. {% else %}
  22. <a id="topic-{{ vo }}-vote" class="vote" href="javascript:void(0)" style="text-decoration:none;">
  23. <i class="fa fa-chevron-{{ vo }}"></i>
  24. </a>
  25. {%- endif %}
  26. {%- endmacro %}
  27. {% macro tags(topic) -%}
  28. {% for tag in topic.tags %}
  29. {{ link.tag(tag) }}
  30. {% endfor %}
  31. {%- endmacro %}
  32. {% macro last_reply(topic) -%}
  33. <span style="margin-left:10px;">
  34. {% set last_reply = topic.replies.first() %}
  35. {{ topic.author.username }}
  36. {{ _('published at %(time)s',time = topic.created_at | timesince ) }}
  37. {% if last_reply %}
  38. · {{ _('The last reply published by %(author)s at %(time)s',author=link.user(last_reply.author.username),time=last_reply.created_at | timesince)}}
  39. {% endif %}
  40. </span>
  41. {%- endmacro %}
  42. {% macro title(topic) -%}
  43. {{ votes(topic) }}
  44. {{ tags(topic) }}
  45. {{ last_reply(topic) }}
  46. {%- endmacro %}