forum_map.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. <span class="label{% if forum.redirects_delta < forum.redirects %} label-success{% endif %}">{{ forum.redirects|intcomma }}</span> {% trans %}Clicks{% endtrans %}
  58. {% else %}
  59. <span class="label{% if forum.posts_delta < forum.posts %} label-success{% endif %}">{{ forum.posts|intcomma }}</span> {% trans %}Posts{% endtrans %}
  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 %}