Repository: searx/searx

Issue:
Make different forms of search appear by default without having to click "advanced settings"
One of the really useful part of Searx is being able to search through files or videos. Having that option hidden under "advanced settings" is annoying, especially for mobile where its hard to click the advanced setting without click the first search result. I would like to have to appear by default on my instance. Is this possible? 

it would be nice if the old default theme was kept as a legacy theme

Make different forms of search appear by default without having to click "advanced settings"
One of the really useful part of Searx is being able to search through files or videos. Having that option hidden under "advanced settings" is annoying, especially for mobile where its hard to click the advanced setting without click the first search result. I would like to have to appear by default on my instance. Is this possible? 

it would be nice if the old default theme was kept as a legacy theme



Discussion:
I second that, really annoying to multiply clic.
Open/type request with suggestion/show websites/clic image link to show images/view image or source
Google studied the UI for years with million dollars, why no just copy what they do? it is clearly the best way to do.

@risoul i agree
the image search part should also allow for a next and previous button so you dont have to close the image and then click the next one each time. Allowing keyboard arrows to work like this would be nice as well

+1

@Wonderfall any update on this? 
Bump.

Is there any toggle to show "advanced settings" by default?
@renyhp 

> Bump.
> 
> Is there any toggle to show "advanced settings" by default?

Would you be capable of writing some code for this feature? It shouldn't be that difficult and the developers of Searx can always help you.
Implementation with a default settings:
* move this line https://github.com/searx/searx/blob/e78bfd4d8b62a521e08029bb0e708b2bcec9958d/searx/webapp.py#L588 at the top of the `index()` function.
* Replace `None` by `settings['ui'].get('advanced_search')`
* each call to `render(` must include`advanced_search=advanced_search,`

It should do the trick.

Here the index page get the default value from the settings.
But I guess most people will want also to keep the setting value on any instances.

---

Another way to solve this issue: display the categories on the index page.
I think I can do a PR for that. I'm not sure I understand this, though:

> But I guess most people will want also to keep the setting value on any instances.
Broken English, sorry.

My guess is, whatever the instance,  some users want to display the categories, some others don't. So a default value in settings.yml won't fit the use in a public instance where the user may want to display the categories and keep that setting across the different requests (even if the default value in settings.yml hides them).

--- 

So, this value could be a preference (in the /preferences URL). 
In this case `None` is replaced by `request.preferences.get_value('advanced_search')`  instead of `settings['ui'].get('advanced_search')` (in the `index()` function)

In preferences add a new entry in `key_value_settings ` : 
```python
            'advanced_search': MapSetting(
                settings['ui'].get('advanced_search', False),
                map={
                    '0': False,
                    '1': True,
                    'False': False,
                    'True': True
                }
            ),
```

Then after https://github.com/searx/searx/blob/e78bfd4d8b62a521e08029bb0e708b2bcec9958d/searx/templates/oscar/preferences.html#L121
Add
```
                    {% set label = _('Show advanced settings') %}
                    {% set info = '' %}
                    {{ preferences_item_header(info, label, rtl, 'advanced_search') }}
                        <select class="form-control {{ custom_select_class(rtl) }}" name="advanced_search" id="advanced_search">
                            <option value="1" {% if preferences.get_value('advanced_search')%}selected="selected"{% endif %}>{{ _('On') }}</option>
                            <option value="0" {% if not preferences.get_value('advanced_search')%}selected="selected"{% endif %}>{{ _('Off')}}</option>
                        </select>
                    {{ preferences_item_footer(info, label, rtl) }}
```

