0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-21 21:48:21 -05:00

Merge branch 'rolling' into CHORE/461_display-the-user-provided-settings-from-the-config-or-the-ui-in-the-settings-page

This commit is contained in:
neon_arch 2023-12-28 21:04:21 +03:00 committed by GitHub
commit 93afb6b8c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 27 deletions

View File

@ -12,14 +12,16 @@ use std::fs::read_to_string;
/// Handles the route of index page or main page of the `websurfx` meta search engine website. /// Handles the route of index page or main page of the `websurfx` meta search engine website.
#[get("/")] #[get("/")]
pub async fn index(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> { pub async fn index(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> {
Ok(HttpResponse::Ok().body( Ok(HttpResponse::Ok()
crate::templates::views::index::index( .content_type("text/html; charset=utf-8")
&config.style.colorscheme, .body(
&config.style.theme, crate::templates::views::index::index(
&config.style.animation, &config.style.colorscheme,
) &config.style.theme,
.0, &config.style.animation,
)) )
.0,
))
} }
/// Handles the route of any other accessed route/page which is not provided by the /// Handles the route of any other accessed route/page which is not provided by the
@ -52,14 +54,16 @@ pub async fn robots_data(_req: HttpRequest) -> Result<HttpResponse, Box<dyn std:
/// Handles the route of about page of the `websurfx` meta search engine website. /// Handles the route of about page of the `websurfx` meta search engine website.
#[get("/about")] #[get("/about")]
pub async fn about(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> { pub async fn about(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn std::error::Error>> {
Ok(HttpResponse::Ok().body( Ok(HttpResponse::Ok()
crate::templates::views::about::about( .content_type("text/html; charset=utf-8")
&config.style.colorscheme, .body(
&config.style.theme, crate::templates::views::about::about(
&config.style.animation, &config.style.colorscheme,
) &config.style.theme,
.0, &config.style.animation,
)) )
.0,
))
} }
/// Handles the route of settings page of the `websurfx` meta search engine website. /// Handles the route of settings page of the `websurfx` meta search engine website.
@ -67,7 +71,9 @@ pub async fn about(config: web::Data<Config>) -> Result<HttpResponse, Box<dyn st
pub async fn settings( pub async fn settings(
config: web::Data<Config>, config: web::Data<Config>,
) -> Result<HttpResponse, Box<dyn std::error::Error>> { ) -> Result<HttpResponse, Box<dyn std::error::Error>> {
Ok(HttpResponse::Ok().body( Ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(
crate::templates::views::settings::settings( crate::templates::views::settings::settings(
config.safe_search, config.safe_search,
&config.style.colorscheme, &config.style.colorscheme,

View File

@ -68,16 +68,18 @@ pub async fn search(
get_results(page + 1) get_results(page + 1)
); );
Ok(HttpResponse::Ok().body( Ok(HttpResponse::Ok()
crate::templates::views::search::search( .content_type("text/html; charset=utf-8")
&config.style.colorscheme, .body(
&config.style.theme, crate::templates::views::search::search(
&config.style.animation, &config.style.colorscheme,
query, &config.style.theme,
&results?, &config.style.animation,
) query,
.0, &results?,
)) )
.0,
))
} }
None => Ok(HttpResponse::TemporaryRedirect() None => Ok(HttpResponse::TemporaryRedirect()
.insert_header(("location", "/")) .insert_header(("location", "/"))