mirror of https://github.com/searxng/searxng.git
[enh] preferences added
This commit is contained in:
parent
a3de9ba56c
commit
1df697305c
|
@ -124,29 +124,47 @@ def index():
|
||||||
response.headers.add('Content-Disposition', 'attachment;Filename=searx_-_{0}.csv'.format('_'.join(query.split())))
|
response.headers.add('Content-Disposition', 'attachment;Filename=searx_-_{0}.csv'.format('_'.join(query.split())))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
template = render('results.html'
|
return render('results.html'
|
||||||
,results=results
|
,results=results
|
||||||
,q=request_data['q']
|
,q=request_data['q']
|
||||||
,selected_categories=selected_categories
|
,selected_categories=selected_categories
|
||||||
,number_of_results=len(results)
|
,number_of_results=len(results)
|
||||||
,suggestions=suggestions
|
,suggestions=suggestions
|
||||||
)
|
)
|
||||||
resp = make_response(template)
|
|
||||||
resp.set_cookie('categories', ','.join(selected_categories))
|
|
||||||
|
|
||||||
return resp
|
|
||||||
|
|
||||||
@app.route('/about', methods=['GET'])
|
@app.route('/about', methods=['GET'])
|
||||||
def about():
|
def about():
|
||||||
global categories
|
global categories
|
||||||
return render('about.html', categs=categories.items())
|
return render('about.html', categs=categories.items())
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/preferences', methods=['GET', 'POST'])
|
||||||
|
def preferences():
|
||||||
|
|
||||||
|
if request.method=='POST':
|
||||||
|
selected_categories = []
|
||||||
|
for pd_name,pd in request.form.items():
|
||||||
|
if pd_name.startswith('category_'):
|
||||||
|
category = pd_name[9:]
|
||||||
|
if not category in categories:
|
||||||
|
continue
|
||||||
|
selected_categories.append(category)
|
||||||
|
if selected_categories:
|
||||||
|
template = render('preferences.html', selected_categories=selected_categories)
|
||||||
|
resp = make_response(template)
|
||||||
|
resp.set_cookie('categories', ','.join(selected_categories))
|
||||||
|
return resp
|
||||||
|
return render('preferences.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/stats', methods=['GET'])
|
@app.route('/stats', methods=['GET'])
|
||||||
def stats():
|
def stats():
|
||||||
global categories
|
global categories
|
||||||
stats = get_engines_stats()
|
stats = get_engines_stats()
|
||||||
return render('stats.html', stats=stats)
|
return render('stats.html', stats=stats)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/robots.txt', methods=['GET'])
|
@app.route('/robots.txt', methods=['GET'])
|
||||||
def robots():
|
def robots():
|
||||||
return Response("""User-agent: *
|
return Response("""User-agent: *
|
||||||
|
@ -155,6 +173,7 @@ Allow: /about
|
||||||
Disallow: /stats
|
Disallow: /stats
|
||||||
""", mimetype='text/plain')
|
""", mimetype='text/plain')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/opensearch.xml', methods=['GET'])
|
@app.route('/opensearch.xml', methods=['GET'])
|
||||||
def opensearch():
|
def opensearch():
|
||||||
global opensearch_xml
|
global opensearch_xml
|
||||||
|
|
Loading…
Reference in New Issue