forum_map.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 %}"><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></td>
  54. </tr>
  55. {% for subforum in forum.subforums %}
  56. {% if depth %}
  57. {% if last %}
  58. {{ draw_forum(subforum, (depth + 1), (branch ~ 's'), loop.last) }}
  59. {% else %}
  60. {{ draw_forum(subforum, (depth + 1), (branch ~ 'i'), loop.last) }}
  61. {% endif %}
  62. {% else %}
  63. {{ draw_forum(subforum, (depth + 1), '', loop.last) }}
  64. {% endif %}
  65. {% endfor %}
  66. {% endmacro %}
  67. {% macro draw_tree(branch) %}
  68. {% for item in branch %}
  69. <span class="tree-{{ item }}"><span></span></span>
  70. {% endfor %}
  71. {% endmacro %}