From a596c075472b94b13f8c03c2806b842121b9907f Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sun, 6 Aug 2023 20:31:30 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=A7=20chore:=20add=20code=20to=20c?= =?UTF-8?q?ache=20the=20previous=20&=20next=20pages=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/routes.rs | 47 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/src/server/routes.rs b/src/server/routes.rs index 0b07115..c203e20 100644 --- a/src/server/routes.rs +++ b/src/server/routes.rs @@ -13,6 +13,7 @@ use crate::{ use actix_web::{get, web, HttpRequest, HttpResponse}; use handlebars::Handlebars; use serde::Deserialize; +use tokio::join; /// A named struct which deserializes all the user provided search parameters and stores them. /// @@ -96,15 +97,49 @@ pub async fn search( } let page = match ¶ms.page { Some(page) => *page, - None => 0, + None => 1, }; - let url = format!( - "http://{}:{}/search?q={}&page={}", - config.binding_ip, config.port, query, page + let (_, results, _) = join!( + results( + format!( + "http://{}:{}/search?q={}&page={}", + config.binding_ip, + config.port, + query, + page - 1 + ), + &config, + query.to_string(), + page - 1, + req.clone(), + ), + results( + format!( + "http://{}:{}/search?q={}&page={}", + config.binding_ip, config.port, query, page + ), + &config, + query.to_string(), + page, + req.clone(), + ), + results( + format!( + "http://{}:{}/search?q={}&page={}", + config.binding_ip, + config.port, + query, + page + 1 + ), + &config, + query.to_string(), + page + 1, + req.clone(), + ) ); - let results_json = results(url, &config, query.to_string(), page, req).await?; - let page_content: String = hbs.render("search", &results_json)?; + + let page_content: String = hbs.render("search", &results?)?; Ok(HttpResponse::Ok().body(page_content)) } None => Ok(HttpResponse::Found() From f68d9ab44247ea7e60155653c7b7dd8233731c7b Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sun, 6 Aug 2023 20:33:42 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=80=20chore:=20bump=20the=20app=20?= =?UTF-8?q?version=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 34 +++++++++++++++++----------------- Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e2688a..aac4c9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1817,9 +1817,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "openssl" -version = "0.10.55" +version = "0.10.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" +checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" dependencies = [ "bitflags 1.3.2", "cfg-if 1.0.0", @@ -1849,9 +1849,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.90" +version = "0.9.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" +checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" dependencies = [ "cc", "libc", @@ -2090,9 +2090,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "2c516611246607d0c04186886dbb3a754368ef82c79e9827a802c6d836dd111c" [[package]] name = "pin-utils" @@ -2391,9 +2391,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ "aho-corasick", "memchr", @@ -2403,9 +2403,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ "aho-corasick", "memchr", @@ -2539,9 +2539,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.6" +version = "0.38.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee020b1716f0a80e2ace9b03441a749e402e86712f15f16fe8a8f75afac732f" +checksum = "172891ebdceb05aa0005f533a6cbfca599ddd7d966f6f5d4d9b2e70478e70399" dependencies = [ "bitflags 2.3.3", "errno", @@ -2684,18 +2684,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.180" +version = "1.0.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" +checksum = "bdb30a74471f5b7a1fa299f40b4bf1be93af61116df95465b2b5fc419331e430" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.180" +version = "1.0.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" +checksum = "6f4c2c6ea4bc09b5c419012eafcdb0fcef1d9119d626c8f3a0708a5b92d38a70" dependencies = [ "proc-macro2 1.0.66", "quote 1.0.32", @@ -3534,7 +3534,7 @@ dependencies = [ [[package]] name = "websurfx" -version = "0.16.1" +version = "0.16.5" dependencies = [ "actix-cors", "actix-files", diff --git a/Cargo.toml b/Cargo.toml index bec4799..866f3ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "websurfx" -version = "0.16.1" +version = "0.16.5" edition = "2021" description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind." repository = "https://github.com/neon-mmd/websurfx"