results.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. {% extends "oscar/base.html" %}
  2. {% macro search_form_attrs(pageno) -%}
  3. {%- for category in selected_categories -%}<input type="hidden" name="category_{{ category }}" value="1"/>{%- endfor -%}
  4. <input type="hidden" name="q" value="{{ q|e }}" />{{- "" -}}
  5. <input type="hidden" name="pageno" value="{{ pageno }}" />{{- "" -}}
  6. <input type="hidden" name="time_range" value="{{ time_range }}" />{{- "" -}}
  7. <input type="hidden" name="language" value="{{ current_language }}" />{{- "" -}}
  8. {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" />{% endif -%}
  9. {%- endmacro %}
  10. {%- macro search_url() %}{{ url_for('search', _external=True) }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}{% if time_range %}&amp;time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&amp;language={{ current_language }}{% endif %}{% endmacro -%}
  11. {% block title %}{{ q|e }} - {% endblock %}
  12. {% block meta %}{{" "}}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ search_url() }}&amp;format=rss">{% endblock %}
  13. {% block content %}
  14. {% include 'oscar/search.html' %}
  15. <div class="row">
  16. <div class="col-sm-4 col-sm-push-8" id="sidebar_results">
  17. {% if number_of_results != '0' -%}
  18. <p><small>{{ _('Number of results') }}: {{ number_of_results }}</small></p>
  19. {%- endif %}
  20. {% if unresponsive_engines and results|length >= 1 -%}
  21. <div class="alert alert-danger fade in" role="alert">
  22. <p>{{ _('Engines cannot retrieve results') }}:</p>
  23. {%- for engine_name, error_type in unresponsive_engines -%}
  24. {{- engine_name }} ({{ error_type }}){% if not loop.last %}, {% endif %}{{- "" -}}
  25. {%- endfor -%}
  26. </div>
  27. {%- endif %}
  28. {% if infoboxes -%}
  29. {% for infobox in infoboxes %}
  30. {% include 'oscar/infobox.html' %}{{- "\n\n" -}}
  31. {% endfor %}
  32. {%- endif %}
  33. {% if suggestions %}
  34. <div class="panel panel-default">
  35. <div class="panel-heading">
  36. <h4 class="panel-title">{{ _('Suggestions') }}</h4>
  37. </div>
  38. <div class="panel-body">
  39. {% for suggestion in suggestions %}
  40. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" role="navigation" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} suggestion_item">
  41. {% if current_language != 'all' %}
  42. <input type="hidden" name="language" value="{{ current_language }}">
  43. {% endif %}
  44. {% if time_range %}
  45. <input type="hidden" name="time_range" value="{{ time_range }}">
  46. {% endif %}
  47. <input type="hidden" name="q" value="{{ suggestion.url }}">
  48. <button type="submit" class="btn btn-default btn-xs">{{ suggestion.title }}</button>
  49. </form>
  50. {% endfor %}
  51. </div>
  52. </div>
  53. {%- endif %}
  54. <div class="panel panel-default hidden-xs">
  55. <div class="panel-heading">{{- "" -}}
  56. <h4 class="panel-title">{{ _('Links') }}</h4>{{- "" -}}
  57. </div>
  58. <div class="panel-body">
  59. <form role="form">{{- "" -}}
  60. <div class="form-group">{{- "" -}}
  61. <label for="search_url">{{ _('Search URL') }}</label>{{- "" -}}
  62. <input id="search_url" type="url" class="form-control select-all-on-click cursor-text" name="search_url" value="{{ search_url() }}" readonly>{{- "" -}}
  63. </div>{{- "" -}}
  64. </form>
  65. <label>{{ _('Download results') }}</label>
  66. <div class="clearfix"></div>
  67. {% for output_type in ('csv', 'json', 'rss') %}
  68. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} result_download">
  69. {{- search_form_attrs(pageno) -}}
  70. <input type="hidden" name="format" value="{{ output_type }}">{{- "" -}}
  71. <button type="submit" class="btn btn-default">{{ output_type }}</button>{{- "" -}}
  72. </form>
  73. {% endfor %}
  74. <div class="clearfix"></div>
  75. <br /><label><a href="{{ search_url() }}&amp;format=rss">{{ _('RSS subscription') }}</a></label>
  76. <div class="clearfix"></div>
  77. </div>
  78. </div>
  79. </div><!-- /#sidebar_results -->
  80. <div class="col-sm-8 col-sm-pull-4" id="main_results">
  81. <h1 class="sr-only">{{ _('Search results') }}</h1>
  82. {% if corrections -%}
  83. <div class="result">
  84. <div class="clearfix">
  85. <span class="result_header text-muted form-inline pull-left suggestion_item">{{ _('Try searching for:') }}</span>
  86. {% for correction in corrections -%}
  87. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" role="navigation" class="form-inline pull-left suggestion_item">{{- "" -}}
  88. {% if current_language != 'all' %}
  89. <input type="hidden" name="language" value="{{ current_language }}">
  90. {% endif %}
  91. {% if time_range %}
  92. <input type="hidden" name="time_range" value="{{ time_range }}">
  93. {% endif %}
  94. <input type="hidden" name="q" value="{{ correction.url }}">{{- "" -}}
  95. <button type="submit" class="btn btn-default btn-xs">{{ correction.title }}</button>{{- "" -}}
  96. </form>
  97. {% endfor %}
  98. </div>
  99. </div>
  100. {%- endif %}
  101. {% if answers -%}
  102. {%- for answer in answers.values() %}
  103. <div class="result well">
  104. {% if answer.url %}
  105. <a href="{{ answer.url }}">{{ answer.answer }}</a>
  106. {% else %}
  107. <span>{{ answer.answer }}</span>
  108. {% endif %}
  109. </div>
  110. {%- endfor %}
  111. {%- endif %}
  112. {% for result in results -%}
  113. <div class="result {% if result['template'] %}result-{{ result.template|replace('.html', '') }}{% else %}result-default{% endif %}{% for e in result.engines %} {{ e }}{% endfor %}">
  114. {%- set index = loop.index -%}
  115. {%- if result.template -%}
  116. {% include get_result_template('oscar', result['template']) %}
  117. {%- else -%}
  118. {% include 'oscar/result_templates/default.html' %}
  119. {%- endif -%}
  120. </div>
  121. {% endfor %}
  122. {% if not results and not answers -%}
  123. {% include 'oscar/messages/no_results.html' %}
  124. {% endif %}
  125. <div class="clearfix"></div>
  126. {% if paging -%}
  127. {% if rtl %}
  128. <div id="pagination">
  129. <div class="pull-left">{{- "" -}}
  130. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
  131. {{- search_form_attrs(pageno+1) -}}
  132. <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-backward"></span> {{ _('next page') }}</button>{{- "" -}}
  133. </form>{{- "" -}}
  134. </div>
  135. <div class="pull-right">{{- "" -}}
  136. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
  137. {{- search_form_attrs(pageno-1) -}}
  138. <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-forward"></span> {{ _('previous page') }}</button>{{- "" -}}
  139. </form>{{- "" -}}
  140. </div>
  141. </div><!-- /#pagination -->
  142. <div class="clearfix"></div>
  143. {% else %}
  144. <div id="pagination">
  145. <div class="pull-left">{{- "" -}}
  146. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
  147. {{- search_form_attrs(pageno-1) -}}
  148. <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-backward"></span> {{ _('previous page') }}</button>{{- "" -}}
  149. </form>{{- "" -}}
  150. </div>
  151. <div class="pull-right">{{- "" -}}
  152. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
  153. {{- search_form_attrs(pageno+1) -}}
  154. <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-forward"></span> {{ _('next page') }}</button>{{- "" -}}
  155. </form>{{- "" -}}
  156. </div>
  157. </div><!-- /#pagination -->
  158. <div class="clearfix"></div>
  159. {% endif %}
  160. {% endif %}
  161. </div><!-- /#main_results -->
  162. </div>
  163. {% endblock %}