2023-11-18 21:23:22 +03:00
|
|
|
//! A module that handles the view for the settings page in the `websurfx` frontend.
|
2023-11-17 22:10:06 +03:00
|
|
|
|
2023-12-28 19:54:47 +03:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
2023-11-17 22:10:06 +03:00
|
|
|
use maud::{html, Markup};
|
|
|
|
|
|
|
|
use crate::templates::partials::{
|
|
|
|
footer::footer,
|
|
|
|
header::header,
|
2024-08-14 21:34:18 +02:00
|
|
|
settings_tabs::{cookies::cookies, engines::engines, user_interface::user_interface},
|
2023-11-17 22:10:06 +03:00
|
|
|
};
|
|
|
|
|
2023-11-18 21:23:22 +03:00
|
|
|
/// A function that handles the html code for the settings page view in the search engine frontend.
|
2023-11-17 22:10:06 +03:00
|
|
|
///
|
2023-11-18 21:23:22 +03:00
|
|
|
/// # Arguments
|
|
|
|
///
|
2023-12-28 19:54:47 +03:00
|
|
|
/// * `safe_search_level` - It takes the safe search level as an argument.
|
2023-11-18 21:23:22 +03:00
|
|
|
/// * `colorscheme` - It takes the colorscheme name as an argument.
|
|
|
|
/// * `theme` - It takes the theme name as an argument.
|
2023-12-28 19:54:47 +03:00
|
|
|
/// * `animation` - It takes the animation name as an argument.
|
2023-11-18 21:23:22 +03:00
|
|
|
/// * `engine_names` - It takes a list of engine names as an argument.
|
|
|
|
///
|
|
|
|
/// # Error
|
|
|
|
///
|
|
|
|
/// This function returns a compiled html markup code on success otherwise returns a standard error
|
|
|
|
/// message.
|
2023-11-17 22:10:06 +03:00
|
|
|
pub fn settings(
|
|
|
|
colorscheme: &str,
|
|
|
|
theme: &str,
|
2023-12-12 15:04:44 +03:00
|
|
|
animation: &Option<String>,
|
2024-08-14 21:34:18 +02:00
|
|
|
//engine_names: &HashMap<String, bool>,
|
2023-11-17 22:10:06 +03:00
|
|
|
) -> Result<Markup, Box<dyn std::error::Error>> {
|
|
|
|
Ok(html!(
|
2023-12-12 15:04:44 +03:00
|
|
|
(header(colorscheme, theme, animation))
|
2023-11-17 22:10:06 +03:00
|
|
|
main class="settings"{
|
|
|
|
h1{"Settings"}
|
|
|
|
hr;
|
|
|
|
.settings_container{
|
|
|
|
.sidebar{
|
|
|
|
div class="btn active" onclick="setActiveTab(this)"{"general"}
|
|
|
|
.btn onclick="setActiveTab(this)"{"user interface"}
|
|
|
|
.btn onclick="setActiveTab(this)"{"engines"}
|
|
|
|
.btn onclick="setActiveTab(this)"{"cookies"}
|
|
|
|
}
|
|
|
|
.main_container{
|
2023-12-28 19:54:47 +03:00
|
|
|
(user_interface(theme, colorscheme, animation)?)
|
2024-08-14 21:34:18 +02:00
|
|
|
//(engines(engine_names))
|
2023-11-17 22:10:06 +03:00
|
|
|
(cookies())
|
|
|
|
p class="message"{}
|
|
|
|
button type="submit" onclick="setClientSettings()"{"Save"}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
script src="static/settings.js"{}
|
|
|
|
script src="static/cookies.js"{}
|
|
|
|
(footer())
|
|
|
|
))
|
|
|
|
}
|