popular_threads.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {% extends "cranefly/layout.html" %}
  2. {% load i18n %}
  3. {% import "cranefly/macros.html" as macros with context %}
  4. {% block title %}{{ macros.page_title(title=_('Popular Threads')) }}{% endblock %}
  5. {% block container %}
  6. <div class="page-header header-primary">
  7. <div class="container">
  8. {% if messages %}
  9. <div class="messages-list">
  10. {{ messages_list(messages) }}
  11. </div>
  12. {% endif %}
  13. <h1>{% trans %}Popular Threads{% endtrans %}</h1>
  14. </div>
  15. </div>
  16. <div class="container container-primary">
  17. {% if threads %}
  18. <div class="popular-threads">
  19. {% for thread in threads %}
  20. {% do thread.__dict__.update({'warmth': loop.index}) %}
  21. {% endfor %}
  22. {% for row in threads|batch(2, '') %}
  23. <div class="row">
  24. {% for thread in row %}{% if thread %}
  25. <div class="span6">
  26. <div class="popular-thread">
  27. <a href="{% url 'thread_new' thread=thread.pk, slug=thread.slug %}" class="label popular-thread-warmth popular-thread-warmth-{{ warmth(thread.warmth) }} tooltip-top" title="{% trans %}Jump to latest reply{% endtrans %}"><i class="icon-fire"></i></a>
  28. <div class="popular-thread-details">
  29. <a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}" class="popular-thread-title tooltip-top" title="{% trans %}Jump to thread start{% endtrans %}">{{ thread.name }}</a>
  30. <p class="popular-thread-info">
  31. {% trans forum=forum(thread.forum), starter=username(thread.start_poster_id, thread.start_poster_name, thread.start_poster_slug), last=thread.last|reldate, replies=replies(thread.replies) %}By {{ starter }} - {{ forum }} - {{ replies }} - last on {{ last }}.{% endtrans %}
  32. </p>
  33. </div>
  34. </div>
  35. </div>
  36. {% endif %}{% endfor %}
  37. </div>
  38. <hr>
  39. {% endfor %}
  40. </div>
  41. {% else %}
  42. <p class="lead">{% trans %}Looks like there are no popular threads... yet!{% endtrans %}</p>
  43. {% endif %}
  44. </div>
  45. {% endblock %}
  46. {% macro warmth(loop_index) -%}
  47. {% if loop_index < 5 %}0{% elif loop_index < 20 %}1{% elif loop_index < 35 %}2{% else %}3{% endif %}
  48. {%- endmacro %}
  49. {% macro replies(thread_replies) -%}
  50. {% trans count=thread_replies, replies=thread_replies|intcomma -%}
  51. One reply
  52. {%- pluralize -%}
  53. {{ replies }} replies
  54. {%- endtrans %}
  55. {%- endmacro %}
  56. {% macro forum(forum) -%}
  57. <a href="{% url 'forum' forum=forum.pk, slug=forum.slug %}">{{ forum.name }}</a>
  58. {%- endmacro %}
  59. {% macro username(id, username, slug) -%}
  60. {%- if id -%}
  61. <a href="{% url 'user' user=id, username=slug %}">{{ username }}</a>
  62. {%- else -%}
  63. {{ username }}
  64. {%- endif -%}
  65. {%- endmacro %}