💡 chore: add documentation to the code (#302)
This commit is contained in:
parent
38ba4bd6cb
commit
c1a5b7086a
18 changed files with 154 additions and 29 deletions
|
@ -1,8 +1,17 @@
|
|||
//!
|
||||
//! A module that handles `bar` partial for the `search_bar` partial and the home/index/main page in the `websurfx` frontend.
|
||||
|
||||
use maud::{html, Markup,PreEscaped};
|
||||
use maud::{html, Markup, PreEscaped};
|
||||
|
||||
/// A functions that handles the html code for the bar for the `search_bar` partial and the
|
||||
/// home/index/main page in the search engine frontend.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `query` - It takes the current search query provided by user as an argument.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html code for the search bar as a result.
|
||||
pub fn bar(query: &str) -> Markup {
|
||||
html!(
|
||||
(PreEscaped("<div class=\"search_bar\">"))
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
//!
|
||||
//! A module that handles the footer for all the pages in the `websurfx` frontend.
|
||||
|
||||
use maud::{html, Markup, PreEscaped};
|
||||
|
||||
/// A functions that handles the html code for the footer for all the pages in the search engine
|
||||
/// frontend.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html code for the footer as a result.
|
||||
pub fn footer() -> Markup {
|
||||
html!(
|
||||
footer{
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
//!
|
||||
//! A module that handles the header for all the pages in the `websurfx` frontend.
|
||||
|
||||
use crate::templates::partials::navbar::navbar;
|
||||
use maud::{html, Markup, PreEscaped, DOCTYPE};
|
||||
|
||||
/// A function that handles the html code for the header for all the pages in the search engine frontend.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `colorscheme` - It takes the colorscheme name as an argument.
|
||||
/// * `theme` - It takes the theme name as an argument.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html markup code for the header as a result.
|
||||
pub fn header(colorscheme: &str, theme: &str) -> Markup {
|
||||
html!(
|
||||
(DOCTYPE)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//!
|
||||
//! This module provides other modules to handle the partials for the views in the `websurfx` frontend.
|
||||
|
||||
pub mod bar;
|
||||
pub mod footer;
|
||||
pub mod header;
|
||||
pub mod navbar;
|
||||
pub mod bar;
|
||||
pub mod settings_tabs;
|
||||
pub mod search_bar;
|
||||
pub mod settings_tabs;
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
//!
|
||||
//! A module that handles `navbar` partial for the header partial in the `websurfx` frontend.
|
||||
|
||||
use maud::{html, Markup};
|
||||
|
||||
/// A functions that handles the html code for the header partial.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html code for the navbar as a result.
|
||||
pub fn navbar() -> Markup {
|
||||
html!(
|
||||
nav{
|
||||
|
|
|
@ -1,12 +1,24 @@
|
|||
//!
|
||||
//! A module that handles `search bar` partial for the search page in the `websurfx` frontend.
|
||||
|
||||
use maud::{html, Markup, PreEscaped};
|
||||
|
||||
use crate::{models::aggregation_models::EngineErrorInfo, templates::partials::bar::bar};
|
||||
|
||||
/// A constant holding the named safe search level options for the corresponding values 0, 1 and 2.
|
||||
const SAFE_SEARCH_LEVELS_NAME: [&str; 3] = ["None", "Low", "Moderate"];
|
||||
|
||||
/// A functions that handles the html code for the search bar for the search page.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `engine_errors_info` - It takes the engine errors list containing errors for each upstream
|
||||
/// search engine which failed to provide results as an argument.
|
||||
/// * `safe_search_level` - It takes the safe search level with values from 0-2 as an argument.
|
||||
/// * `query` - It takes the current search query provided by user as an argument.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html code for the search bar as a result.
|
||||
pub fn search_bar(
|
||||
engine_errors_info: &[EngineErrorInfo],
|
||||
safe_search_level: u8,
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
//!
|
||||
//! A module that handles the engines tab for setting page view in the `websurfx` frontend.
|
||||
|
||||
use maud::{html, Markup};
|
||||
|
||||
/// A functions that handles the html code for the cookies tab for the settings page for the search page.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html markup code for the cookies tab.
|
||||
pub fn cookies() -> Markup {
|
||||
html!(
|
||||
div class="cookies tab"{
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
//!
|
||||
//! A module that handles the engines tab for setting page view in the `websurfx` frontend.
|
||||
|
||||
use maud::{html, Markup};
|
||||
|
||||
/// A functions that handles the html code for the engines tab for the settings page for the search page.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `engine_names` - It takes the list of all available engine names as an argument.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html markup code for the engines tab.
|
||||
pub fn engines(engine_names: &[&String]) -> Markup {
|
||||
html!(
|
||||
div class="engines tab"{
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
//!
|
||||
//! A module that handles the general tab for setting page view in the `websurfx` frontend.
|
||||
|
||||
use maud::{html, Markup};
|
||||
|
||||
const SAFE_SEARCH_LEVELS: [(u8, &'static str); 3] = [(0, "None"), (1, "Low"), (2, "Moderate")];
|
||||
/// A constant holding the named safe search level options for the corresponding values 0, 1 and 2.
|
||||
const SAFE_SEARCH_LEVELS: [(u8, &str); 3] = [(0, "None"), (1, "Low"), (2, "Moderate")];
|
||||
|
||||
/// A functions that handles the html code for the general tab for the settings page for the search page.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// It returns the compiled html markup code for the general tab.
|
||||
pub fn general() -> Markup {
|
||||
html!(
|
||||
div class="general tab active"{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//!
|
||||
//! This module provides other modules to handle the partials for the tabs for the settings page
|
||||
//! view in the `websurfx` frontend.
|
||||
|
||||
pub mod general;
|
||||
pub mod engines;
|
||||
pub mod cookies;
|
||||
pub mod engines;
|
||||
pub mod general;
|
||||
pub mod user_interface;
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
//!
|
||||
//! A module that handles the user interface tab for setting page view in the `websurfx` frontend.
|
||||
|
||||
use crate::handler::paths::{file_path, FileType};
|
||||
use maud::{html, Markup};
|
||||
use std::fs::read_dir;
|
||||
|
||||
/// A helper function that helps in building the list of all available colorscheme/theme names
|
||||
/// present in the colorschemes and themes folder respectively.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `style_type` - It takes the style type of the values `theme` and `colorscheme` as an
|
||||
/// argument.
|
||||
///
|
||||
/// # Error
|
||||
///
|
||||
/// Returns a list of colorscheme/theme names as a vector of tuple strings on success otherwise
|
||||
/// returns a standard error message.
|
||||
fn style_option_list(
|
||||
style_type: &str,
|
||||
) -> Result<Vec<(String, String)>, Box<dyn std::error::Error + '_>> {
|
||||
|
@ -14,13 +26,18 @@ fn style_option_list(
|
|||
style_type,
|
||||
))? {
|
||||
let style_name = file?.file_name().to_str().unwrap().replace(".css", "");
|
||||
style_option_names.push((style_name.clone(), style_name.replace("-", " ")));
|
||||
style_option_names.push((style_name.clone(), style_name.replace('-', " ")));
|
||||
}
|
||||
|
||||
Ok(style_option_names)
|
||||
}
|
||||
|
||||
/// A functions that handles the html code for the user interface tab for the settings page for the search page.
|
||||
///
|
||||
/// # Error
|
||||
///
|
||||
/// It returns the compiled html markup code for the user interface tab on success otherwise
|
||||
/// returns a standard error message.
|
||||
pub fn user_interface() -> Result<Markup, Box<dyn std::error::Error>> {
|
||||
Ok(html!(
|
||||
div class="user_interface tab"{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue