add some options to sidebar

This commit is contained in:
Gnkalk 2024-12-20 21:48:40 +03:30
parent af0164b1a3
commit ff8ac40478
12 changed files with 240 additions and 14 deletions

View file

@ -280,6 +280,7 @@ main:has(.not-found) .button {
}
#index header .links {
gap: .5rem;
display: flex;
}
@ -334,7 +335,7 @@ body:has(.sidebar_btn[open]) header .links .link.config {
overflow: hidden;
}
#sidebar .container {
#sidebar > .container {
width: calc(100% - 2rem);
min-width: 308px;
height: calc(100% - 2rem);
@ -343,6 +344,47 @@ body:has(.sidebar_btn[open]) header .links .link.config {
overflow-y: auto;
}
#sidebar > .container fieldset {
padding: .5rem 0;
}
#sidebar > .container fieldset .container {
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
gap: .5rem;
padding: 0 .5rem;
display: flex;
}
#sidebar > .container fieldset .container select {
background-color: var(--secondary-background-color);
color: var(--text-color);
border-radius: .5rem;
max-width: 250px;
padding: .5rem 1rem;
}
#sidebar > .container fieldset .description {
text-align: justify;
color: var(--text-color);
margin: .5rem;
font-size: .8rem;
}
#sidebar > .container button {
background-color: var(--primary-color);
width: 100%;
color: var(--filled-text-color);
border-radius: .5rem;
margin: .5rem 0;
padding: .5rem;
}
#sidebar > .container button.reset {
background-color: var(--secondary-color);
}
footer {
flex-wrap: wrap;
justify-content: space-between;

View file

@ -280,6 +280,7 @@ main:has(.not-found) .button {
}
#index header .links {
gap: .5rem;
display: flex;
}
@ -334,7 +335,7 @@ body:has(.sidebar_btn[open]) header .links .link.config {
overflow: hidden;
}
#sidebar .container {
#sidebar > .container {
width: calc(100% - 2rem);
min-width: 308px;
height: calc(100% - 2rem);
@ -343,6 +344,47 @@ body:has(.sidebar_btn[open]) header .links .link.config {
overflow-y: auto;
}
#sidebar > .container fieldset {
padding: .5rem 0;
}
#sidebar > .container fieldset .container {
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
gap: .5rem;
padding: 0 .5rem;
display: flex;
}
#sidebar > .container fieldset .container select {
background-color: var(--secondary-background-color);
color: var(--text-color);
border-radius: .5rem;
max-width: 250px;
padding: .5rem 1rem;
}
#sidebar > .container fieldset .description {
text-align: justify;
color: var(--text-color);
margin: .5rem;
font-size: .8rem;
}
#sidebar > .container button {
background-color: var(--primary-color);
width: 100%;
color: var(--filled-text-color);
border-radius: .5rem;
margin: .5rem 0;
padding: .5rem;
}
#sidebar > .container button.reset {
background-color: var(--secondary-color);
}
footer {
flex-wrap: wrap;
justify-content: space-between;

View file

@ -121,6 +121,7 @@ main:has(.not-found) {
.links {
display: flex;
gap: .5rem;
.link {
display: inline-block;
@ -178,13 +179,54 @@ body:has(.sidebar_btn[open]) {
padding 200ms ease-in-out;
position: relative;
.container {
&>.container {
width: calc(100% - 2rem);
height: calc(100% - 2rem);
overflow-y: auto;
position: absolute;
min-width: $screen-xs - toPx(2);
transition: width 500ms ease-in-out;
fieldset {
padding: .5rem 0;
.container {
display: flex;
padding: 0 .5rem;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: .5rem;
select {
padding: .5rem 1rem;
background-color: var(--secondary-background-color);
color: var(--text-color);
@include mixin.rounded(sm);
max-width: 250px;
}
}
.description {
margin: .5rem;
text-align: justify;
color: var(--text-color);
font-size: .8rem;
}
}
button {
padding: .5rem;
background-color: var(--primary-color);
width: 100%;
color: var(--filled-text-color);
@include mixin.rounded(sm);
margin: .5rem 0;
&.reset {
background-color: var(--secondary-color);
}
}
}
}

View file

@ -100,16 +100,8 @@
{% endif %} {% block content %} {% endblock %}
</main>
</div>
<div id="sidebar">
<div class="container">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid
inventore repellat totam eius consequatur neque laborum corrupti
repellendus optio obcaecati! Et voluptates omnis, adipisci modi
officiis aliquid, debitis perferendis illum enim tenetur sequi
rerum at error expedita harum dolorum ex assumenda! Voluptatibus
velit suscipit, aut voluptas fugit saepe natus eum?
</div>
</div>
{% if endpoint == 'index' or endpoint == 'results' %} {% include
'smart/madules/sidebar.html' %} {% endif %}
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
</body>
</html>

View file

@ -9,7 +9,7 @@
</a>
<div class="links">
<a href="" class="link">{{icon_small('donate')}}</a>
{% include 'smart/sidebar.html' %}
{% include 'smart/madules/sidebar_btn.html' %}
</div>
{% endblock %} {% block content %}

View file

@ -0,0 +1,17 @@
<fieldset>
<div class="container">
<legend id="pref_autocomplete">{{- _('Autocomplete') -}}</legend>
<select name="autocomplete" aria-labelledby="pref_autocomplete" aria-describedby="desc_autocomplete">
<option value=""> - </option>
{%- for backend in autocomplete_backends -%}
<option value="{{ backend }}"
{%- if backend == autocomplete %} selected="selected" {%- endif -%}>
{{- backend -}}
</option>
{%- endfor -%}
</select>
</div>
<div class="description" id="desc_autocomplete">
{{- _('Find stuff as you type') }}
</div>
</fieldset>

View file

@ -0,0 +1,17 @@
<fieldset>
<div class="container">
<legend id="pref_ui_locale">{{- _('Interface language') -}}</legend>
<select name='locale' aria-labelledby="pref_ui_locale" aria-describedby="desc_ui_locale">
{%- for locale_id,locale_name in locales.items() | sort -%}
<option value="{{ locale_id }}"
{%- if locale_id == current_locale %} selected="selected" {%- endif %}>
{{- locale_name -}}
</option>
{%- endfor -%}
</select>
</div>
<div class="description" id="desc_ui_locale">
{{- _('Change the language of the layout') -}}
</div>
</fieldset>

View file

@ -0,0 +1,27 @@
<fieldset>
<div class="container">
<legend id="pref_language">{{- _('Search language') -}}</legend>
<select name="language" aria-labelledby="pref_language" aria-describedby="desc_language">
<option value="all"
{%- if current_language == 'all' %} selected="selected" {%- endif -%}>
{{- _('Default language') }} [all]
</option>
<option value="auto"
{%- if current_language == 'auto' %} selected="selected" {%- endif -%}>
{{- _('Auto-detect') }} [auto]
</option>
{% for sxng_tag,lang_name,country_name,english_name,flag in sxng_locales | sort(attribute=1) -%}
<option value="{{ sxng_tag }}"
{%- if sxng_tag == current_language %} selected="selected" {%- endif -%}>
{{ lang_name }}{%- if country_name -%}-{{ country_name }}{%- endif -%}
[{{sxng_tag}}]
{%- if flag -%}{{ flag }}{%- endif -%}
</option>
{%- endfor -%}
</select>
</div>
<div class="description" id="desc_language">
{{- _('What language do you prefer for search?') }} {{- ' ' -}}
{{- _('Choose Auto-detect to let SearXNG detect the language of your query.') -}}
</div>
</fieldset>

View file

@ -0,0 +1,23 @@
<fieldset>
<div class="container">
<legend id="pref_safesearch">{{- _('SafeSearch') -}}</legend>
<select name='safesearch' aria-labelledby="pref_safesearch" aria-describedby="desc_safesearch">
<option value="2"
{%- if safesearch == '2' %} selected="selected" {%- endif -%}>
{{- _('Strict') -}}
</option>
<option value="1"
{%- if safesearch == '1' %} selected="selected" {%- endif -%}>
{{- _('Moderate') -}}
</option>
<option value="0"
{%- if safesearch == '0' %} selected="selected" {%- endif -%}>
{{- _('None') -}}
</option>
</select>
</div>
<div class="description" id="desc_safesearch">
{{- _('Filter content') -}}
</div>
</fieldset>

View file

@ -0,0 +1,22 @@
<div id="sidebar">
<div class="container">
<form
id="search_form"
method="post"
action="{{ url_for('preferences') }}"
autocomplete="off"
>
{%- if 'language' not in locked_preferences -%} {%- include
'smart/madules/settings/language.html' -%} {% endif %} {%- if
'autocomplete' not in locked_preferences -%} {%- include
'smart/madules/settings/autocomplete.html' -%} {%- endif -%} {%- if
'safesearch' not in locked_preferences -%} {%- include
'smart/madules/settings/safe_search.html' -%} {%- endif -%} {%- if
'ui_locale' not in locked_preferences -%} {%- include
'smart/madules/settings/interface_lang.html' -%} {%- endif -%}
<button type="submit" class="save">{{- _('Save') -}}</button>
<button type="reset" class="reset">{{- _('Reset') -}}</button>
</form>
</div>
</div>

View file

@ -609,6 +609,8 @@ def index():
'index.html',
selected_categories=get_selected_categories(request.preferences, request.form),
current_locale = request.preferences.get_value("locale"),
autocomplete_backends = autocomplete_backends,
locales = LOCALE_NAMES,
# fmt: on
)