diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2020-06-04 21:22:53 +0200 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarit.de> | 2020-06-04 21:22:53 +0200 |
| commit | 1fc0e9ddc59ab5217a08c36561791fbf0b96190a (patch) | |
| tree | ebc8d3012ca0ef1f0d18c5437e6e69bb76a72d9a | |
| parent | 2b2a882df046e9ee3bfae8a8f33ffc2484b603b5 (diff) | |
| parent | de1b08a941a6834a39159b9a2aa3ff3552df029f (diff) | |
Merge branch 'master' of https://github.com/asciimoo/searx into filtron
| -rw-r--r-- | searx/settings.yml | 6 | ||||
| -rw-r--r-- | searx/templates/courgette/base.html | 2 | ||||
| -rw-r--r-- | searx/templates/legacy/base.html | 2 | ||||
| -rw-r--r-- | searx/templates/oscar/base.html | 2 | ||||
| -rw-r--r-- | searx/templates/simple/base.html | 2 | ||||
| -rwxr-xr-x | searx/webapp.py | 25 |
6 files changed, 26 insertions, 13 deletions
diff --git a/searx/settings.yml b/searx/settings.yml index 2497a764b..8df151b14 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -24,6 +24,12 @@ ui: default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section theme_args : oscar_style : logicodev # default style of oscar +# categories_order : +# - general +# - files +# - map +# - it +# - science # searx supports result proxification using an external service: https://github.com/asciimoo/morty # uncomment below section if you have running morty proxy diff --git a/searx/templates/courgette/base.html b/searx/templates/courgette/base.html index 8e272585c..f4c61dac2 100644 --- a/searx/templates/courgette/base.html +++ b/searx/templates/courgette/base.html @@ -29,7 +29,7 @@ searx.autocompleter = {% if autocomplete %}true{% else %}false{% endif %}; </script> </head> - <body> + <body class="{{ endpoint }}_endpoint" > <div id="container"> {% block content %} {% endblock %} diff --git a/searx/templates/legacy/base.html b/searx/templates/legacy/base.html index da19741cb..21fe42e16 100644 --- a/searx/templates/legacy/base.html +++ b/searx/templates/legacy/base.html @@ -20,7 +20,7 @@ <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/> {% endblock %} </head> - <body> + <body class="{{ endpoint }}_endpoint" > <div id="container"> {% block content %} {% endblock %} diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index 5eb4462e4..cd3d23df5 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -47,7 +47,7 @@ </style> </noscript> </head> -<body> +<body class="{{ endpoint }}_endpoint" > {% include 'oscar/navbar.html' %} <div class="container"> diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html index 71df123ea..650ef771c 100644 --- a/searx/templates/simple/base.html +++ b/searx/templates/simple/base.html @@ -32,7 +32,7 @@ {% endblock %} <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" /> </head> -<body> +<body class="{{ endpoint }}_endpoint" > <main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}"> {% if errors %} <div class="dialog-error" role="alert"> diff --git a/searx/webapp.py b/searx/webapp.py index f3f5f21b8..2ba8ccfb8 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -355,17 +355,12 @@ def render(template_name, override_theme=None, **kwargs): if (engine_name, category) not in disabled_engines) if 'categories' not in kwargs: - kwargs['categories'] = ['general'] - kwargs['categories'].extend(x for x in - sorted(categories.keys()) - if x != 'general' - and x in enabled_categories) + kwargs['categories'] = [x for x in + _get_ordered_categories() + if x in enabled_categories] if 'all_categories' not in kwargs: - kwargs['all_categories'] = ['general'] - kwargs['all_categories'].extend(x for x in - sorted(categories.keys()) - if x != 'general') + kwargs['all_categories'] = _get_ordered_categories() if 'selected_categories' not in kwargs: kwargs['selected_categories'] = [] @@ -430,6 +425,7 @@ def render(template_name, override_theme=None, **kwargs): kwargs['brand'] = brand kwargs['scripts'] = set() + kwargs['endpoint'] = 'results' if 'q' in kwargs else request.endpoint for plugin in request.user_plugins: for script in plugin.js_dependencies: kwargs['scripts'].add(script) @@ -443,6 +439,17 @@ def render(template_name, override_theme=None, **kwargs): '{}/{}'.format(kwargs['theme'], template_name), **kwargs) +def _get_ordered_categories(): + ordered_categories = [] + if 'categories_order' not in settings['ui']: + ordered_categories = ['general'] + ordered_categories.extend(x for x in sorted(categories.keys()) if x != 'general') + return ordered_categories + ordered_categories = settings['ui']['categories_order'] + ordered_categories.extend(x for x in sorted(categories.keys()) if x not in ordered_categories) + return ordered_categories + + @app.before_request def pre_request(): request.start_time = time() |