forked from zaclys/searxng
[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 %} />
|
{{ category }}: <input type="checkbox" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
|
<p>remember categories:<input type="checkbox" name="save" checked="checked" /></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -80,11 +80,13 @@ def index():
|
||||||
selected_engines.extend(x.name for x in categories[ccateg])
|
selected_engines.extend(x.name for x in categories[ccateg])
|
||||||
query = request.form['q'].encode('utf-8')
|
query = request.form['q'].encode('utf-8')
|
||||||
results = search(query, request, selected_engines)
|
results = search(query, request, selected_engines)
|
||||||
|
remember_categs = True if 'save' in request.form else False
|
||||||
if request.form.get('format') == 'json':
|
if request.form.get('format') == 'json':
|
||||||
# TODO HTTP headers
|
# TODO HTTP headers
|
||||||
return json.dumps({'query': query, 'results': results})
|
return json.dumps({'query': query, 'results': results})
|
||||||
template = render('results.html', results=results, q=query.decode('utf-8'), selected_categories=selected_categories)
|
template = render('results.html', results=results, q=query.decode('utf-8'), selected_categories=selected_categories)
|
||||||
resp = make_response(template)
|
resp = make_response(template)
|
||||||
|
if remember_categs:
|
||||||
resp.set_cookie('categories', ','.join(selected_categories))
|
resp.set_cookie('categories', ','.join(selected_categories))
|
||||||
return resp
|
return resp
|
||||||
return render('index.html')
|
return render('index.html')
|
||||||
|
|
Loading…
Reference in New Issue