on master help sign in
Merge branch 'master' of https://github.com/asciimoo/searx into filtron
1fc0e9dMarkus Heiser
searx/settings.yml+6
@@ -24,6 +24,12 @@ ui:
24 default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section
24 default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section
25 theme_args :
25 theme_args :
26 oscar_style : logicodev # default style of oscar
26 oscar_style : logicodev # default style of oscar
27+# categories_order :
28+# - general
29+# - files
30+# - map
31+# - it
32+# - science
27
33
28# searx supports result proxification using an external service: https://github.com/asciimoo/morty
34# searx supports result proxification using an external service: https://github.com/asciimoo/morty
29# uncomment below section if you have running morty proxy
35# uncomment below section if you have running morty proxy
searx/templates/courgette/base.html+1−1
@@ -29,7 +29,7 @@
29 searx.autocompleter = {% if autocomplete %}true{% else %}false{% endif %};
29 searx.autocompleter = {% if autocomplete %}true{% else %}false{% endif %};
30 </script>
30 </script>
31 </head>
31 </head>
32− <body>
32+ <body class="{{ endpoint }}_endpoint" >
33 <div id="container">
33 <div id="container">
34 {% block content %}
34 {% block content %}
35 {% endblock %}
35 {% endblock %}
searx/templates/legacy/base.html+1−1
@@ -20,7 +20,7 @@
20 <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
20 <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
21 {% endblock %}
21 {% endblock %}
22 </head>
22 </head>
23− <body>
23+ <body class="{{ endpoint }}_endpoint" >
24 <div id="container">
24 <div id="container">
25 {% block content %}
25 {% block content %}
26 {% endblock %}
26 {% endblock %}
searx/templates/oscar/base.html+1−1
@@ -47,7 +47,7 @@
47 </style>
47 </style>
48 </noscript>
48 </noscript>
49</head>
49</head>
50−<body>
50+<body class="{{ endpoint }}_endpoint" >
51 {% include 'oscar/navbar.html' %}
51 {% include 'oscar/navbar.html' %}
52
52
53 <div class="container">
53 <div class="container">
searx/templates/simple/base.html+1−1
@@ -32,7 +32,7 @@
32 {% endblock %}
32 {% endblock %}
33 <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" />
33 <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" />
34</head>
34</head>
35−<body>
35+<body class="{{ endpoint }}_endpoint" >
36 <main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}">
36 <main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}">
37 {% if errors %}
37 {% if errors %}
38 <div class="dialog-error" role="alert">
38 <div class="dialog-error" role="alert">
searx/webapp.py+16−9
@@ -355,17 +355,12 @@ def render(template_name, override_theme=None, **kwargs):
355 if (engine_name, category) not in disabled_engines)
355 if (engine_name, category) not in disabled_engines)
356
356
357 if 'categories' not in kwargs:
357 if 'categories' not in kwargs:
358− kwargs['categories'] = ['general']
358+ kwargs['categories'] = [x for x in
359− kwargs['categories'].extend(x for x in
359+ _get_ordered_categories()
360− sorted(categories.keys())
361− if x != 'general'
362− and x in enabled_categories)
360+ if x in enabled_categories]
363
361
364 if 'all_categories' not in kwargs:
362 if 'all_categories' not in kwargs:
365− kwargs['all_categories'] = ['general']
363+ kwargs['all_categories'] = _get_ordered_categories()
366− kwargs['all_categories'].extend(x for x in
367− sorted(categories.keys())
368− if x != 'general')
369
364
370 if 'selected_categories' not in kwargs:
365 if 'selected_categories' not in kwargs:
371 kwargs['selected_categories'] = []
366 kwargs['selected_categories'] = []
@@ -430,6 +425,7 @@ def render(template_name, override_theme=None, **kwargs):
430 kwargs['brand'] = brand
425 kwargs['brand'] = brand
431
426
432 kwargs['scripts'] = set()
427 kwargs['scripts'] = set()
428+ kwargs['endpoint'] = 'results' if 'q' in kwargs else request.endpoint
433 for plugin in request.user_plugins:
429 for plugin in request.user_plugins:
434 for script in plugin.js_dependencies:
430 for script in plugin.js_dependencies:
435 kwargs['scripts'].add(script)
431 kwargs['scripts'].add(script)
@@ -443,6 +439,17 @@ def render(template_name, override_theme=None, **kwargs):
443 '{}/{}'.format(kwargs['theme'], template_name), **kwargs)
439 '{}/{}'.format(kwargs['theme'], template_name), **kwargs)
444
440
445
441
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+
446@app.before_request
453@app.before_request
447def pre_request():
454def pre_request():
448 request.start_time = time()
455 request.start_time = time()