mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-21 21:48:21 -05:00
Merge branch 'rolling' of https://github.com/sam-sunder/websurfx into rolling
This commit is contained in:
commit
fd798e665f
47
.github/workflows/contributors.yml
vendored
Normal file
47
.github/workflows/contributors.yml
vendored
Normal file
@ -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 <noreply@github.com>
|
||||
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`
|
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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")?,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -40,12 +40,13 @@ pub async fn aggregate(
|
||||
query: &str,
|
||||
page: u32,
|
||||
random_delay: bool,
|
||||
debug: bool,
|
||||
) -> Result<SearchResults, Box<dyn std::error::Error>> {
|
||||
let user_agent: String = random_user_agent();
|
||||
let mut result_map: HashMap<String, RawSearchResult> = 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));
|
||||
|
@ -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)?;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user