forum_map.html 3.6 KB

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