forum_map.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. <div class="header">
  33. <h2>{{ category.name }}</h2>
  34. </div>
  35. {% for forum in category.subforums%}
  36. {{ draw_forum(forum) }}
  37. {% endfor %}
  38. </div>
  39. {% endmacro %}
  40. {% macro draw_forum(forum, depth=0, branch='', last=false) %}
  41. <div class="{% if depth -%}
  42. forum-map-subforum
  43. {%- else -%}
  44. forum-map-forum
  45. {%- endif %}">
  46. <h3>{% if depth %}{% if last -%}
  47. {{ draw_tree(branch ~ 'l') }}
  48. {%- else -%}
  49. {{ draw_tree(branch ~ 't') }}
  50. {%- endif %}{% endif %} <a href="{{ forum.type|url(slug=forum.slug, forum=forum.id) }}">{{ forum.name }}</a></h3>
  51. </div>
  52. {% for subforum in forum.subforums %}
  53. {% if depth %}
  54. {% if last %}
  55. {{ draw_forum(subforum, (depth + 1), (branch ~ 's'), loop.last) }}
  56. {% else %}
  57. {{ draw_forum(subforum, (depth + 1), (branch ~ 'i'), loop.last) }}
  58. {% endif %}
  59. {% else %}
  60. {{ draw_forum(subforum, (depth + 1), '', loop.last) }}
  61. {% endif %}
  62. {% endfor %}
  63. {% endmacro %}
  64. {% macro draw_tree(branch) %}
  65. {% for item in branch %}
  66. <span class="tree-{{ item }}"><span></span></span>
  67. {% endfor %}
  68. {% endmacro %}