(and a similar change in the `simple` theme: https://github.com/searx/searx/blob/e78bfd4d8b62a521e08029bb0e708b2bcec9958d/searx/templates/simple/preferences.html )

I hope I haven't forgotten something.

---

Feel free to create a PR based on this comment or the previous comment (it fixes the issue).


I second that, really annoying to multiply clic.
Open/type request with suggestion/show websites/clic image link to show images/view image or source
Google studied the UI for years with million dollars, why no just copy what they do? it is clearly the best way to do.

@risoul i agree
the image search part should also allow for a next and previous button so you dont have to close the image and then click the next one each time. Allowing keyboard arrows to work like this would be nice as well

+1

@Wonderfall any update on this? 
Bump.

Is there any toggle to show "advanced settings" by default?
@renyhp 

> Bump.
> 
> Is there any toggle to show "advanced settings" by default?

Would you be capable of writing some code for this feature? It shouldn't be that difficult and the developers of Searx can always help you.
Implementation with a default settings:
* move this line https://github.com/searx/searx/blob/e78bfd4d8b62a521e08029bb0e708b2bcec9958d/searx/webapp.py#L588 at the top of the `index()` function.
* Replace `None` by `settings['ui'].get('advanced_search')`
* each call to `render(` must include`advanced_search=advanced_search,`

It should do the trick.

Here the index page get the default value from the settings.
But I guess most people will want also to keep the setting value on any instances.

---

Another way to solve this issue: display the categories on the index page.
I think I can do a PR for that. I'm not sure I understand this, though:

> But I guess most people will want also to keep the setting value on any instances.
Broken English, sorry.

My guess is, whatever the instance,  some users want to display the categories, some others don't. So a default value in settings.yml won't fit the use in a public instance where the user may want to display the categories and keep that setting across the different requests (even if the default value in settings.yml hides them).

--- 

So, this value could be a preference (in the /preferences URL). 
In this case `None` is replaced by `request.preferences.get_value('advanced_search')`  instead of `settings['ui'].get('advanced_search')` (in the `index()` function)

In preferences add a new entry in `key_value_settings ` : 
```python
            'advanced_search': MapSetting(
                settings['ui'].get('advanced_search', False),
                map={
                    '0': False,
                    '1': True,
                    'False': False,
                    'True': True
                }
            ),
```

Then after https://github.com/searx/searx/blob/e78bfd4d8b62a521e08029bb0e708b2bcec9958d/searx/templates/oscar/preferences.html#L121
Add
```
                    {% set label = _('Show advanced settings') %}
                    {% set info = '' %}
                    {{ preferences_item_header(info, label, rtl, 'advanced_search') }}
                        <select class="form-control {{ custom_select_class(rtl) }}" name="advanced_search" id="advanced_search">
                            <option value="1" {% if preferences.get_value('advanced_search')%}selected="selected"{% endif %}>{{ _('On') }}</option>
                            <option value="0" {% if not preferences.get_value('advanced_search')%}selected="selected"{% endif %}>{{ _('Off')}}</option>
                        </select>
                    {{ preferences_item_footer(info, label, rtl) }}
```

(and a similar change in the `simple` theme: https://github.com/searx/searx/blob/e78bfd4d8b62a521e08029bb0e708b2bcec9958d/searx/templates/simple/preferences.html )

I hope I haven't forgotten something.

---

Feel free to create a PR based on this comment or the previous comment (it fixes the issue).



Resolving patch:
diff --git a/searx/preferences.py b/searx/preferences.py
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -395,6 +395,17 @@ def __init__(self, themes, categories, engines, plugins):
                 settings['ui'].get('theme_args', {}).get('oscar_style', 'logicodev'),
                 is_locked('oscar-style'),
                 choices=['', 'logicodev', 'logicodev-dark', 'pointhi']),
+            'advanced_search': MapSetting(
+                settings['ui'].get('advanced_search', False),
+                is_locked('advanced_search'),
+                map={
+                    '0': False,
+                    '1': True,
+                    'False': False,
+                    'True': True,
+                    'on': True,
+                }
+            ),
         }
 
         self.engines = EnginesSetting('engines', choices=engines)
diff --git a/searx/webapp.py b/searx/webapp.py
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -545,6 +545,9 @@ def index_error(output_format, error_message):
 def index():
     """Render index page."""
 
+    # UI
+    advanced_search = request.preferences.get_value('advanced_search')
+
     # redirect to search if there's a query in the request
     if request.form.get('q'):
         query = ('?' + request.query_string.decode()) if request.query_string else ''
@@ -553,6 +556,7 @@ def index():
     return render(
         'index.html',
         selected_categories=get_selected_categories(request.preferences, request.form),
+        advanced_search=advanced_search,
     )
 
 
@@ -573,6 +577,7 @@ def search():
         if output_format == 'html':
             return render(
                 'index.html',
+                advanced_search=request.preferences.get_value('advanced_search'),
                 selected_categories=get_selected_categories(request.preferences, request.form),
             )
         else:
@@ -606,9 +611,6 @@ def search():
     if result_container.redirect_url:
         return redirect(result_container.redirect_url)
 
-    # UI
-    advanced_search = request.form.get('advanced_search', None)
-
     # Server-Timing header
     request.timings = result_container.get_timings()
 
@@ -717,7 +719,6 @@ def search():
         pageno=search_query.pageno,
         time_range=search_query.time_range,
         number_of_results=format_decimal(number_of_results),
-        advanced_search=advanced_search,
         suggestions=suggestion_urls,
         answers=result_container.answers,
         corrections=correction_urls,


Test patch: