mirror of https://github.com/searxng/searxng.git
[enh] category selection remember
This commit is contained in:
parent
247c9144f2
commit
83c39a565a
|
@ -6,4 +6,5 @@
|
|||
{{ category }}: <input type="checkbox" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>remember categories:<input type="checkbox" name="save" checked="checked" /></p>
|
||||
</form>
|
||||
|
|
|
@ -80,12 +80,14 @@ def index():
|
|||
selected_engines.extend(x.name for x in categories[ccateg])
|
||||
query = request.form['q'].encode('utf-8')
|
||||
results = search(query, request, selected_engines)
|
||||
remember_categs = True if 'save' in request.form else False
|
||||
if request.form.get('format') == 'json':
|
||||
# TODO HTTP headers
|
||||
return json.dumps({'query': query, 'results': results})
|
||||
template = render('results.html', results=results, q=query.decode('utf-8'), selected_categories=selected_categories)
|
||||
resp = make_response(template)
|
||||
resp.set_cookie('categories', ','.join(selected_categories))
|
||||
if remember_categs:
|
||||
resp.set_cookie('categories', ','.join(selected_categories))
|
||||
return resp
|
||||
return render('index.html')
|
||||
|
||||
|
|
Loading…
Reference in New Issue