on master help sign in
Merge branch 'master' of https://github.com/asciimoo/searx into filtron
commit1fc0e9ddc59ab5217a08c36561791fbf0b96190a authorMarkus Heiser <markus.heiser@darmarit.de> dateThu 4 Jun 2020, 21:22 (6 years ago) parent2b2a882de1b08a
6 files changed+26−13
searx/settings.yml+6 searx/templates/courgette/base.html+1−1 searx/templates/legacy/base.html+1−1 searx/templates/oscar/base.html+1−1 searx/templates/simple/base.html+1−1 searx/webapp.py+16−9
searx/settings.yml+6
@@ -24,6 +24,12 @@ ui:
2424 default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section
2525 theme_args :
2626 oscar_style : logicodev # default style of oscar
27+# categories_order :
28+# - general
29+# - files
30+# - map
31+# - it
32+# - science
2733
2834# searx supports result proxification using an external service: https://github.com/asciimoo/morty
2935# uncomment below section if you have running morty proxy
searx/templates/courgette/base.html+1−1
@@ -29,7 +29,7 @@
2929 searx.autocompleter = {% if autocomplete %}true{% else %}false{% endif %};
3030 </script>
3131 </head>
32− <body>
32+ <body class="{{ endpoint }}_endpoint" >
3333 <div id="container">
3434 {% block content %}
3535 {% endblock %}
searx/templates/legacy/base.html+1−1
@@ -20,7 +20,7 @@
2020 <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
2121 {% endblock %}
2222 </head>
23− <body>
23+ <body class="{{ endpoint }}_endpoint" >
2424 <div id="container">
2525 {% block content %}
2626 {% endblock %}
searx/templates/oscar/base.html+1−1
@@ -47,7 +47,7 @@
4747 </style>
4848 </noscript>
4949</head>
50−<body>
50+<body class="{{ endpoint }}_endpoint" >
5151 {% include 'oscar/navbar.html' %}
5252
5353 <div class="container">
searx/templates/simple/base.html+1−1
@@ -32,7 +32,7 @@
3232 {% endblock %}
3333 <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" />
3434</head>
35−<body>
35+<body class="{{ endpoint }}_endpoint" >
3636 <main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}">
3737 {% if errors %}
3838 <div class="dialog-error" role="alert">
searx/webapp.py+16−9
@@ -355,17 +355,12 @@ def render(template_name, override_theme=None, **kwargs):
355355 if (engine_name, category) not in disabled_engines)
356356
357357 if 'categories' not in kwargs:
358− kwargs['categories'] = ['general']
359− kwargs['categories'].extend(x for x in
360− sorted(categories.keys())
361− if x != 'general'
362− and x in enabled_categories)
358+ kwargs['categories'] = [x for x in
359+ _get_ordered_categories()
360+ if x in enabled_categories]
363361
364362 if 'all_categories' not in kwargs:
365− kwargs['all_categories'] = ['general']
366− kwargs['all_categories'].extend(x for x in
367− sorted(categories.keys())
368− if x != 'general')
363+ kwargs['all_categories'] = _get_ordered_categories()
369364
370365 if 'selected_categories' not in kwargs:
371366 kwargs['selected_categories'] = []
@@ -430,6 +425,7 @@ def render(template_name, override_theme=None, **kwargs):
430425 kwargs['brand'] = brand
431426
432427 kwargs['scripts'] = set()
428+ kwargs['endpoint'] = 'results' if 'q' in kwargs else request.endpoint
433429 for plugin in request.user_plugins:
434430 for script in plugin.js_dependencies:
435431 kwargs['scripts'].add(script)
@@ -443,6 +439,17 @@ def render(template_name, override_theme=None, **kwargs):
443439 '{}/{}'.format(kwargs['theme'], template_name), **kwargs)
444440
445441
442+def _get_ordered_categories():
443+ ordered_categories = []
444+ if 'categories_order' not in settings['ui']:
445+ ordered_categories = ['general']
446+ ordered_categories.extend(x for x in sorted(categories.keys()) if x != 'general')
447+ return ordered_categories
448+ ordered_categories = settings['ui']['categories_order']
449+ ordered_categories.extend(x for x in sorted(categories.keys()) if x not in ordered_categories)
450+ return ordered_categories
451+
452+
446453@app.before_request
447454def pre_request():
448455 request.start_time = time()