♻️ refactor(maud): rewrite the frontend code with maud html framework (#302)
This commit is contained in:
parent
beb5e6012a
commit
0ec89146c8
32 changed files with 527 additions and 317 deletions
21
src/templates/partials/settings_tabs/cookies.rs
Normal file
21
src/templates/partials/settings_tabs/cookies.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
//!
|
||||
|
||||
use maud::{html, Markup};
|
||||
|
||||
///
|
||||
pub fn cookies() -> Markup {
|
||||
html!(
|
||||
div class="cookies tab"{
|
||||
h1{"Cookies"}
|
||||
p class="description"{
|
||||
"This is the cookies are saved on your system and it contains the preferences
|
||||
you chose in the settings page"
|
||||
}
|
||||
input type="text" name="cookie_field" value="" readonly;
|
||||
p class="description"{
|
||||
"The cookies stored are not used by us for any malicious intend or for
|
||||
tracking you in any way."
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
35
src/templates/partials/settings_tabs/engines.rs
Normal file
35
src/templates/partials/settings_tabs/engines.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
//!
|
||||
|
||||
use maud::{html, Markup};
|
||||
|
||||
///
|
||||
pub fn engines(engine_names: &[&String]) -> Markup {
|
||||
html!(
|
||||
div class="engines tab"{
|
||||
h1{"Engines"}
|
||||
h3{"select search engines"}
|
||||
p class="description"{
|
||||
"Select the search engines from the list of engines that you want results from"
|
||||
}
|
||||
.engine_selection{
|
||||
.toggle_btn{
|
||||
label class="switch"{
|
||||
input type="checkbox" class="select_all" onchange="toggleAllSelection()";
|
||||
span class="slider round"{}
|
||||
}
|
||||
"Select All"
|
||||
}
|
||||
hr;
|
||||
@for engine_name in engine_names{
|
||||
.toggle_btn{
|
||||
label class="switch"{
|
||||
input type="checkbox" class="engine";
|
||||
span class="slider round"{}
|
||||
}
|
||||
(format!("{}{}",engine_name[..1].to_uppercase().to_owned(), engine_name[1..].to_owned()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
23
src/templates/partials/settings_tabs/general.rs
Normal file
23
src/templates/partials/settings_tabs/general.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
//!
|
||||
|
||||
use maud::{html, Markup};
|
||||
|
||||
const SAFE_SEARCH_LEVELS: [(u8, &'static str); 3] = [(0, "None"), (1, "Low"), (2, "Moderate")];
|
||||
|
||||
///
|
||||
pub fn general() -> Markup {
|
||||
html!(
|
||||
div class="general tab active"{
|
||||
h1{"General"}
|
||||
h3{"Select a safe search level"}
|
||||
p class="description"{
|
||||
"Select a safe search level from the menu below to filter content based on the level."
|
||||
}
|
||||
select name="safe_search_levels"{
|
||||
@for (k,v) in SAFE_SEARCH_LEVELS{
|
||||
option value=(k){(v)}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
6
src/templates/partials/settings_tabs/mod.rs
Normal file
6
src/templates/partials/settings_tabs/mod.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
//!
|
||||
|
||||
pub mod general;
|
||||
pub mod engines;
|
||||
pub mod cookies;
|
||||
pub mod user_interface;
|
48
src/templates/partials/settings_tabs/user_interface.rs
Normal file
48
src/templates/partials/settings_tabs/user_interface.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
//!
|
||||
|
||||
use crate::handler::paths::{file_path, FileType};
|
||||
use maud::{html, Markup};
|
||||
use std::fs::read_dir;
|
||||
|
||||
fn style_option_list(
|
||||
style_type: &str,
|
||||
) -> Result<Vec<(String, String)>, Box<dyn std::error::Error + '_>> {
|
||||
let mut style_option_names: Vec<(String, String)> = Vec::new();
|
||||
for file in read_dir(format!(
|
||||
"{}static/{}/",
|
||||
file_path(FileType::Theme)?,
|
||||
style_type,
|
||||
))? {
|
||||
let style_name = file?.file_name().to_str().unwrap().replace(".css", "");
|
||||
style_option_names.push((style_name.clone(), style_name.replace("-", " ")));
|
||||
}
|
||||
|
||||
Ok(style_option_names)
|
||||
}
|
||||
|
||||
///
|
||||
pub fn user_interface() -> Result<Markup, Box<dyn std::error::Error>> {
|
||||
Ok(html!(
|
||||
div class="user_interface tab"{
|
||||
h1{"User Interface"}
|
||||
h3{"select theme"}
|
||||
p class="description"{
|
||||
"Select the theme from the available themes to be used in user interface"
|
||||
}
|
||||
select name="themes"{
|
||||
@for (k,v) in style_option_list("themes")?{
|
||||
option value=(k){(v)}
|
||||
}
|
||||
}
|
||||
h3{"select color scheme"}
|
||||
p class="description"{
|
||||
"Select the color scheme for your theme to be used in user interface"
|
||||
}
|
||||
select name="colorschemes"{
|
||||
@for (k,v) in style_option_list("colorschemes")?{
|
||||
option value=(k){(v)}
|
||||
}
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue