forum_map.html 2.3 KB

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