forum_map.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. {% extends "cranefly/layout.html" %}
  2. {% load i18n %}
  3. {% import "cranefly/macros.html" as macros with context %}
  4. {% block title %}{{ macros.page_title(title=_("Forum Map")) }}{% endblock %}
  5. {% block container %}
  6. <div class="page-header header-primary">
  7. <div class="container">
  8. {{ messages_list(messages) }}
  9. <h1>{% trans %}Forum Map{% endtrans %}</h1>
  10. </div>
  11. </div>
  12. <div class="container container-primary">
  13. {% if forums %}
  14. <div class="row">
  15. <div class="span6">
  16. {% for category in forums %}{% if loop.index is odd and category.subforums %}
  17. {{ draw_category(category) }}
  18. {% endif %}{% endfor %}
  19. </div>
  20. <div class="span6">
  21. {% for category in forums %}{% if loop.index is even and category.subforums %}
  22. {{ draw_category(category) }}
  23. {% endif %}{% endfor %}
  24. </div>
  25. </div>
  26. {% else %}
  27. <p class="lead">{% trans %}Looks like no forums exist that you have permission to see.{% endtrans %}</p>
  28. {% endif %}
  29. </div>
  30. {% endblock %}
  31. {% macro draw_category(category) %}
  32. <div class="forum-map-category{% if category.style %} forum-map-category-{{ category.style }}{% endif %}">
  33. <table class="table">
  34. <caption>{{ category.name }}</caption>
  35. <tbody>
  36. {% for forum in category.subforums%}
  37. {{ draw_forum(forum) }}
  38. {% endfor %}
  39. </tbody>
  40. </table>
  41. </div>
  42. {% endmacro %}
  43. {% macro draw_forum(forum, depth=0, branch='', last=false) %}
  44. <tr>
  45. <td class="{% if depth -%}
  46. forum-map-subforum
  47. {%- else -%}
  48. forum-map-forum
  49. {%- endif %}">
  50. <h3>{% if depth %}{% if last -%}
  51. {{ draw_tree(branch ~ 'l') }}
  52. {%- else -%}
  53. {{ draw_tree(branch ~ 't') }}
  54. {%- endif %}{% endif %} <a href="{{ forum.type|url(slug=forum.slug, forum=forum.id) }}">{{ forum.name }}</a></h3>
  55. <div class="forum-details">
  56. {% if forum.type == 'redirect' %}
  57. {{ redirect_stats(forum) }}
  58. {% else %}
  59. {{ forum_stats(forum) }}
  60. {% endif %}
  61. </div>
  62. </td>
  63. </tr>
  64. {% for subforum in forum.subforums %}
  65. {% if depth %}
  66. {% if last %}
  67. {{ draw_forum(subforum, (depth + 1), (branch ~ 's'), loop.last) }}
  68. {% else %}
  69. {{ draw_forum(subforum, (depth + 1), (branch ~ 'i'), loop.last) }}
  70. {% endif %}
  71. {% else %}
  72. {{ draw_forum(subforum, (depth + 1), '', loop.last) }}
  73. {% endif %}
  74. {% endfor %}
  75. {% endmacro %}
  76. {% macro draw_tree(branch) %}
  77. {% for item in branch %}
  78. <span class="tree-{{ item }}"><span></span></span>
  79. {% endfor %}
  80. {% endmacro %}
  81. {% macro forum_stats(forum) -%}
  82. {% if forum.last_thread_id and not forum.attr('hidethread') -%}
  83. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta), thread=forum_thread(forum) -%}
  84. {{ posts }} post - last in {{ thread }}
  85. {%- pluralize -%}
  86. {{ posts }} posts - last in {{ thread }}
  87. {%- endtrans %}
  88. {%- else -%}
  89. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta) -%}
  90. {{ posts }} post
  91. {%- pluralize -%}
  92. {{ posts }} posts
  93. {%- endtrans %}
  94. {%- endif %}
  95. {%- endmacro %}
  96. {% macro forum_thread(forum) -%}
  97. <a href="{% url 'thread' thread=forum.last_thread_id, slug=forum.last_thread_slug %}">{{ forum.last_thread_name }}</a>
  98. {%- endmacro %}
  99. {% macro redirect_stats(forum) -%}
  100. {% trans count=forum.redirects, redirects=fancy_number(forum.redirects, forum.redirects_delta) -%}
  101. {{ redirects }} click
  102. {%- pluralize -%}
  103. {{ redirects }} clicks
  104. {%- endtrans %}
  105. {%- endmacro %}
  106. {% macro fancy_number(number, delta) -%}
  107. <strong{% if delta < number %} class="stat-increment"{% endif %}>{{ number|intcomma }}</strong>
  108. {%- endmacro %}