search_result.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. {% set page_title = _("Search") %}
  2. {% extends theme("layout.html") %}
  3. {% block content %}
  4. {% from theme('macros.html') import render_pagination, group_field, topic_pages %}
  5. <ul class="breadcrumb">
  6. <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
  7. <li class="active">{% trans %}Search{% endtrans %}</li>
  8. </ul>
  9. {% if result['post'] %}
  10. <h3>{% trans %}Posts{% endtrans %}</h3>
  11. <table class="table table-bordered">
  12. <tbody>
  13. {% for post in result['post'].all() %}
  14. <tr>
  15. <td>
  16. <table class="table table-borderless">
  17. <tr>
  18. {% if post.user_id %}
  19. {% if post.user.avatar %}
  20. <td width="1">
  21. <img src="{{ post.user.avatar }}" alt="Avatar" height="100" width="100">
  22. </td>
  23. {% endif %}
  24. <td>
  25. <a href="{{ post.user.url }}">
  26. <span style="font-weight:bold">{{ post.user.username }}</span> <!-- TODO: Implement userstyles -->
  27. </a>
  28. {%- if post.user|is_online %}
  29. <span class="label label-success">Online</span>
  30. {%- else %}
  31. <span class="label label-default">Offline</span>
  32. {%- endif %}
  33. <div class="profile primary-group">
  34. {{ post.user.primary_group.name }}
  35. </div>
  36. </td>
  37. <td class="pull-right">
  38. {% trans %}Posts{% endtrans %}: {{ post.user.post_count }}<br />
  39. {% trans %}Registered since{% endtrans %}: {{ post.user.date_joined|format_date('%b %d %Y') }}<br />
  40. </td>
  41. {% else %}
  42. <td>
  43. <strong>{{ post.username }}</strong>
  44. <br />
  45. {% trans %}Guest{% endtrans %}
  46. </td>
  47. {% endif %}
  48. </tr>
  49. </table>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td>
  54. <div class="post_body" id="pid{{ post.id }}">
  55. {% autoescape false %}
  56. {{ post.content|markup }}
  57. {% endautoescape %}
  58. </div>
  59. </td>
  60. </tr>
  61. {% else %}
  62. <tr>
  63. <td>{% trans %}No posts found matching your search criteria.{% endtrans %}</td>
  64. </tr>
  65. {% endfor %}
  66. </tbody>
  67. </table>
  68. {% endif %}
  69. {% if result['user'] %}
  70. <h3>{% trans %}Users{% endtrans %}</h3>
  71. <table class="table table-bordered">
  72. <thead>
  73. <tr>
  74. <th>#</th>
  75. <th>{% trans %}Username{% endtrans %}</th>
  76. <th>{% trans %}Posts{% endtrans %}</th>
  77. <th>{% trans %}Date registered{% endtrans %}</th>
  78. <th>{% trans %}Group{% endtrans %}</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. {% for user in result['user'].all() %}
  83. <tr>
  84. <td>{{ user.id }}</td>
  85. <td><a href="{{ user.url }}">{{ user.username }}</a></td>
  86. <td>{{ user.post_count }}</td>
  87. <td>{{ user.date_joined|format_date('%b %d %Y') }}</td>
  88. <td>{{ user.primary_group.name }}</td>
  89. </tr>
  90. {% else %}
  91. <tr>
  92. <td colspan="5">{% trans %}No users found matching your search criteria.{% endtrans %}</td>
  93. </tr>
  94. {% endfor %}
  95. </tbody>
  96. </table>
  97. {% endif %}
  98. {% if result['topic'] %}
  99. <h3>{% trans %}Topics{% endtrans %}</h3>
  100. <table class="table table-bordered">
  101. <thead>
  102. <tr>
  103. <th colspan="2">{% trans %}Topic{% endtrans %}</th>
  104. <th>{% trans %}Posts{% endtrans %}</th>
  105. <th>{% trans %}Views{% endtrans %}</th>
  106. <th>{% trans %}Last Post{% endtrans %}</th>
  107. </tr>
  108. </thead>
  109. <tbody>
  110. {% for topic in result['topic'].all() %}
  111. <tr>
  112. <td width="4%">
  113. {% if topic.locked %}
  114. <span class="fa fa-locked" style="font-size: 2em"></span>
  115. {% else %}
  116. <span class="fa fa-comment-o" style="font-size: 2em"></span>
  117. {% endif %}
  118. </td>
  119. <td>
  120. <div>
  121. <a href="{{ topic.url }}">{{ topic.title }}</a>
  122. <!-- Topic Pagination -->
  123. {{ topic_pages(topic, flaskbb_config["POSTS_PER_PAGE"]) }}
  124. <br />
  125. <small>
  126. {% trans %}by{% endtrans %}
  127. {% if topic.user_id %}
  128. <a href="{{ topic.user.url }}">{{ topic.user.username }}</a>
  129. {% else %}
  130. {{ topic.username }}
  131. {% endif %}
  132. </small>
  133. </div>
  134. </td>
  135. <td>
  136. {{ topic.post_count }}
  137. </td>
  138. <td>
  139. {{ topic.views }}
  140. </td>
  141. <td>
  142. <a href="{{ topic.last_post.url }}">{{ topic.last_post.date_created|time_since }}</a><br />
  143. <small>
  144. {% trans %}by{% endtrans %}
  145. {% if topic.last_post.user_id %}
  146. <a href="{{ topic.last_post.user.url }}">{{ topic.last_post.user.username }}</a>
  147. {% else %}
  148. {{ topic.last_post.username }}
  149. {% endif %}
  150. </small>
  151. </td>
  152. </tr>
  153. {% else %}
  154. <tr>
  155. <td colspan="5">{% trans %}No topics found matching your search criteria.{% endtrans %}</td>
  156. </tr>
  157. {% endfor %}
  158. </tbody>
  159. </table>
  160. {% endif %}
  161. {% if result['forum'] %}
  162. <h3>{% trans %}Forums{% endtrans %}</h3>
  163. <table class="table table-bordered">
  164. <thead class="categoryhead">
  165. <tr>
  166. <th colspan="2"><strong>{% trans %}Forum{% endtrans %}</strong></th>
  167. <th width="85" align="center" style="white-space: nowrap"><strong>{% trans %}Topics{% endtrans %}</strong></th>
  168. <th width="85" align="center" style="white-space: nowrap"><strong>{% trans %}Posts{% endtrans %}</strong></th>
  169. <th width="200" align="center" style="white-space: nowrap"><strong>{% trans %}Last Post{% endtrans %}</strong></th>
  170. </tr>
  171. </thead>
  172. <tbody class="forumbody">
  173. {% for forum in result['forum'].all() %}
  174. <tr>
  175. <td align="center" valign="center" width="4%">
  176. {% if forum.external %}
  177. <span class="fa fa-external-link" style="font-size: 2em"></span>
  178. </td>
  179. <td valign="top">
  180. <strong><a href="{{ forum.external }}">{{ forum.title }}</a></strong>
  181. <div class="forum-description">
  182. {% autoescape false %}
  183. {{ forum.description|markup }}
  184. {% endautoescape %}
  185. </div>
  186. </td>
  187. <td valign="top" align="center" style="white-space: nowrap">-</td>
  188. <td valign="top" align="center" style="white-space: nowrap">-</td>
  189. <td valign="top" align="right" style="white-space: nowrap">-</td>
  190. <!-- End external -->
  191. {% else %}
  192. {% if forum.locked %}
  193. <span class="fa fa-lock" style="font-size: 2em"></span>
  194. {% else %}
  195. <span class="fa fa-comments-o" style="font-size: 2em"></span>
  196. {% endif %}
  197. </td>
  198. <td valign="top">
  199. <strong><a href="{{ forum.url }}">{{ forum.title }}</a></strong>
  200. <div class="forum-description">
  201. {% autoescape false %}
  202. {{ forum.description|markup }}
  203. {% endautoescape %}
  204. {% if forum.show_moderators %}
  205. <div class="forum-moderators">
  206. {% trans %}Moderators{% endtrans %}:
  207. {% for moderator in forum.moderators %}
  208. <a href="{{ url_for('user.profile', username=moderator.username) }}">{{ moderator.username }}</a>{% if not loop.last %}, {% endif %}
  209. {% endfor %}
  210. </div>
  211. {% endif %}
  212. </div>
  213. </td>
  214. <td valign="top" align="center" style="white-space: nowrap">{{ forum.topic_count }}</td>
  215. <td valign="top" align="center" style="white-space: nowrap">{{ forum.post_count }}</td>
  216. <td valign="top" align="right" style="white-space: nowrap">
  217. {% if forum.last_post_id %}
  218. <a href="{{ forum.last_post.url }}" title="{{ forum.last_post.topic.title }}">
  219. <strong>{{ forum.last_post.topic.title|crop_title }}</strong>
  220. </a>
  221. <br />
  222. {{ forum.last_post.date_created|time_since }}<br />
  223. {% trans %}by{% endtrans %}
  224. {% if forum.last_post.user_id %}
  225. <a href="{{ url_for('user.profile', username=forum.last_post.user.username) }}">{{ forum.last_post.user.username }}</a>
  226. {% else %}
  227. {{ forum.last_post.username }}
  228. {% endif %}
  229. {% else %}
  230. {% trans %}No posts.{% endtrans %}
  231. {% endif %}
  232. {% endif %}
  233. </td>
  234. </tr>
  235. {% else %}
  236. <tr>
  237. <td colspan="5">
  238. {% trans %}No forums found matching your search criteria.{% endtrans %}
  239. </td>
  240. </tr>
  241. {% endfor %}
  242. </tbody>
  243. </table>
  244. {% endif %}
  245. {% endblock %}