results.html 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. {% extends "simple/base.html" %}
  2. {% from 'simple/macros.html' import icon, icon_small %}
  3. {% macro engine_data_form(engine_data) -%}
  4. {% for engine_name, kv_data in engine_data.items() %}
  5. {% for k, v in kv_data.items() %}
  6. <input type="hidden" name="engine_data-{{ engine_name }}-{{ k|e }}" value="{{ v|e }}" />
  7. {% endfor %}
  8. {% endfor %}
  9. {%- endmacro %}
  10. {% block title %}{% if method == 'GET' %}{{- q|e -}} -{% endif %}{% endblock %}
  11. {% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}&amp;pageno={{ pageno }}&amp;time_range={{ time_range }}&amp;language={{ current_language }}&amp;safesearch={{ safesearch }}&amp;format=rss">{% endblock %}
  12. {% block content %}
  13. <nav id="linkto_preferences"><a href="{{ url_for('preferences') }}">{{ icon('navicon-round') }}</a></nav>
  14. {% include 'simple/search.html' %}
  15. {% if results and results|map(attribute='template')|unique|list|count == 1 %}
  16. {% set only_template = 'only_template_' + results[0]['template']|default('default')|replace('.html', '') %}
  17. {% else %}
  18. {% set unique_template = '' %}
  19. {% endif %}
  20. <div id="results" class="{{ only_template }}">
  21. {% if answers -%}
  22. <div id="answers"><h4 class="title">{{ _('Answers') }} : </h4>
  23. {%- for answer in answers.values() -%}
  24. <div class="answer">
  25. {% if answer.url %}
  26. <a href="{{ answer.url }}">{{ answer.answer }}</a>
  27. {% else %}
  28. <span>{{ answer.answer }}</span>
  29. {% endif %}
  30. </div>
  31. {%- endfor -%}
  32. </div>
  33. {%- endif %}
  34. <div id="sidebar">
  35. {% if number_of_results != '0' -%}
  36. <p id="result_count"><small>{{ _('Number of results') }}: {{ number_of_results }}</small></p>
  37. {%- endif %}
  38. {% if unresponsive_engines and results|length >= 1 %}
  39. <div class="dialog-error" role="alert">
  40. <p><strong>{{ _('Error!') }}</strong> {{ _('Engines cannot retrieve results') }}:</p>
  41. <p>{% for engine_name, error_type in unresponsive_engines %}
  42. {{- engine_name }} ({{- error_type -}}){% if not loop.last %}, {% endif %}
  43. {% endfor %}</p>
  44. </div>
  45. {% endif %}
  46. {% if infoboxes %}
  47. <div id="infoboxes">
  48. {% for infobox in infoboxes -%}
  49. {% include 'simple/infobox.html' %}
  50. {%- endfor %}
  51. </div>
  52. {% endif %}
  53. {% if suggestions %}
  54. <div id="suggestions">
  55. <h4 class="title">{{ _('Suggestions') }} : </h4>
  56. <div class="wrapper">
  57. {% for suggestion in suggestions %}
  58. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
  59. <input type="hidden" name="q" value="{{ suggestion.url }}">
  60. <input type="hidden" name="time_range" value="{{ time_range }}">
  61. <input type="hidden" name="language" value="{{ current_language }}">
  62. <input type="hidden" name="safesearch" value="{{ safesearch }}">
  63. <input type="hidden" name="theme" value="{{ theme }}">
  64. {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %}
  65. <input type="submit" class="suggestion" value="&bull; {{ suggestion.title }}">
  66. </form>
  67. {% endfor %}
  68. </div>
  69. </div>
  70. {% endif %}
  71. <div id="search_url">
  72. <h4 class="title">{{ _('Search URL') }} :</h4>
  73. <div class="selectable_url"><pre>{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&amp;language={{ current_language }}&amp;time_range={{ time_range }}&amp;safesearch={{ safesearch }}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if timeout_limit %}&amp;timeout_limit={{ timeout_limit|urlencode }}{% endif %}</pre></div>
  74. </div>
  75. <div id="apis">
  76. <h4 class="title">{{ _('Download results') }}</h4>
  77. {% for output_type in ('csv', 'json', 'rss') %}
  78. <div class="left">
  79. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
  80. <input type="hidden" name="q" value="{{ q|e }}">
  81. {% for category in selected_categories %}
  82. <input type="hidden" name="category_{{ category }}" value="1">
  83. {% endfor %}
  84. <input type="hidden" name="pageno" value="{{ pageno }}">
  85. <input type="hidden" name="time_range" value="{{ time_range }}">
  86. <input type="hidden" name="language" value="{{ current_language }}">
  87. <input type="hidden" name="safesearch" value="{{ safesearch }}">
  88. <input type="hidden" name="format" value="{{ output_type }}">
  89. {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %}
  90. <input type="submit" value="{{ output_type }}">
  91. </form>
  92. </div>
  93. {% endfor %}
  94. </div>
  95. </div>
  96. {% if corrections %}
  97. <div id="corrections">
  98. <h4>{{ _('Try searching for:') }}</h4>
  99. {% for correction in corrections %}
  100. <div class="left">
  101. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" role="navigation">
  102. <input type="hidden" name="q" value="{{ correction.url }}">
  103. <input type="hidden" name="time_range" value="{{ time_range }}">
  104. <input type="hidden" name="language" value="{{ current_language }}">
  105. <input type="hidden" name="safesearch" value="{{ safesearch }}">
  106. <input type="hidden" name="theme" value="{{ theme }}">
  107. {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit }}" >{% endif %}
  108. <input type="submit" value="{{ correction.title }}">
  109. </form>
  110. </div>
  111. {% endfor %}
  112. </div>
  113. {% endif %}
  114. <div id="urls">
  115. {% for result in results %}
  116. {% set index = loop.index %}
  117. {% if result['template'] %}
  118. {% include get_result_template('simple', result['template']) %}
  119. {% else %}
  120. {% include 'simple/result_templates/default.html' %}
  121. {% endif %}
  122. {% endfor %}
  123. {% if not results and not answers %}
  124. {% include 'simple/messages/no_results.html' %}
  125. {% endif %}
  126. </div>
  127. <div id="backToTop">
  128. <a href="#">{{ icon_small('chevron-up') }}</a>
  129. </div>
  130. {% if paging %}
  131. <nav id="pagination">
  132. {% if pageno > 1 %}
  133. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
  134. <div class="{% if rtl %}right{% else %}left{% endif %}">
  135. <input type="hidden" name="q" value="{{ q|e }}" >
  136. {{- engine_data_form(engine_data) -}}
  137. {% for category in selected_categories %}
  138. <input type="hidden" name="category_{{ category }}" value="1" >
  139. {% endfor %}
  140. <input type="hidden" name="pageno" value="{{ pageno-1 }}" >
  141. <input type="hidden" name="time_range" value="{{ time_range }}" >
  142. <input type="hidden" name="language" value="{{ current_language }}" >
  143. <input type="hidden" name="safesearch" value="{{ safesearch }}" >
  144. <input type="hidden" name="theme" value="{{ theme }}" >
  145. {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %}
  146. <button type="submit">{{ icon_small('chevron-left') }} {{ _('previous page') }}</button>
  147. </div>
  148. </form>
  149. {% endif %}
  150. <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
  151. <div class="{% if rtl %}left{% else %}right{% endif %}">
  152. <input type="hidden" name="q" value="{{ q|e }}" >
  153. {{- engine_data_form(engine_data) -}}
  154. {% for category in selected_categories %}
  155. <input type="hidden" name="category_{{ category }}" value="1" >
  156. {% endfor %}
  157. <input type="hidden" name="pageno" value="{{ pageno+1 }}" >
  158. <input type="hidden" name="time_range" value="{{ time_range }}" >
  159. <input type="hidden" name="language" value="{{ current_language }}" >
  160. <input type="hidden" name="safesearch" value="{{ safesearch }}" >
  161. <input type="hidden" name="theme" value="{{ theme }}" >
  162. {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %}
  163. <button type="submit">{{ _('next page') }} {{ icon_small('chevron-right') }}</button>
  164. </div>
  165. </form>
  166. </nav>
  167. {% endif %}
  168. </div>
  169. {% endblock %}