on master help sign in
Merge pull request #61 from matejc/optional_search_get

Optional search get

commit44d3af9fb2482cd0df1a8ababbe2fdf27ab33172 authorAdam Tauber <asciimoo@gmail.com> dateTue 8 Apr 2014, 17:51 (13 years ago) parentd2f89f04519de9
5 files changed+30−6
searx/templates/preferences.html+9 searx/templates/results.html+4−4 searx/templates/search.html+1−1 searx/webapp.py+7 versions.cfg+9−1
searx/templates/preferences.html+9
@@ -43,6 +43,15 @@
4343 </select>
4444 </p>
4545 </fieldset>
46+ <fieldset>
47+ <legend>{{ _('Method') }}</legend>
48+ <p>
49+ <select name='method'>
50+ <option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option>
51+ <option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option>
52+ </select>
53+ </p>
54+ </fieldset>
4655 <fieldset>
4756 <legend>{{ _('Currently used search engines') }}</legend>
4857
searx/templates/results.html+4−4
@@ -10,7 +10,7 @@
1010 {% if suggestions %}
1111 <div id="suggestions"><span>{{ _('Suggestions') }}</span>
1212 {% for suggestion in suggestions %}
13− <form method="post" action="{{ url_for('index') }}">
13+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
1414 <input type="hidden" name="q" value="{{ suggestion }}">
1515 <input type="submit" value="{{ suggestion }}" />
1616 </form>
@@ -25,7 +25,7 @@
2525 <div id="apis">
2626 {{ _('Download results') }}
2727 {% for output_type in ('csv', 'json', 'rss') %}
28− <form method="post" action="{{ url_for('index') }}">
28+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
2929 <div class="left">
3030 <input type="hidden" name="q" value="{{ q }}" />
3131 <input type="hidden" name="format" value="{{ output_type }}" />
@@ -52,7 +52,7 @@
5252 {% if paging %}
5353 <div id="pagination">
5454 {% if pageno > 1 %}
55− <form method="post" action="{{ url_for('index') }}">
55+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
5656 <div class="left">
5757 <input type="hidden" name="q" value="{{ q }}" />
5858 {% for category in selected_categories %}
@@ -63,7 +63,7 @@
6363 </div>
6464 </form>
6565 {% endif %}
66− <form method="post" action="{{ url_for('index') }}">
66+ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
6767 <div class="left">
6868 {% for category in selected_categories %}
6969 <input type="hidden" name="category_{{ category }}" value="1"/>
searx/templates/search.html+1−1
@@ -1,4 +1,4 @@
1−<form method="post" action="{{ url_for('index') }}" id="search_form">
1+<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form">
22 <div id="search_wrapper">
33 <input type="text" placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" autocomplete="off" {% if q %}value="{{ q }}"{% endif %}/>
44 <input type="submit" value="search" id="search_submit" />
searx/webapp.py+7
@@ -123,6 +123,8 @@ def render(template_name, **kwargs):
123123 if not 'autocomplete' in kwargs:
124124 kwargs['autocomplete'] = autocomplete
125125
126+ kwargs['method'] = request.cookies.get('method', 'POST')
127+
126128 return render_template(template_name, **kwargs)
127129
128130
@@ -291,6 +293,7 @@ def preferences():
291293 selected_categories = []
292294 locale = None
293295 autocomplete = ''
296+ method = 'POST'
294297 for pd_name, pd in request.form.items():
295298 if pd_name.startswith('category_'):
296299 category = pd_name[9:]
@@ -305,6 +308,8 @@ def preferences():
305308 pd in (x[0] for
306309 x in language_codes)):
307310 lang = pd
311+ elif pd_name == 'method':
312+ method = pd
308313 elif pd_name.startswith('engine_'):
309314 engine_name = pd_name.replace('engine_', '', 1)
310315 if engine_name in engines:
@@ -344,6 +349,8 @@ def preferences():
344349 max_age=cookie_max_age
345350 )
346351
352+ resp.set_cookie('method', method, max_age=cookie_max_age)
353+
347354 return resp
348355 return render('preferences.html',
349356 locales=settings['locales'],
versions.cfg+9−1
@@ -1,4 +1,5 @@
11[versions]
2+Babel = 1.3
23Flask = 0.10.1
34Flask-Babel = 0.9
45Jinja2 = 2.7.2
@@ -14,9 +15,11 @@ docutils = 0.11
1415flake8 = 2.1.0
1516itsdangerous = 0.23
1617mccabe = 0.2.1
18+mock = 1.0.1
1719pep8 = 1.4.6
1820plone.testing = 4.0.8
1921pyflakes = 0.7.3
22+pytz = 2013b
2023pyyaml = 3.10
2124requests = 2.2.0
2225robotframework-debuglibrary = 0.3
@@ -24,6 +27,7 @@ robotframework-httplibrary = 0.4.2
2427robotframework-selenium2library = 1.5.0
2528robotsuite = 1.4.2
2629selenium = 2.39.0
30+speaklater = 1.3
2731unittest2 = 0.5.1
2832waitress = 0.8.8
2933zc.recipe.testrunner = 2.0.0
@@ -72,7 +76,7 @@ setuptools = 2.1
7276
7377# Required by:
7478# zope.testrunner==4.4.1
75−six = 1.5.2
79+six = 1.6.1
7680
7781# Required by:
7882# collective.recipe.omelette==0.16
@@ -93,3 +97,7 @@ zope.testing = 4.1.2
9397# Required by:
9498# zc.recipe.testrunner==2.0.0
9599zope.testrunner = 4.4.1
100+
101+# Required by:
102+# searx==0.3.0
103+python-dateutil = 2.2