From 270283eb61716fa51c0c9b96ef3e00d23eb94dc9 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 20 Jun 2024 16:08:57 +0200 Subject: add more info --- readme.md | 16 ++++++++++++++-- sample_config.yaml | 16 ++++++++++++++++ src/info.rs | 16 ++++++++++------ src/main.rs | 1 - src/state.rs | 8 +++++++- 5 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 sample_config.yaml diff --git a/readme.md b/readme.md index 05b61cc..ef98b75 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,16 @@ # meta adservices -A funny adservice. To promote each others free software projects or websites like one would in -a webring. +A funny adservice. To promote each others free software projects or websites +like one would in a webring. + +## Usage + +1. Build with cargo: `cargo build --release` +2. Write a configuration file. See [sample_config.yaml](./sample_config.yaml) +3. Run it: `meta-adservices your_config.yaml` + +Ask questions in issues or [contact me](https://metamuffin.org/contact). + +## License + +AGPL-3.0-only; See [COPYING](./COPYING) diff --git a/sample_config.yaml b/sample_config.yaml new file mode 100644 index 0000000..4c5b0bb --- /dev/null +++ b/sample_config.yaml @@ -0,0 +1,16 @@ +bloom_filter_size: 10000 +impression_weight_falloff: 0.95 +leaderboard_weight_threshold: 16 +database_path: /path/to/data +port: 8080 +image_base: /path/to/ads_dir +ads: + one: + image: image-one.avif + target: "https://example.org/" + two: + image: image-two.avif + target: "https://example.org/" + three: + image: image-three.avif + target: "https://example.org/" diff --git a/src/info.rs b/src/info.rs index f0cda28..d082d4d 100644 --- a/src/info.rs +++ b/src/info.rs @@ -20,7 +20,9 @@ pub async fn r_index<'a>(state: &State>) -> MyResult(state: &State>) -> MyResult(state: &State>) -> MyResult(state: &State>) -> MyResult 16 { + while d + .last() + .map(|l| l.2 < self.config.leaderboard_weight_threshold) + .unwrap_or_default() + || d.len() > 64 + { d.pop(); } -- cgit v1.2.3-70-g09d2