forked from zaclys/searxng
Merge branch 'master' of https://github.com/asciimoo/searx into filtron
This commit is contained in:
commit
26b85659c0
3 changed files with 43 additions and 5 deletions
|
|
@ -25,5 +25,29 @@
|
|||
{% if r.pubdate %}<pubDate>{{ r.pubdate }}</pubDate>{% endif %}
|
||||
</item>
|
||||
{% endfor %}
|
||||
{% if answers %}
|
||||
{% for a in answers %}
|
||||
<item>
|
||||
<title>{{ a }}</title>
|
||||
<type>answer</type>
|
||||
</item>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if corrections %}
|
||||
{% for a in corrections %}
|
||||
<item>
|
||||
<title>{{ a }}</title>
|
||||
<type>correction</type>
|
||||
</item>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if suggestions %}
|
||||
{% for a in suggestions %}
|
||||
<item>
|
||||
<title>{{ a }}</title>
|
||||
<type>suggestion</type>
|
||||
</item>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</channel>
|
||||
</rss>
|
||||
|
|
|
|||
|
|
@ -626,20 +626,34 @@ def index():
|
|||
mimetype='application/json')
|
||||
elif output_format == 'csv':
|
||||
csv = UnicodeWriter(StringIO())
|
||||
keys = ('title', 'url', 'content', 'host', 'engine', 'score')
|
||||
keys = ('title', 'url', 'content', 'host', 'engine', 'score', 'type')
|
||||
csv.writerow(keys)
|
||||
for row in results:
|
||||
row['host'] = row['parsed_url'].netloc
|
||||
row['type'] = 'result'
|
||||
csv.writerow([row.get(key, '') for key in keys])
|
||||
for a in result_container.answers:
|
||||
row = {'title': a, 'type': 'answer'}
|
||||
csv.writerow([row.get(key, '') for key in keys])
|
||||
for a in result_container.suggestions:
|
||||
row = {'title': a, 'type': 'suggestion'}
|
||||
csv.writerow([row.get(key, '') for key in keys])
|
||||
for a in result_container.corrections:
|
||||
row = {'title': a, 'type': 'correction'}
|
||||
csv.writerow([row.get(key, '') for key in keys])
|
||||
csv.stream.seek(0)
|
||||
response = Response(csv.stream.read(), mimetype='application/csv')
|
||||
cont_disp = 'attachment;Filename=searx_-_{0}.csv'.format(search_query.query)
|
||||
cont_disp = 'attachment;Filename=searx_-_{0}.csv'.format(search_query.query.decode('utf-8'))
|
||||
response.headers.add('Content-Disposition', cont_disp)
|
||||
return response
|
||||
elif output_format == 'rss':
|
||||
print(results)
|
||||
response_rss = render(
|
||||
'opensearch_response_rss.xml',
|
||||
results=results,
|
||||
answers=result_container.answers,
|
||||
corrections=result_container.corrections,
|
||||
suggestions=result_container.suggestions,
|
||||
q=request.form['q'],
|
||||
number_of_results=number_of_results,
|
||||
base_url=get_base_url(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue