popular_threads.html 2.5 KB

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