diff options
author | Alexandre Flament <alex@al-f.net> | 2019-08-02 13:50:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-02 13:50:51 +0200 |
commit | 72029d27ded8d93ab891c616d6bffbe8d3a67dd2 (patch) | |
tree | 135388ae0dbd97abe3855745ba627c2ab181e975 /searx/templates | |
parent | 2179079a9173b33b81e1084fc1e8e181c19ef8e9 (diff) | |
download | searxng-72029d27ded8d93ab891c616d6bffbe8d3a67dd2.tar.gz searxng-72029d27ded8d93ab891c616d6bffbe8d3a67dd2.zip |
[enh] Add timeout limit per request (#1640)
The new url parameter "timeout_limit" set timeout limit defined in second.
Example "timeout_limit=1.5" means the timeout limit is 1.5 seconds.
In addition, the query can start with <[number] to set the timeout limit.
For number between 0 and 99, the unit is the second :
Example: "<30 searx" means the timeout limit is 3 seconds
For number above 100, the unit is the millisecond:
Example: "<850 searx" means the timeout is 850 milliseconds.
In addition, there is a new optional setting: outgoing.max_request_timeout.
If not set, the user timeout can't go above searx configuration (as before: the max timeout of selected engine for a query).
If the value is set, the user can set a timeout between 0 and max_request_timeout using
<[number] or timeout_limit query parameter.
Related to #1077
Updated version of PR #1413 from @isj-privacore
Diffstat (limited to 'searx/templates')
-rw-r--r-- | searx/templates/oscar/results.html | 1 | ||||
-rw-r--r-- | searx/templates/simple/infobox.html | 5 | ||||
-rw-r--r-- | searx/templates/simple/results.html | 12 | ||||
-rw-r--r-- | searx/templates/simple/search.html | 1 |
4 files changed, 16 insertions, 3 deletions
diff --git a/searx/templates/oscar/results.html b/searx/templates/oscar/results.html index f712e5779..ce557daf9 100644 --- a/searx/templates/oscar/results.html +++ b/searx/templates/oscar/results.html @@ -5,6 +5,7 @@ <input type="hidden" name="pageno" value="{{ pageno }}" />
<input type="hidden" name="time_range" value="{{ time_range }}" />
<input type="hidden" name="language" value="{{ current_language }}" />
+ <input type="hidden" name="timeout_limit" value="{{ timeout_limit }}" />
{%- endmacro %}
{%- macro search_url() %}{{ base_url }}?q={{ q|urlencode }}{% if selected_categories %}&categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&pageno={{ pageno }}{% endif %}{% if time_range %}&time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&language={{ current_language }}{% endif %}{% endmacro -%}
diff --git a/searx/templates/simple/infobox.html b/searx/templates/simple/infobox.html index d99806ac4..50b568919 100644 --- a/searx/templates/simple/infobox.html +++ b/searx/templates/simple/infobox.html @@ -36,6 +36,11 @@ {% for suggestion in topic.suggestions %} <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> <input type="hidden" name="q" value="{{ suggestion }}"> + <input type="hidden" name="time_range" value="{{ time_range }}"> + <input type="hidden" name="language" value="{{ current_language }}"> + <input type="hidden" name="safesearch" value="{{ safesearch }}"> + <input type="hidden" name="theme" value="{{ theme }}"> + {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %} <input type="submit" value="{{ suggestion }}" /> </form> {% endfor %} diff --git a/searx/templates/simple/results.html b/searx/templates/simple/results.html index a8e899e57..770eebe81 100644 --- a/searx/templates/simple/results.html +++ b/searx/templates/simple/results.html @@ -51,9 +51,11 @@ {% for suggestion in suggestions %} <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> <input type="hidden" name="q" value="{{ suggestion.url }}"> + <input type="hidden" name="time_range" value="{{ time_range }}"> <input type="hidden" name="language" value="{{ current_language }}"> <input type="hidden" name="safesearch" value="{{ safesearch }}"> <input type="hidden" name="theme" value="{{ theme }}"> + {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %} <input type="submit" class="suggestion" value="• {{ suggestion.title }}"> </form> {% endfor %} @@ -63,7 +65,7 @@ <div id="search_url"> <h4 class="title">{{ _('Search URL') }} :</h4> - <div class="selectable_url"><pre>{{ base_url }}?q={{ q|urlencode }}&language={{ current_language }}&time_range={{ time_range }}&safesearch={{ safesearch }}{% if pageno > 1 %}&pageno={{ pageno }}{% endif %}{% if selected_categories %}&categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}</pre></div> + <div class="selectable_url"><pre>{{ base_url }}?q={{ q|urlencode }}&language={{ current_language }}&time_range={{ time_range }}&safesearch={{ safesearch }}{% if pageno > 1 %}&pageno={{ pageno }}{% endif %}{% if selected_categories %}&categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if timeout_limit %}&timeout_limit={{ timeout_limit|urlencode }}{% endif %}</pre></div> </div> <div id="apis"> <h4 class="title">{{ _('Download results') }}</h4> @@ -79,6 +81,7 @@ <input type="hidden" name="language" value="{{ current_language }}"> <input type="hidden" name="safesearch" value="{{ safesearch }}"> <input type="hidden" name="format" value="{{ output_type }}"> + {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %} <input type="submit" value="{{ output_type }}"> </form> </div> @@ -97,6 +100,7 @@ <input type="hidden" name="language" value="{{ current_language }}"> <input type="hidden" name="safesearch" value="{{ safesearch }}"> <input type="hidden" name="theme" value="{{ theme }}"> + {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit }}" >{% endif %} <input type="submit" value="{{ correction }}"> </form> </div> @@ -134,7 +138,8 @@ <input type="hidden" name="language" value="{{ current_language }}" > <input type="hidden" name="safesearch" value="{{ safesearch }}" > <input type="hidden" name="theme" value="{{ theme }}" > - <button type="submit">{{ icon_small('chevron-left') }} {{ _('previous page') }}</button> + {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %} + <button type="submit">{{ icon_small('chevron-left') }} {{ _('previous page') }}</button> </div> </form> {% endif %} @@ -149,7 +154,8 @@ <input type="hidden" name="language" value="{{ current_language }}" > <input type="hidden" name="safesearch" value="{{ safesearch }}" > <input type="hidden" name="theme" value="{{ theme }}" > - <button type="submit">{{ _('next page') }} {{ icon_small('chevron-right') }}</button> + {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %} + <button type="submit">{{ _('next page') }} {{ icon_small('chevron-right') }}</button> </div> </form> </nav> diff --git a/searx/templates/simple/search.html b/searx/templates/simple/search.html index 9c4a99b68..e9023b420 100644 --- a/searx/templates/simple/search.html +++ b/searx/templates/simple/search.html @@ -14,4 +14,5 @@ {% include 'simple/categories.html' %} <input type="hidden" name="safesearch" value="{{ safesearch }}" > <input type="hidden" name="theme" value="{{ theme }}" > + {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %} </form> |