From 7f7367a34d62ac7aefc33ef39fa01f264df82ba1 Mon Sep 17 00:00:00 2001 From: morrigan Date: Sun, 16 Feb 2025 16:35:39 +0100 Subject: [PATCH] remove github stuf --- .github/dependabot.yml | 14 ------------ public/static/themes/simple.css | 36 ++++++++++++++--------------- src/models/server_models.rs | 2 +- src/results/aggregator.rs | 4 +--- src/server/routes/search.rs | 5 ++-- src/templates/partials/bar.rs | 39 ++++++++++++++++++++++++++------ src/templates/partials/header.rs | 5 +--- src/templates/partials/mod.rs | 1 - src/templates/partials/navbar.rs | 19 ---------------- src/templates/views/index.rs | 14 ++++-------- src/templates/views/search.rs | 2 +- 11 files changed, 61 insertions(+), 80 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 src/templates/partials/navbar.rs diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index dc1715a..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "cargo" - directory: "/" - schedule: - interval: "monthly" - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "monthly" - - package-ecosystem: "docker" - directory: "/" - schedule: - interval: "monthly" diff --git a/public/static/themes/simple.css b/public/static/themes/simple.css index 8f5fcc7..770cb04 100644 --- a/public/static/themes/simple.css +++ b/public/static/themes/simple.css @@ -35,19 +35,19 @@ button { /* styles for the index page */ -.search-container { +.search_container { display: flex; - flex-direction: column; + flex-direction: row; gap: 5rem; justify-content: center; align-items: center; } -.search-container svg { +.search_container svg { color: var(--logo-color); } -.search-container div { +.search_container div { display: flex; } @@ -102,10 +102,10 @@ button { } .search_bar button img { - position:absolute; - left:50%; - top:50%; - transform:translate(-50%, -50%); + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); } .search_bar button:active { @@ -336,7 +336,7 @@ footer div { .results_aggregated { display: flex; flex-direction: column; - justify-content: space-between; + justify-content: space-between; margin: 2rem 0; content-visibility: auto; } @@ -593,7 +593,7 @@ footer div { font-size: 2.5rem; } -.settings > h1 { +.settings>h1 { margin-bottom: 4rem; margin-left: 2rem; } @@ -603,7 +603,7 @@ footer div { margin: 0.3rem 0 1rem; } -.settings > hr { +.settings>hr { margin-left: 2rem; } @@ -796,15 +796,15 @@ footer div { transition: .2s; } -input:checked + .slider { +input:checked+.slider { background-color: var(--color-three); } -input:focus + .slider { +input:focus+.slider { box-shadow: 0 0 1px var(--color-three); } -input:checked + .slider::before { +input:checked+.slider::before { transform: translateX(2.6rem); } @@ -817,7 +817,7 @@ input:checked + .slider::before { border-radius: 50%; } -@media screen and (width <= 1136px) { +@media screen and (width <=1136px) { .hero-text-container { width: unset; } @@ -827,7 +827,7 @@ input:checked + .slider::before { } } -@media screen and (width <= 706px) { +@media screen and (width <=706px) { .about-container article .logo-container svg { width: clamp(200px, 290px, 815px); } @@ -851,7 +851,7 @@ input:checked + .slider::before { .features { grid-template-columns: 1fr; } - + .feature-list { padding: 35px 0; } @@ -859,4 +859,4 @@ input:checked + .slider::before { .feature-card { border-radius: 0; } -} +} \ No newline at end of file diff --git a/src/models/server_models.rs b/src/models/server_models.rs index 81de741..c73352c 100644 --- a/src/models/server_models.rs +++ b/src/models/server_models.rs @@ -7,7 +7,7 @@ use serde::Deserialize; pub struct SearchParams { /// It stores the search parameter option `q` (or query in simple words) /// of the search url. - pub q: Option, + pub query: Option, /// It stores the search parameter `page` (or pageno in simple words) /// of the search url. pub page: Option, diff --git a/src/results/aggregator.rs b/src/results/aggregator.rs index 7386bb2..a7116c6 100644 --- a/src/results/aggregator.rs +++ b/src/results/aggregator.rs @@ -147,9 +147,7 @@ pub async fn aggregate( }; } - let mut results: Vec = - result_map.iter().map(|(_, value)| value.clone()).collect(); + let results: Vec = result_map.iter().map(|(_, value)| value.clone()).collect(); - results.sort_by(|a, b| a.description.len().cmp(&b.description.len())); Ok(SearchResults::new(results, &engine_errors_info)) } diff --git a/src/server/routes/search.rs b/src/server/routes/search.rs index ae6cf74..d2f34af 100644 --- a/src/server/routes/search.rs +++ b/src/server/routes/search.rs @@ -35,13 +35,14 @@ pub async fn search( ) -> Result> { let params = web::Query::::from_query(req.query_string())?; - if params.q.as_ref().is_some_and(|q| q.trim().is_empty()) || params.q.is_none() { + if params.query.as_ref().is_some_and(|q| q.trim().is_empty()) || params.query.is_none() { + log::info!("wha!"); return Ok(HttpResponse::TemporaryRedirect() .insert_header(("location", "/")) .finish()); } - let query = params.q.as_ref().unwrap().trim(); + let query = params.query.as_ref().unwrap().trim(); let cookie = req.cookie("appCookie"); diff --git a/src/templates/partials/bar.rs b/src/templates/partials/bar.rs index 7fb71d9..1ad9288 100644 --- a/src/templates/partials/bar.rs +++ b/src/templates/partials/bar.rs @@ -1,6 +1,6 @@ //! A module that handles `bar` partial for the `search_bar` partial and the home/index/main page in the `crabbysearch` frontend. -use maud::{html, Markup, PreEscaped}; +use maud::{html, Markup}; /// 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. @@ -12,15 +12,40 @@ use maud::{html, Markup, PreEscaped}; /// # Returns /// /// It returns the compiled html code for the search bar as a result. -pub fn bar(query: &str) -> Markup { +pub fn bar(query: &str, engines: Vec<(&'static str, bool)>) -> Markup { html!( .search_container { - (PreEscaped("
")) form action="/search" method="get" { - input type="search" name="query" value=(query) placeholder="Type to search"; - input type="hidden" name="page" value="0"; - button type="submit" { - img src="./images/magnifying_glass.svg" alt="Info icon for error box"; + div class="search_bar" { + input type="search" name="query" value=(query) placeholder="Type to search"; + input type="hidden" name="page" value="1"; + button type="submit" { + img src="./images/magnifying_glass.svg" alt="Info icon for error box"; + } + } + div class="search_bar" { + .engine_selection { + @for (name, selected) in engines{ + @if selected { + .toggle_btn{ + span {(name)} + label class="switch"{ + input type="checkbox" class="engine" checked; + span class="slider round"{} + } + } + } + @else { + .toggle_btn { + (name) + label class="switch"{ + input type="checkbox" class="engine"; + span class="slider round"{} + } + } + } + } + } } } } diff --git a/src/templates/partials/header.rs b/src/templates/partials/header.rs index 43dfe80..38e4de4 100644 --- a/src/templates/partials/header.rs +++ b/src/templates/partials/header.rs @@ -1,7 +1,6 @@ //! A module that handles the header for all the pages in the `crabbysearch` frontend. -use crate::templates::partials::navbar::navbar; -use maud::{html, Markup, PreEscaped, DOCTYPE}; +use maud::{html, Markup, DOCTYPE}; /// A function that handles the html code for the header for all the pages in the search engine frontend. /// @@ -26,10 +25,8 @@ pub fn header() -> Markup { link href=("static/themes/simple.css") rel="stylesheet" type="text/css"; } - (PreEscaped("")) header{ h1{a href="/"{"crabbysearch"}} - (navbar()) } ) } diff --git a/src/templates/partials/mod.rs b/src/templates/partials/mod.rs index 6aaab27..b2c71da 100644 --- a/src/templates/partials/mod.rs +++ b/src/templates/partials/mod.rs @@ -3,4 +3,3 @@ pub mod bar; pub mod footer; pub mod header; -pub mod navbar; diff --git a/src/templates/partials/navbar.rs b/src/templates/partials/navbar.rs deleted file mode 100644 index 92d6450..0000000 --- a/src/templates/partials/navbar.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! A module that handles `navbar` partial for the header partial in the `crabbysearch` 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{ - ul{ - li{a href="about"{"about"}} - li{a href="settings"{"settings"}} - } - } - ) -} diff --git a/src/templates/views/index.rs b/src/templates/views/index.rs index bcf5809..ac2a807 100644 --- a/src/templates/views/index.rs +++ b/src/templates/views/index.rs @@ -1,6 +1,6 @@ //! A module that handles the view for the index/home/main page in the `crabbysearch` frontend. -use maud::{html, Markup, PreEscaped}; +use maud::{html, Markup}; use crate::templates::partials::{bar::bar, footer::footer, header::header}; @@ -15,13 +15,7 @@ use crate::templates::partials::{bar::bar, footer::footer, header::header}; /// /// It returns the compiled html markup code as a result. pub fn index() -> Markup { - html!( - (header()) - main class="search-container"{ - (bar(&String::default())) - (PreEscaped("
")) - } - script src="static/index.js"{} - (footer()) - ) + html!((header())(bar(&String::default(), vec![("bing", true)]))( + footer() + )) } diff --git a/src/templates/views/search.rs b/src/templates/views/search.rs index 94ca508..254025c 100644 --- a/src/templates/views/search.rs +++ b/src/templates/views/search.rs @@ -23,7 +23,7 @@ pub fn search(query: &str, search_results: &SearchResults) -> Markup { html!( (header()) main class="results"{ - (bar(query)) + (bar(query, vec![("Bing", true)])) .results_aggregated{ @if !search_results.results.is_empty() { @for result in search_results.results.iter(){