forum_map.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. {% if messages %}
  9. <div class="messages-list">
  10. {{ messages_list(messages) }}
  11. </div>
  12. {% endif %}
  13. <h1>{% trans %}Forum Map{% endtrans %}</h1>
  14. </div>
  15. </div>
  16. <div class="container container-primary">
  17. {% if forums %}
  18. <div class="row">
  19. <div class="span6">
  20. {% for category in forums %}{% if loop.index is odd and category.subforums %}
  21. {{ draw_category(category) }}
  22. {% endif %}{% endfor %}
  23. </div>
  24. <div class="span6">
  25. {% for category in forums %}{% if loop.index is even and category.subforums %}
  26. {{ draw_category(category) }}
  27. {% endif %}{% endfor %}
  28. </div>
  29. </div>
  30. {% else %}
  31. <p class="lead">{% trans %}Looks like no forums exist that you have permission to see.{% endtrans %}</p>
  32. {% endif %}
  33. </div>
  34. {% endblock %}
  35. {% macro draw_category(category) %}
  36. <div class="forum-map-category{% if category.style %} forum-map-category-{{ category.style }}{% endif %}">
  37. <table class="table">
  38. <caption>{{ category.name }}</caption>
  39. <tbody>
  40. {% for forum in category.subforums%}
  41. {{ draw_forum(forum) }}
  42. {% endfor %}
  43. </tbody>
  44. </table>
  45. </div>
  46. {% endmacro %}
  47. {% macro draw_forum(forum, depth=0, branch='', last=false) %}
  48. <tr>
  49. <td class="{% if depth -%}
  50. forum-map-subforum
  51. {%- else -%}
  52. forum-map-forum
  53. {%- endif %}"><h3>{% if depth %}{% if last -%}
  54. {{ draw_tree(branch ~ 'l') }}
  55. {%- else -%}
  56. {{ draw_tree(branch ~ 't') }}
  57. {%- endif %}{% endif %}<a href="{{ forum.type|url(slug=forum.slug, forum=forum.id) }}">{{ forum.name }}</a></h3></td>
  58. </tr>
  59. {% for subforum in forum.subforums %}
  60. {% if depth %}
  61. {% if last %}
  62. {{ draw_forum(subforum, (depth + 1), (branch ~ 's'), loop.last) }}
  63. {% else %}
  64. {{ draw_forum(subforum, (depth + 1), (branch ~ 'i'), loop.last) }}
  65. {% endif %}
  66. {% else %}
  67. {{ draw_forum(subforum, (depth + 1), '', loop.last) }}
  68. {% endif %}
  69. {% endfor %}
  70. {% endmacro %}
  71. {% macro draw_tree(branch) %}
  72. {% for item in branch %}
  73. <span class="tree-{{ item }}"><span></span></span>
  74. {% endfor %}
  75. {% endmacro %}