diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml new file mode 100644 index 0000000..fcb0277 --- /dev/null +++ b/.github/workflows/contributors.yml @@ -0,0 +1,47 @@ +name: Contributors List + +on: + workflow_dispatch: + + schedule: + - cron: "0 1 * * *" + +jobs: + contributors: + permissions: + contents: write + pull-requests: write + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + with: + fetch-depth: 0 + ref: ${{ github.event.repository.default_branch }} + + - name: Update contributors list + uses: wow-actions/contributors-list@b9e91f91a51a55460fdcae64daad0cb8122cdd53 # v1.1.0 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + svgPath: images/contributors_list.svg + round: true + includeBots: false + noCommit: true + + - name: Commit & PR + uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # v4.2.4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + add-paths: .github/assets/CONTRIBUTORS.svg + commit-message: 'chore: update contributors-list' + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: false + branch: workflow/update-contributors-list + base: main + delete-branch: true + title: 'chore: update contributors-list' + body: | + Automated update to `images/contributors_list.svg` \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e35e94c..9af7c18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,7 +125,7 @@ dependencies = [ "actix-utils", "futures-core", "futures-util", - "mio 0.8.6", + "mio 0.8.7", "num_cpus", "socket2", "tokio 1.28.2", @@ -1510,14 +1510,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "eebffdb73fe72e917997fad08bdbf31ac50b0fa91cec93e69a0662e4264d454c" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1603,9 +1603,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" [[package]] name = "openssl" @@ -2879,7 +2879,7 @@ dependencies = [ "autocfg 1.1.0", "bytes 1.4.0", "libc", - "mio 0.8.6", + "mio 0.8.7", "num_cpus", "parking_lot 0.12.1", "pin-project-lite", @@ -3316,7 +3316,7 @@ dependencies = [ [[package]] name = "websurfx" -version = "0.10.0" +version = "0.11.0" dependencies = [ "actix-files", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 8d8d452..17aa0a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "websurfx" -version = "0.10.0" +version = "0.11.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/docs/configuration.md b/docs/configuration.md index a5391a3..0d54fd9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -21,6 +21,7 @@ Some of the configuration options provided in the file are stated below. These a # General - **logging:** An option to enable or disable logs. +- **debug:** An option to enable or disable debug mode. ## Server diff --git a/docs/installation.md b/docs/installation.md index 1a04254..fbb0d16 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -78,6 +78,7 @@ After that edit the config.lua file located under `websurfx` directory. In the c ```lua -- ### General ### logging = true -- an option to enable or disable logs. +debug = false -- an option to enable or disable debug mode. -- ### Server ### port = "8080" -- port on which server should be launched diff --git a/src/bin/websurfx.rs b/src/bin/websurfx.rs index ca05713..8661725 100644 --- a/src/bin/websurfx.rs +++ b/src/bin/websurfx.rs @@ -19,7 +19,7 @@ async fn main() -> std::io::Result<()> { let config = Config::parse().unwrap(); // Initializing logging middleware with level set to default or info. - if config.logging { + if config.logging || config.debug { use env_logger::Env; env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); } diff --git a/src/config_parser/parser.rs b/src/config_parser/parser.rs index dd92f1b..ac200cd 100644 --- a/src/config_parser/parser.rs +++ b/src/config_parser/parser.rs @@ -26,6 +26,7 @@ pub struct Config { pub redis_connection_url: String, pub aggregator: AggreatorConfig, pub logging: bool, + pub debug: bool, } /// Configuration options for the aggregator. @@ -73,6 +74,7 @@ impl Config { redis_connection_url: globals.get::<_, String>("redis_connection_url")?, aggregator: aggregator_config, logging: globals.get::<_, bool>("logging")?, + debug: globals.get::<_, bool>("debug")?, }) }) } diff --git a/src/search_results_handler/aggregator.rs b/src/search_results_handler/aggregator.rs index 8b86972..8b6bae3 100644 --- a/src/search_results_handler/aggregator.rs +++ b/src/search_results_handler/aggregator.rs @@ -40,12 +40,13 @@ pub async fn aggregate( query: &str, page: u32, random_delay: bool, + debug: bool, ) -> Result> { let user_agent: String = random_user_agent(); let mut result_map: HashMap = HashMap::new(); // Add a random delay before making the request. - if random_delay { + if random_delay || !debug { let mut rng = rand::thread_rng(); let delay_secs = rng.gen_range(1..10); std::thread::sleep(Duration::from_secs(delay_secs)); diff --git a/src/server/routes.rs b/src/server/routes.rs index ead1612..9234d8d 100644 --- a/src/server/routes.rs +++ b/src/server/routes.rs @@ -128,7 +128,7 @@ pub async fn search( } Err(_) => { let mut results_json: crate::search_results_handler::aggregation_models::SearchResults = - aggregate(query, page, config.aggregator.random_delay).await?; + aggregate(query, page, config.aggregator.random_delay, config.debug).await?; results_json.add_style(config.style.clone()); redis_cache .cache_results(serde_json::to_string(&results_json)?, &page_url)?; diff --git a/websurfx/config.lua b/websurfx/config.lua index 29c4fff..3daaa91 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -1,5 +1,6 @@ -- ### General ### logging = true -- an option to enable or disable logs. +debug = false -- an option to enable or disable debug mode. -- ### Server ### port = "8080" -- port on which server should be launched