mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
[help] introduce searx.user_help.get_variables()
This commit is contained in:
parent
33ad043218
commit
6c5d41e708
1 changed files with 17 additions and 9 deletions
|
@ -48,14 +48,7 @@ def render(markdown: str, variables=Dict[str, str], filename='') -> HelpPage:
|
||||||
return HelpPage(title=first_line.strip('# '), content=content)
|
return HelpPage(title=first_line.strip('# '), content=content)
|
||||||
|
|
||||||
|
|
||||||
def initialize(app: flask.Flask):
|
def get_variables(app: flask.Flask):
|
||||||
"""
|
|
||||||
Renders the user documentation. Must be called after all Flask routes have been
|
|
||||||
registered, because the documentation might try to link to them with Flask's `url_for`.
|
|
||||||
|
|
||||||
We render the user documentation once on startup to improve performance.
|
|
||||||
"""
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
'brand.git_url': GIT_URL,
|
'brand.git_url': GIT_URL,
|
||||||
'brand.public_instances': get_setting('brand.public_instances'),
|
'brand.public_instances': get_setting('brand.public_instances'),
|
||||||
|
@ -71,13 +64,28 @@ def initialize(app: flask.Flask):
|
||||||
variables['stats'] = url_for('stats')
|
variables['stats'] = url_for('stats')
|
||||||
variables['search'] = url_for('search')
|
variables['search'] = url_for('search')
|
||||||
|
|
||||||
|
return variables
|
||||||
|
|
||||||
|
|
||||||
|
def initialize(app: flask.Flask):
|
||||||
|
"""
|
||||||
|
Renders the user documentation. Must be called after all Flask routes have been
|
||||||
|
registered, because the documentation might try to link to them with Flask's `url_for`.
|
||||||
|
|
||||||
|
We render the user documentation once on startup to improve performance.
|
||||||
|
"""
|
||||||
|
|
||||||
|
variables = get_variables(app)
|
||||||
|
|
||||||
for pagename in _TOC:
|
for pagename in _TOC:
|
||||||
filename = 'help/en/' + pagename + '.md'
|
filename = 'help/en/' + pagename + '.md'
|
||||||
file_content = pkg_resources.resource_string(__name__, filename).decode()
|
file_content = pkg_resources.resource_string(__name__, filename).decode()
|
||||||
|
|
||||||
if pagename == 'about':
|
if pagename == 'about':
|
||||||
try:
|
try:
|
||||||
file_content += pkg_resources.resource_string(__name__, 'templates/__common__/aboutextend.html').decode()
|
file_content += pkg_resources.resource_string(
|
||||||
|
__name__, 'templates/__common__/aboutextend.html'
|
||||||
|
).decode()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
PAGES[pagename] = render(file_content, variables, filename=filename)
|
PAGES[pagename] = render(file_content, variables, filename=filename)
|
||||||
|
|
Loading…
Add table
Reference in a new issue