popular_threads.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. {{ messages_list(messages) }}
  9. <h1>{% trans %}Popular Threads{% endtrans %}</h1>
  10. </div>
  11. </div>
  12. <div class="container container-primary">
  13. {% if threads %}
  14. <div class="popular-threads">
  15. {% for thread in threads %}
  16. {% do thread.__dict__.update({'warmth': loop.index}) %}
  17. {% endfor %}
  18. {% for row in threads|batch(2, '') %}
  19. <div class="row">
  20. {% for thread in row %}{% if thread %}
  21. <div class="span6">
  22. <div class="popular-thread">
  23. <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>
  24. <div class="popular-thread-details">
  25. <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>
  26. <p class="popular-thread-info">
  27. {% 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 %}
  28. </p>
  29. </div>
  30. </div>
  31. </div>
  32. {% endif %}{% endfor %}
  33. </div>
  34. <hr>
  35. {% endfor %}
  36. </div>
  37. {% else %}
  38. <p class="lead">{% trans %}Looks like there are no popular threads... yet!{% endtrans %}</p>
  39. {% endif %}
  40. </div>
  41. {% endblock %}
  42. {% macro warmth(loop_index) -%}
  43. {% if loop_index < 5 %}0{% elif loop_index < 20 %}1{% elif loop_index < 35 %}2{% else %}3{% endif %}
  44. {%- endmacro %}
  45. {% macro replies(thread_replies) -%}
  46. {% trans count=thread_replies, replies=thread_replies|intcomma -%}
  47. One reply
  48. {%- pluralize -%}
  49. {{ replies }} replies
  50. {%- endtrans %}
  51. {%- endmacro %}
  52. {% macro forum(forum) -%}
  53. <a href="{% url 'forum' forum=forum.pk, slug=forum.slug %}">{{ forum.name }}</a>
  54. {%- endmacro %}
  55. {% macro username(id, username, slug) -%}
  56. {%- if id -%}
  57. <a href="{% url 'user' user=id, username=slug %}">{{ username }}</a>
  58. {%- else -%}
  59. {{ username }}
  60. {%- endif -%}
  61. {%- endmacro %}