category.html 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {% extends "cranefly/layout.html" %}
  2. {% load i18n %}
  3. {% load url from future %}
  4. {% import "cranefly/macros.html" as macros with context %}
  5. {% block title %}{{ macros.page_title(title=category.name) }}{% endblock %}
  6. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  7. {% for parent in parents %}
  8. <li><a href="{{ parent.type|url(forum=parent.pk, slug=parent.slug) }}">{{ parent.name }}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>
  9. {% endfor %}
  10. <li class="active">{{ category.name }}
  11. {%- endblock %}
  12. {% block container %}
  13. <div class="page-header header-primary">
  14. <div class="container">
  15. {{ messages_list(messages) }}
  16. <ul class="breadcrumb">
  17. {{ self.breadcrumb() }}</li>
  18. </ul>
  19. <h1>{{ category.name }}</h1>
  20. </div>
  21. </div>
  22. <div class="container container-primary">
  23. {% if category.description %}
  24. <div class="markdown lead page-description">
  25. {{ category.description_preparsed|markdown_final|safe }}
  26. </div>
  27. {% endif %}
  28. {% if category.subforums %}
  29. <div class="category-forums-list{% if category.style %} category-forums-{{ category.style }}{% endif %}">
  30. <table class="table">
  31. <tbody>
  32. {% for forum in category.subforums %}
  33. <tr>
  34. <td class="forum-icon"><span class="forum-icon-wrap{% if forum.type == 'redirect' %} forum-icon-redirect{% elif not forum.is_read %} forum-icon-new{% endif %}"><i class="icon-{% if forum.type == 'redirect' %}circle-arrow-right{% else %}comment{% endif %} icon-white"></i></span></td>
  35. <td class="forum-main">
  36. <h3{% if not forum.is_read %} class="forum-title-new"{% endif %}><a href="{{ forum.type|url(slug=forum.slug, forum=forum.id) }}">{{ forum.name }}</a></h3>
  37. {% if forum.show_details %}
  38. <div class="forum-details">
  39. {% if forum.type == 'redirect' %}
  40. {{ redirect_stats(forum) }}
  41. {% else %}
  42. {{ forum_stats(forum) }}
  43. {% endif %}
  44. </div>
  45. {% endif %}
  46. {% if forum.description %}<p class="forum-description">{{ forum.description }}</p>{% endif %}
  47. </td>
  48. </tr>
  49. {% endfor %}
  50. </tbody>
  51. </table>
  52. </div>
  53. {% else %}
  54. <p class="lead">{% trans %}Looks like there are no forums to display in this category.{% endtrans %}</p>
  55. {% endif %}
  56. </div>
  57. {% endblock %}
  58. {% macro forum_stats(forum) -%}
  59. {% if forum.last_thread_id and not forum.attr('hidethread') -%}
  60. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta), thread=forum_thread(forum) -%}
  61. {{ posts }} post - last in {{ thread }}
  62. {%- pluralize -%}
  63. {{ posts }} posts - last in {{ thread }}
  64. {%- endtrans %}
  65. {%- else -%}
  66. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta) -%}
  67. {{ posts }} post
  68. {%- pluralize -%}
  69. {{ posts }} posts
  70. {%- endtrans %}
  71. {%- endif %}
  72. {%- endmacro %}
  73. {% macro forum_thread(forum) -%}
  74. <a href="{% url 'thread' thread=forum.last_thread_id, slug=forum.last_thread_slug %}">{{ forum.last_thread_name }}</a>
  75. {%- endmacro %}
  76. {% macro redirect_stats(forum) -%}
  77. {% trans count=forum.redirects, redirects=fancy_number(forum.redirects, forum.redirects_delta) -%}
  78. {{ redirects }} click
  79. {%- pluralize -%}
  80. {{ redirects }} clicks
  81. {%- endtrans %}
  82. {%- endmacro %}
  83. {% macro fancy_number(number, delta) -%}
  84. <strong{% if delta < number %} class="stat-increment"{% endif %}>{{ number|intcomma }}</strong>
  85. {%- endmacro %}