From 71fae8b4967a57f6692bcd8e08c939f215e9b76a Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sun, 30 Apr 2023 20:04:31 +0300 Subject: [PATCH] add more colorschemes, fix tests and improve documentation --- public/static/colorschemes/catppuccin-mocha.css | 1 - public/static/colorschemes/dracula.css | 11 +++++++++++ public/static/colorschemes/gruvbox-dark.css | 11 +++++++++++ public/static/colorschemes/monokai.css | 11 +++++++++++ public/static/colorschemes/nord.css | 11 +++++++++++ public/static/colorschemes/oceanic-next.css | 11 +++++++++++ public/static/colorschemes/solarized-dark.css | 11 +++++++++++ public/static/colorschemes/solarized-light.css | 11 +++++++++++ public/static/colorschemes/tomorrow-night.css | 11 +++++++++++ src/lib.rs | 3 ++- src/search_results_handler/aggregation_models.rs | 2 +- tests/index.rs | 15 ++++++++------- websurfx/config.lua | 11 +++++++++++ 13 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 public/static/colorschemes/dracula.css create mode 100644 public/static/colorschemes/gruvbox-dark.css create mode 100644 public/static/colorschemes/monokai.css create mode 100644 public/static/colorschemes/nord.css create mode 100644 public/static/colorschemes/oceanic-next.css create mode 100644 public/static/colorschemes/solarized-dark.css create mode 100644 public/static/colorschemes/solarized-light.css create mode 100644 public/static/colorschemes/tomorrow-night.css diff --git a/public/static/colorschemes/catppuccin-mocha.css b/public/static/colorschemes/catppuccin-mocha.css index a53acc1..d2c1075 100644 --- a/public/static/colorschemes/catppuccin-mocha.css +++ b/public/static/colorschemes/catppuccin-mocha.css @@ -1,5 +1,4 @@ :root { - /* catppuccin-mocha colorscheme */ --bg: #1e1e2e; --fg: #cdd6f4; --1: #45475a; diff --git a/public/static/colorschemes/dracula.css b/public/static/colorschemes/dracula.css new file mode 100644 index 0000000..fb9c26c --- /dev/null +++ b/public/static/colorschemes/dracula.css @@ -0,0 +1,11 @@ +:root { + --bg: #44475a; + --fg: #8be9fd; + --1: #ff5555; + --2: #50fa7b; + --3: #ffb86c; + --4: #bd93f9; + --5: #ff79c6; + --6: #94a3a5; + --7: #ffffff; +} diff --git a/public/static/colorschemes/gruvbox-dark.css b/public/static/colorschemes/gruvbox-dark.css new file mode 100644 index 0000000..0b022a5 --- /dev/null +++ b/public/static/colorschemes/gruvbox-dark.css @@ -0,0 +1,11 @@ +:root { + --bg: #282828; + --fg: #ebdbb2; + --1: #cc241d; + --2: #98971a; + --3: #d79921; + --4: #458588; + --5: #b16286; + --6: #689d6a; + --7: #ffffff; +} diff --git a/public/static/colorschemes/monokai.css b/public/static/colorschemes/monokai.css new file mode 100644 index 0000000..2c7b738 --- /dev/null +++ b/public/static/colorschemes/monokai.css @@ -0,0 +1,11 @@ +:root { + --bg: #403e41; + --fg: #fcfcfa; + --1: #ff6188; + --2: #a9dc76; + --3: #ffd866; + --4: #fc9867; + --5: #ab9df2; + --6: #78dce8; + --7: #ffffff; +} diff --git a/public/static/colorschemes/nord.css b/public/static/colorschemes/nord.css new file mode 100644 index 0000000..cc0793f --- /dev/null +++ b/public/static/colorschemes/nord.css @@ -0,0 +1,11 @@ +:root { + --bg: #2e3440; + --fg: #d8dee9; + --1: #3b4252; + --2: #bf616a; + --3: #a3be8c; + --4: #ebcb8b; + --5: #81a1c1; + --6: #b48ead; + --7: #ffffff; +} diff --git a/public/static/colorschemes/oceanic-next.css b/public/static/colorschemes/oceanic-next.css new file mode 100644 index 0000000..e7e25b7 --- /dev/null +++ b/public/static/colorschemes/oceanic-next.css @@ -0,0 +1,11 @@ +:root { + --bg: #1b2b34; + --fg: #d8dee9; + --1: #343d46; + --2: #ec5f67; + --3: #99c794; + --4: #fac863; + --5: #6699cc; + --6: #c594c5; + --7: #ffffff; +} diff --git a/public/static/colorschemes/solarized-dark.css b/public/static/colorschemes/solarized-dark.css new file mode 100644 index 0000000..1cad24f --- /dev/null +++ b/public/static/colorschemes/solarized-dark.css @@ -0,0 +1,11 @@ +:root { + --bg: #002b36; + --fg: #839496; + --1: #073642; + --2: #dc322f; + --3: #859900; + --4: #b58900; + --5: #268bd2; + --6: #d33682; + --7: #ffffff; +} diff --git a/public/static/colorschemes/solarized-light.css b/public/static/colorschemes/solarized-light.css new file mode 100644 index 0000000..c6de267 --- /dev/null +++ b/public/static/colorschemes/solarized-light.css @@ -0,0 +1,11 @@ +:root { + --bg: #fdf6e3; + --fg: #657b83; + --1: #073642; + --2: #dc322f; + --3: #859900; + --4: #b58900; + --5: #268bd2; + --6: #d33682; + --7: #ffffff; +} diff --git a/public/static/colorschemes/tomorrow-night.css b/public/static/colorschemes/tomorrow-night.css new file mode 100644 index 0000000..05502bc --- /dev/null +++ b/public/static/colorschemes/tomorrow-night.css @@ -0,0 +1,11 @@ +:root { + --bg: #1d1f21; + --fg: #c5c8c6; + --1: #cc6666; + --2: #b5bd68; + --3: #f0c674; + --4: #81a2be; + --5: #b294bb; + --6: #8abeb7; + --7: #ffffff; +} diff --git a/src/lib.rs b/src/lib.rs index afa6a1c..5e7a332 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,8 +29,9 @@ use handlebars::Handlebars; /// /// ```rust /// use std::net::TcpListener; -/// use websurfx::run; +/// use websurfx::{config_parser::parser::Config, run}; /// +/// let config = Config::parse().unwrap(); /// let listener = TcpListener::bind("127.0.0.1:8080").expect("Failed to bind address"); /// let server = run(listener,config).expect("Failed to start server"); /// ``` diff --git a/src/search_results_handler/aggregation_models.rs b/src/search_results_handler/aggregation_models.rs index 2543b09..3d2e081 100644 --- a/src/search_results_handler/aggregation_models.rs +++ b/src/search_results_handler/aggregation_models.rs @@ -3,7 +3,7 @@ use serde::Serialize; -use crate::config_parser::parser::Style; +use crate::config_parser::parser_models::Style; /// A named struct to store and serialize the individual search result from all the scraped /// and aggregated search results from the upstream search engines. diff --git a/tests/index.rs b/tests/index.rs index d0a61fe..6ef11c4 100644 --- a/tests/index.rs +++ b/tests/index.rs @@ -1,15 +1,15 @@ use std::net::TcpListener; use handlebars::Handlebars; -use websurfx::run; - +use websurfx::{config_parser::parser::Config, run}; // Starts a new instance of the HTTP server, bound to a random available port fn spawn_app() -> String { // Binding to port 0 will trigger the OS to assign a port for us. let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port"); let port = listener.local_addr().unwrap().port(); - let server = run(listener).expect("Failed to bind address"); + let config = Config::parse().unwrap(); + let server = run(listener, config).expect("Failed to bind address"); tokio::spawn(server); format!("http://127.0.0.1:{}/", port) @@ -27,7 +27,6 @@ fn handlebars() -> Handlebars<'static> { handlebars } - #[tokio::test] async fn test_index() { let address = spawn_app(); @@ -35,8 +34,10 @@ async fn test_index() { let client = reqwest::Client::new(); let res = client.get(address).send().await.unwrap(); assert_eq!(res.status(), 200); - + let handlebars = handlebars(); - let template = handlebars.render("index", &()).unwrap(); + let config = Config::parse().unwrap(); + let template = handlebars.render("index", &config.style).unwrap(); assert_eq!(res.text().await.unwrap(), template); -} \ No newline at end of file +} + diff --git a/websurfx/config.lua b/websurfx/config.lua index a841292..cf28c13 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -3,5 +3,16 @@ port = "8080" -- port on which server should be launched binding_ip_addr = "127.0.0.1" --ip address on the which server should be launched. -- Website +-- The different colorschemes provided are: +-- {{ +-- catppuccin-mocha +-- dracula +-- monokai +-- nord +-- oceanic-next +-- solarized-dark +-- solarized-light +-- tomorrow-night +-- }} colorscheme = "catppuccin-mocha" -- the colorscheme name which should be used for the website theme theme = "simple" -- the theme name which should be used for the website