Spaces:
Running
Running
Merge branch 'rolling' into FIX/468_pagination-for-the-upstream-search-engines-not-working
Browse files- public/static/cookies.js +67 -3
- public/static/themes/simple.css +9 -1
- src/server/router.rs +2 -4
- src/templates/partials/settings_tabs/engines.rs +45 -14
- src/templates/partials/settings_tabs/general.rs +18 -4
- src/templates/partials/settings_tabs/user_interface.rs +28 -10
- src/templates/views/settings.rs +8 -3
public/static/cookies.js
CHANGED
@@ -1,3 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/**
|
2 |
* This function is executed when any page on the website finishes loading and
|
3 |
* this function retrieves the cookies if it is present on the user's machine.
|
@@ -16,9 +75,14 @@ document.addEventListener(
|
|
16 |
let cookie = decodeURIComponent(document.cookie)
|
17 |
// Set the value of the input field to the decoded cookie value if it is not empty
|
18 |
// Otherwise, display a message indicating that no cookies have been saved on the user's system
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
} catch (error) {
|
23 |
// If there is an error decoding the cookie, log the error to the console
|
24 |
// and display an error message in the input field
|
|
|
1 |
+
/**
|
2 |
+
* This functions gets the saved cookies if it is present on the user's machine If it
|
3 |
+
* is available then it is parsed and converted to an object which is then used to
|
4 |
+
* retrieve the preferences that the user had selected previously and is then loaded
|
5 |
+
* and used for displaying the user provided settings by setting them as the selected
|
6 |
+
* options in the settings page.
|
7 |
+
*
|
8 |
+
* @function
|
9 |
+
* @param {string} cookie - It takes the client settings cookie as a string.
|
10 |
+
* @returns {void}
|
11 |
+
*/
|
12 |
+
function setClientSettingsOnPage(cookie) {
|
13 |
+
let cookie_value = cookie
|
14 |
+
.split(';')
|
15 |
+
.map((item) => item.split('='))
|
16 |
+
.reduce((acc, [_, v]) => (acc = JSON.parse(v)) && acc, {})
|
17 |
+
|
18 |
+
// Loop through all select tags and add their values to the cookie dictionary
|
19 |
+
document.querySelectorAll('select').forEach((select_tag) => {
|
20 |
+
switch (select_tag.name) {
|
21 |
+
case 'themes':
|
22 |
+
select_tag.value = cookie_value['theme']
|
23 |
+
break
|
24 |
+
case 'colorschemes':
|
25 |
+
select_tag.value = cookie_value['colorscheme']
|
26 |
+
break
|
27 |
+
case 'animations':
|
28 |
+
select_tag.value = cookie_value['animation']
|
29 |
+
break
|
30 |
+
case 'safe_search_levels':
|
31 |
+
select_tag.value = cookie_value['safe_search_level']
|
32 |
+
break
|
33 |
+
}
|
34 |
+
})
|
35 |
+
let engines = document.querySelectorAll('.engine')
|
36 |
+
let engines_cookie = cookie_value['engines']
|
37 |
+
|
38 |
+
if (engines_cookie.length === engines.length) {
|
39 |
+
document.querySelector('.select_all').checked = true
|
40 |
+
engines.forEach((engine_checkbox) => {
|
41 |
+
engine_checkbox.checked = true
|
42 |
+
})
|
43 |
+
} else {
|
44 |
+
engines.forEach((engines_checkbox) => {
|
45 |
+
engines_checkbox.checked = false
|
46 |
+
})
|
47 |
+
engines_cookie.forEach((engine_name) => {
|
48 |
+
engines.forEach((engine_checkbox) => {
|
49 |
+
if (
|
50 |
+
engine_checkbox.parentNode.parentNode.innerText.trim() ===
|
51 |
+
engine_name.trim()
|
52 |
+
) {
|
53 |
+
engine_checkbox.checked = true
|
54 |
+
}
|
55 |
+
})
|
56 |
+
})
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
/**
|
61 |
* This function is executed when any page on the website finishes loading and
|
62 |
* this function retrieves the cookies if it is present on the user's machine.
|
|
|
75 |
let cookie = decodeURIComponent(document.cookie)
|
76 |
// Set the value of the input field to the decoded cookie value if it is not empty
|
77 |
// Otherwise, display a message indicating that no cookies have been saved on the user's system
|
78 |
+
if (cookie.length) {
|
79 |
+
document.querySelector('.cookies input').value = cookie
|
80 |
+
// This function displays the user provided settings on the settings page.
|
81 |
+
setClientSettingsOnPage(cookie)
|
82 |
+
} else {
|
83 |
+
document.querySelector('.cookies input').value =
|
84 |
+
'No cookies have been saved on your system'
|
85 |
+
}
|
86 |
} catch (error) {
|
87 |
// If there is an error decoding the cookie, log the error to the console
|
88 |
// and display an error message in the input field
|
public/static/themes/simple.css
CHANGED
@@ -600,12 +600,20 @@ footer div {
|
|
600 |
text-transform: capitalize;
|
601 |
}
|
602 |
|
603 |
-
.settings_container .tab .description
|
|
|
604 |
font-size: 1.5rem;
|
605 |
margin-bottom: 0.5rem;
|
|
|
|
|
|
|
606 |
color: var(--foreground-color);
|
607 |
}
|
608 |
|
|
|
|
|
|
|
|
|
609 |
.settings_container .user_interface select,
|
610 |
.settings_container .general select {
|
611 |
margin: 0.7rem 0;
|
|
|
600 |
text-transform: capitalize;
|
601 |
}
|
602 |
|
603 |
+
.settings_container .tab .description,
|
604 |
+
.settings_container .tab .admin_warning {
|
605 |
font-size: 1.5rem;
|
606 |
margin-bottom: 0.5rem;
|
607 |
+
}
|
608 |
+
|
609 |
+
.settings_container .tab .description {
|
610 |
color: var(--foreground-color);
|
611 |
}
|
612 |
|
613 |
+
.settings_container .tab .admin_warning {
|
614 |
+
color: var(--color-two);
|
615 |
+
}
|
616 |
+
|
617 |
.settings_container .user_interface select,
|
618 |
.settings_container .general select {
|
619 |
margin: 0.7rem 0;
|
src/server/router.rs
CHANGED
@@ -75,13 +75,11 @@ pub async fn settings(
|
|
75 |
.content_type("text/html; charset=utf-8")
|
76 |
.body(
|
77 |
crate::templates::views::settings::settings(
|
|
|
78 |
&config.style.colorscheme,
|
79 |
&config.style.theme,
|
80 |
&config.style.animation,
|
81 |
-
&config
|
82 |
-
.upstream_search_engines
|
83 |
-
.keys()
|
84 |
-
.collect::<Vec<&String>>(),
|
85 |
)?
|
86 |
.0,
|
87 |
))
|
|
|
75 |
.content_type("text/html; charset=utf-8")
|
76 |
.body(
|
77 |
crate::templates::views::settings::settings(
|
78 |
+
config.safe_search,
|
79 |
&config.style.colorscheme,
|
80 |
&config.style.theme,
|
81 |
&config.style.animation,
|
82 |
+
&config.upstream_search_engines,
|
|
|
|
|
|
|
83 |
)?
|
84 |
.0,
|
85 |
))
|
src/templates/partials/settings_tabs/engines.rs
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
//! A module that handles the engines tab for setting page view in the `websurfx` frontend.
|
2 |
|
|
|
|
|
3 |
use maud::{html, Markup};
|
4 |
|
5 |
/// A functions that handles the html code for the engines tab for the settings page for the search page.
|
6 |
///
|
7 |
/// # Arguments
|
8 |
///
|
9 |
-
/// * `engine_names` - It takes the list of all available engine names
|
|
|
10 |
///
|
11 |
/// # Returns
|
12 |
///
|
13 |
/// It returns the compiled html markup code for the engines tab.
|
14 |
-
pub fn engines(engine_names: &
|
15 |
html!(
|
16 |
div class="engines tab"{
|
17 |
h1{"Engines"}
|
@@ -20,21 +23,49 @@ pub fn engines(engine_names: &[&String]) -> Markup {
|
|
20 |
"Select the search engines from the list of engines that you want results from"
|
21 |
}
|
22 |
.engine_selection{
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
hr;
|
31 |
-
@for engine_name in engine_names{
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
-
(format!("{}{}",engine_name[..1].to_uppercase().to_owned(), engine_name[1..].to_owned()))
|
38 |
}
|
39 |
}
|
40 |
}
|
|
|
1 |
//! A module that handles the engines tab for setting page view in the `websurfx` frontend.
|
2 |
|
3 |
+
use std::collections::HashMap;
|
4 |
+
|
5 |
use maud::{html, Markup};
|
6 |
|
7 |
/// A functions that handles the html code for the engines tab for the settings page for the search page.
|
8 |
///
|
9 |
/// # Arguments
|
10 |
///
|
11 |
+
/// * `engine_names` - It takes the key value pair list of all available engine names and there corresponding
|
12 |
+
/// selected (enabled/disabled) value as an argument.
|
13 |
///
|
14 |
/// # Returns
|
15 |
///
|
16 |
/// It returns the compiled html markup code for the engines tab.
|
17 |
+
pub fn engines(engine_names: &HashMap<String, bool>) -> Markup {
|
18 |
html!(
|
19 |
div class="engines tab"{
|
20 |
h1{"Engines"}
|
|
|
23 |
"Select the search engines from the list of engines that you want results from"
|
24 |
}
|
25 |
.engine_selection{
|
26 |
+
// Checks whether all the engines are selected or not if they are then the
|
27 |
+
// checked `select_all` button is rendered otherwise the unchecked version
|
28 |
+
// is rendered.
|
29 |
+
@if engine_names.values().all(|selected| *selected){
|
30 |
+
.toggle_btn{
|
31 |
+
label class="switch"{
|
32 |
+
input type="checkbox" class="select_all" onchange="toggleAllSelection()" checked;
|
33 |
+
span class="slider round"{}
|
34 |
+
}
|
35 |
+
"Select All"
|
36 |
+
}
|
37 |
+
}
|
38 |
+
@else{
|
39 |
+
.toggle_btn {
|
40 |
+
label class="switch"{
|
41 |
+
input type="checkbox" class="select_all" onchange="toggleAllSelection()";
|
42 |
+
span class="slider round"{}
|
43 |
+
}
|
44 |
+
"Select All"
|
45 |
+
}
|
46 |
}
|
47 |
hr;
|
48 |
+
@for (engine_name, selected) in engine_names{
|
49 |
+
// Checks whether the `engine_name` is selected or not if they are then the
|
50 |
+
// checked `engine` button is rendered otherwise the unchecked version is
|
51 |
+
// rendered.
|
52 |
+
@if *selected {
|
53 |
+
.toggle_btn{
|
54 |
+
label class="switch"{
|
55 |
+
input type="checkbox" class="engine" checked;
|
56 |
+
span class="slider round"{}
|
57 |
+
}
|
58 |
+
(format!("{}{}",engine_name[..1].to_uppercase().to_owned(), engine_name[1..].to_owned()))
|
59 |
+
}
|
60 |
+
}
|
61 |
+
@else {
|
62 |
+
.toggle_btn {
|
63 |
+
label class="switch"{
|
64 |
+
input type="checkbox" class="engine";
|
65 |
+
span class="slider round"{}
|
66 |
+
}
|
67 |
+
(format!("{}{}",engine_name[..1].to_uppercase().to_owned(), engine_name[1..].to_owned()))
|
68 |
}
|
|
|
69 |
}
|
70 |
}
|
71 |
}
|
src/templates/partials/settings_tabs/general.rs
CHANGED
@@ -7,10 +7,14 @@ const SAFE_SEARCH_LEVELS: [(u8, &str); 3] = [(0, "None"), (1, "Low"), (2, "Moder
|
|
7 |
|
8 |
/// A functions that handles the html code for the general tab for the settings page for the search page.
|
9 |
///
|
|
|
|
|
|
|
|
|
10 |
/// # Returns
|
11 |
///
|
12 |
/// It returns the compiled html markup code for the general tab.
|
13 |
-
pub fn general() -> Markup {
|
14 |
html!(
|
15 |
div class="general tab active"{
|
16 |
h1{"General"}
|
@@ -18,9 +22,19 @@ pub fn general() -> Markup {
|
|
18 |
p class="description"{
|
19 |
"Select a safe search level from the menu below to filter content based on the level."
|
20 |
}
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
}
|
26 |
}
|
|
|
7 |
|
8 |
/// A functions that handles the html code for the general tab for the settings page for the search page.
|
9 |
///
|
10 |
+
/// # Arguments
|
11 |
+
///
|
12 |
+
/// * `safe_search_level` - It takes the safe search level as an argument.
|
13 |
+
///
|
14 |
/// # Returns
|
15 |
///
|
16 |
/// It returns the compiled html markup code for the general tab.
|
17 |
+
pub fn general(safe_search_level: u8) -> Markup {
|
18 |
html!(
|
19 |
div class="general tab active"{
|
20 |
h1{"General"}
|
|
|
22 |
p class="description"{
|
23 |
"Select a safe search level from the menu below to filter content based on the level."
|
24 |
}
|
25 |
+
@if safe_search_level < 3 {
|
26 |
+
select name="safe_search_levels" {
|
27 |
+
// Sets the user selected safe_search_level name from the config file as the first option in the selection list.
|
28 |
+
option value=(safe_search_level){(SAFE_SEARCH_LEVELS.iter().find(|level| level.0 == safe_search_level).unwrap().1)}
|
29 |
+
@for (k,v) in SAFE_SEARCH_LEVELS.iter().filter(|level| level.0 != safe_search_level){
|
30 |
+
option value=(k){(v)}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
@else {
|
35 |
+
p class="admin_warning" {"⚠️ This setting is being managed by the server administrator."}
|
36 |
+
select name="safe_search_levels" disabled {
|
37 |
+
option value=(SAFE_SEARCH_LEVELS[2].0){(SAFE_SEARCH_LEVELS[2].1)}
|
38 |
}
|
39 |
}
|
40 |
}
|
src/templates/partials/settings_tabs/user_interface.rs
CHANGED
@@ -4,13 +4,16 @@ use crate::handler::{file_path, FileType};
|
|
4 |
use maud::{html, Markup};
|
5 |
use std::fs::read_dir;
|
6 |
|
7 |
-
/// A helper function that helps in building the list of all available colorscheme/theme
|
8 |
-
/// present in the colorschemes and themes folder respectively
|
|
|
9 |
///
|
10 |
/// # Arguments
|
11 |
///
|
12 |
/// * `style_type` - It takes the style type of the values `theme` and `colorscheme` as an
|
13 |
/// argument.
|
|
|
|
|
14 |
///
|
15 |
/// # Error
|
16 |
///
|
@@ -18,7 +21,8 @@ use std::fs::read_dir;
|
|
18 |
/// returns a standard error message.
|
19 |
fn style_option_list(
|
20 |
style_type: &str,
|
21 |
-
|
|
|
22 |
let mut style_option_names: Vec<(String, String)> = Vec::new();
|
23 |
for file in read_dir(format!(
|
24 |
"{}static/{}/",
|
@@ -26,7 +30,13 @@ fn style_option_list(
|
|
26 |
style_type,
|
27 |
))? {
|
28 |
let style_name = file?.file_name().to_str().unwrap().replace(".css", "");
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
Ok(style_option_names)
|
@@ -38,7 +48,11 @@ fn style_option_list(
|
|
38 |
///
|
39 |
/// It returns the compiled html markup code for the user interface tab on success otherwise
|
40 |
/// returns a standard error message.
|
41 |
-
pub fn user_interface(
|
|
|
|
|
|
|
|
|
42 |
Ok(html!(
|
43 |
div class="user_interface tab"{
|
44 |
h1{"User Interface"}
|
@@ -47,7 +61,9 @@ pub fn user_interface() -> Result<Markup, Box<dyn std::error::Error>> {
|
|
47 |
"Select the theme from the available themes to be used in user interface"
|
48 |
}
|
49 |
select name="themes"{
|
50 |
-
|
|
|
|
|
51 |
option value=(k){(v)}
|
52 |
}
|
53 |
}
|
@@ -56,7 +72,9 @@ pub fn user_interface() -> Result<Markup, Box<dyn std::error::Error>> {
|
|
56 |
"Select the color scheme for your theme to be used in user interface"
|
57 |
}
|
58 |
select name="colorschemes"{
|
59 |
-
|
|
|
|
|
60 |
option value=(k){(v)}
|
61 |
}
|
62 |
}
|
@@ -65,12 +83,12 @@ pub fn user_interface() -> Result<Markup, Box<dyn std::error::Error>> {
|
|
65 |
"Select the animation for your theme to be used in user interface"
|
66 |
}
|
67 |
select name="animations"{
|
68 |
-
option
|
69 |
-
|
|
|
70 |
option value=(k){(v)}
|
71 |
}
|
72 |
}
|
73 |
-
|
74 |
}
|
75 |
))
|
76 |
}
|
|
|
4 |
use maud::{html, Markup};
|
5 |
use std::fs::read_dir;
|
6 |
|
7 |
+
/// A helper function that helps in building the list of all available colorscheme/theme/animation
|
8 |
+
/// names present in the colorschemes, animations and themes folder respectively by excluding the
|
9 |
+
/// ones that have already been selected via the config file.
|
10 |
///
|
11 |
/// # Arguments
|
12 |
///
|
13 |
/// * `style_type` - It takes the style type of the values `theme` and `colorscheme` as an
|
14 |
/// argument.
|
15 |
+
/// * `selected_style` - It takes the currently selected style value provided via the config file
|
16 |
+
/// as an argument.
|
17 |
///
|
18 |
/// # Error
|
19 |
///
|
|
|
21 |
/// returns a standard error message.
|
22 |
fn style_option_list(
|
23 |
style_type: &str,
|
24 |
+
selected_style: &str,
|
25 |
+
) -> Result<Vec<(String, String)>, Box<dyn std::error::Error>> {
|
26 |
let mut style_option_names: Vec<(String, String)> = Vec::new();
|
27 |
for file in read_dir(format!(
|
28 |
"{}static/{}/",
|
|
|
30 |
style_type,
|
31 |
))? {
|
32 |
let style_name = file?.file_name().to_str().unwrap().replace(".css", "");
|
33 |
+
if selected_style != style_name {
|
34 |
+
style_option_names.push((style_name.clone(), style_name.replace('-', " ")));
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
if style_type == "animations" {
|
39 |
+
style_option_names.push(("".to_owned(), "none".to_owned()))
|
40 |
}
|
41 |
|
42 |
Ok(style_option_names)
|
|
|
48 |
///
|
49 |
/// It returns the compiled html markup code for the user interface tab on success otherwise
|
50 |
/// returns a standard error message.
|
51 |
+
pub fn user_interface(
|
52 |
+
theme: &str,
|
53 |
+
colorscheme: &str,
|
54 |
+
animation: &Option<String>,
|
55 |
+
) -> Result<Markup, Box<dyn std::error::Error>> {
|
56 |
Ok(html!(
|
57 |
div class="user_interface tab"{
|
58 |
h1{"User Interface"}
|
|
|
61 |
"Select the theme from the available themes to be used in user interface"
|
62 |
}
|
63 |
select name="themes"{
|
64 |
+
// Sets the user selected theme name from the config file as the first option in the selection list.
|
65 |
+
option value=(theme){(theme.replace('-', " "))}
|
66 |
+
@for (k,v) in style_option_list("themes", theme)?{
|
67 |
option value=(k){(v)}
|
68 |
}
|
69 |
}
|
|
|
72 |
"Select the color scheme for your theme to be used in user interface"
|
73 |
}
|
74 |
select name="colorschemes"{
|
75 |
+
// Sets the user selected colorscheme name from the config file as the first option in the selection list.
|
76 |
+
option value=(colorscheme){(colorscheme.replace('-', " "))}
|
77 |
+
@for (k,v) in style_option_list("colorschemes", colorscheme)?{
|
78 |
option value=(k){(v)}
|
79 |
}
|
80 |
}
|
|
|
83 |
"Select the animation for your theme to be used in user interface"
|
84 |
}
|
85 |
select name="animations"{
|
86 |
+
// Sets the user selected animation name from the config file as the first option in the selection list.
|
87 |
+
option value=(animation.as_ref().unwrap_or(&"".to_owned())){(animation.as_ref().unwrap_or(&"".to_owned()).replace('-'," "))}
|
88 |
+
@for (k,v) in style_option_list("animations", animation.as_ref().unwrap_or(&"".to_owned()))?{
|
89 |
option value=(k){(v)}
|
90 |
}
|
91 |
}
|
|
|
92 |
}
|
93 |
))
|
94 |
}
|
src/templates/views/settings.rs
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
//! A module that handles the view for the settings page in the `websurfx` frontend.
|
2 |
|
|
|
|
|
3 |
use maud::{html, Markup};
|
4 |
|
5 |
use crate::templates::partials::{
|
@@ -14,8 +16,10 @@ use crate::templates::partials::{
|
|
14 |
///
|
15 |
/// # Arguments
|
16 |
///
|
|
|
17 |
/// * `colorscheme` - It takes the colorscheme name as an argument.
|
18 |
/// * `theme` - It takes the theme name as an argument.
|
|
|
19 |
/// * `engine_names` - It takes a list of engine names as an argument.
|
20 |
///
|
21 |
/// # Error
|
@@ -23,10 +27,11 @@ use crate::templates::partials::{
|
|
23 |
/// This function returns a compiled html markup code on success otherwise returns a standard error
|
24 |
/// message.
|
25 |
pub fn settings(
|
|
|
26 |
colorscheme: &str,
|
27 |
theme: &str,
|
28 |
animation: &Option<String>,
|
29 |
-
engine_names: &
|
30 |
) -> Result<Markup, Box<dyn std::error::Error>> {
|
31 |
Ok(html!(
|
32 |
(header(colorscheme, theme, animation))
|
@@ -41,8 +46,8 @@ pub fn settings(
|
|
41 |
.btn onclick="setActiveTab(this)"{"cookies"}
|
42 |
}
|
43 |
.main_container{
|
44 |
-
(general())
|
45 |
-
(user_interface()?)
|
46 |
(engines(engine_names))
|
47 |
(cookies())
|
48 |
p class="message"{}
|
|
|
1 |
//! A module that handles the view for the settings page in the `websurfx` frontend.
|
2 |
|
3 |
+
use std::collections::HashMap;
|
4 |
+
|
5 |
use maud::{html, Markup};
|
6 |
|
7 |
use crate::templates::partials::{
|
|
|
16 |
///
|
17 |
/// # Arguments
|
18 |
///
|
19 |
+
/// * `safe_search_level` - It takes the safe search level as an argument.
|
20 |
/// * `colorscheme` - It takes the colorscheme name as an argument.
|
21 |
/// * `theme` - It takes the theme name as an argument.
|
22 |
+
/// * `animation` - It takes the animation name as an argument.
|
23 |
/// * `engine_names` - It takes a list of engine names as an argument.
|
24 |
///
|
25 |
/// # Error
|
|
|
27 |
/// This function returns a compiled html markup code on success otherwise returns a standard error
|
28 |
/// message.
|
29 |
pub fn settings(
|
30 |
+
safe_search_level: u8,
|
31 |
colorscheme: &str,
|
32 |
theme: &str,
|
33 |
animation: &Option<String>,
|
34 |
+
engine_names: &HashMap<String, bool>,
|
35 |
) -> Result<Markup, Box<dyn std::error::Error>> {
|
36 |
Ok(html!(
|
37 |
(header(colorscheme, theme, animation))
|
|
|
46 |
.btn onclick="setActiveTab(this)"{"cookies"}
|
47 |
}
|
48 |
.main_container{
|
49 |
+
(general(safe_search_level))
|
50 |
+
(user_interface(theme, colorscheme, animation)?)
|
51 |
(engines(engine_names))
|
52 |
(cookies())
|
53 |
p class="message"{}
|