summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index ffe9b4da9..3bb29140a 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -124,6 +124,7 @@ app = Flask(
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
+app.jinja_env.add_extension('jinja2.ext.loopcontrols')
app.secret_key = settings['server']['secret_key']
if not searx_debug \
@@ -538,14 +539,16 @@ def index():
if output_format == 'html':
if 'content' in result and result['content']:
result['content'] = highlight_content(escape(result['content'][:1024]), search_query.query)
- result['title'] = highlight_content(escape(result['title'] or u''), search_query.query)
+ if 'title' in result and result['title']:
+ result['title'] = highlight_content(escape(result['title'] or u''), search_query.query)
else:
if result.get('content'):
result['content'] = html_to_text(result['content']).strip()
# removing html content and whitespace duplications
result['title'] = ' '.join(html_to_text(result['title']).strip().split())
- result['pretty_url'] = prettify_url(result['url'])
+ if 'url' in result:
+ result['pretty_url'] = prettify_url(result['url'])
# TODO, check if timezone is calculated right
if 'publishedDate' in result:
@@ -607,6 +610,12 @@ def index():
'title': suggestion
},
result_container.suggestions)
+
+ correction_urls = list(map(lambda correction: {
+ 'url': raw_text_query.changeSearchQuery(correction).getFullQuery(),
+ 'title': correction
+ },
+ result_container.corrections))
#
return render(
'results.html',
@@ -619,7 +628,7 @@ def index():
advanced_search=advanced_search,
suggestions=suggestion_urls,
answers=result_container.answers,
- corrections=result_container.corrections,
+ corrections=correction_urls,
infoboxes=result_container.infoboxes,
paging=result_container.paging,
unresponsive_engines=result_container.unresponsive_engines,