summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2022-03-13 22:15:27 +0100
committerAlexandre Flament <alex@al-f.net>2022-03-13 22:22:02 +0100
commit1157462ff9fc08504297e259356ccbefb339965f (patch)
treeb87c6f75cc657e1929fe32afa2b8fbc9f905c65d /searx/webapp.py
parent59100e852573cbc01b602b1637b0d4a02a863a9d (diff)
downloadsearxng-1157462ff9fc08504297e259356ccbefb339965f.tar.gz
searxng-1157462ff9fc08504297e259356ccbefb339965f.zip
Various change on PR 930
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-xsearx/webapp.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 5263aaf1b..5d3e7ebfd 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -383,6 +383,11 @@ def url_for_theme(endpoint: str, override_theme: Optional[str] = None, **values)
if file_hash:
values['filename'] = filename_with_theme
suffix = "?" + file_hash
+ if endpoint == 'info' and 'locale' not in values:
+ locale = request.preferences.get_value('locale')
+ if _INFO_PAGES.get_page(values['pagename'], locale) is None:
+ locale = _INFO_PAGES.locale_default
+ values['locale'] = locale
return url_for(endpoint, **values) + suffix
@@ -905,23 +910,30 @@ def about():
return redirect(url_for('info', pagename='about', locale=locale))
-_INFO_PAGES = infopage.InfoPageSet(infopage.MistletoePage)
+_INFO_PAGES = infopage.InfoPageSet()
@app.route('/info/<locale>/<pagename>', methods=['GET'])
def info(pagename, locale):
"""Render page of online user documentation"""
- locale = locale or request.preferences.get_value('locale')
page = _INFO_PAGES.get_page(pagename, locale)
if page is None:
- page = _INFO_PAGES.get_page(pagename)
- if page is None:
flask.abort(404)
+ def all_pages():
+ user_locale = request.preferences.get_value('locale')
+ for for_pagename, for_page in _INFO_PAGES.all_pages(user_locale):
+ for_locale = locale
+ if for_page is None:
+ # we are sure that for_pagename != pagename
+ for_page = _INFO_PAGES.get_page(for_pagename, _INFO_PAGES.locale_default)
+ for_locale = _INFO_PAGES.locale_default
+ yield for_pagename, for_page, for_locale
+
return render(
'info.html',
- all_pages=_INFO_PAGES.all_pages,
+ all_pages=all_pages(),
active_page=page,
active_pagename=pagename,
)