aboutsummaryrefslogtreecommitdiff
path: root/src/info.rs
blob: 1e5d8d9a230cefc57abb7d0f56ed1e8f1c0ea2ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use crate::error::MyResult;
use crate::{s_file, state::Logic, Template};
use markup::{doctype, DynRender};
use rocket::{get, http::ContentType, State};
use std::sync::Arc;

#[get("/")]
pub async fn r_index<'a>(state: &State<Arc<Logic>>) -> MyResult<Template<DynRender<'a>>> {
    let leaderboard = state.get_leaderboard().await?;
    Ok(Template(markup::new! {
        @doctype()
        html {
            head {
                title { "meta adservices" }
                meta[name="viewport", content="width=device-width, initial-scale=1.0"];
                meta[name="description", content="advertise now with meta adservices"];
                link[rel="stylesheet", href="/style.css"];
            }
            body {
                h1 { "meta adservices" }
                p {
                    "meta adservices is the leading provider of useless images within iframes. "
                    "meta adservices is inspired by " a[href="https://john.citrons.xyz/"]{"johnvertisement"}
                }
                h2 { "sample ad" }
                iframe[src="/v1/embed?s=adservices.metamuffin.org", style="border:none;width:728px;height:90px;"] {}
                h2 { "use meta ads" }
                p { "Use meta ads by inserting the following iframe:" }
                code { pre { "<iframe src=\"https://adservices.metamuffin.org/v1/embed?s=example.org\", style=\"border:none;width:728px;height:90px;\"></iframe>" } }
                p { "You SHOULD replace " code {"example.org"} " with your domain." }
                h2 { "create meta ads" }
                p {
                    "Send mail to " a[href="mailto:metamuffin@disroot.org"]{"metamuffin@disroot.org"} "." br;
                    "The mail MUST contain a ad name, ad image, URL to direct those who click it and optionally ad author name. " br;
                    "Some ads will be rejected for any or no reason at all. "
                    "To create good ads, consider the following statements in the context of your ad: "
                    ol {
                        li { "It is funny, amusing or enigmatic in some way." }
                        li { "It doesn't break any laws." }
                        li { "The image is compressed losslessly." }
                        li { "The image has a resolution of exactly 728x90." }
                        li { "The image uses the sRGB color space." }
                        li { "The image contains no nonfree assets." }
                        li { "The image, URL or names should be free of malware" }
                    }
                }
                h2 { "leaderboard" }
                table {
                    tr { th { "Domain" } th { "Impressions" } th { "Impression weight" } }
                    @for (domain, raw, weighted) in &leaderboard {
                        tr {
                            td { @domain }
                            td { @raw }
                            td { @weighted }
                        }
                    }
                }
                h2 { "privacy" }
                p { "data used by meta adservices: " }
                ul {
                    li { "Your IP address" }
                    li { "The Advertisement site (where the ad was shown)" }
                }
                p { "data stored by meta adservices: " }
                ul {
                    li { "Your IP address is used within a bloom filter in volatile memory." }
                    li { "Your requests increments a persistent public counter per ad site (according to a weighting function)." }
                }
            }
        }
    }))
}

#[get("/style.css")]
pub fn r_style() -> (ContentType, String) {
    (ContentType::CSS, s_file!("style.css"))
}

#[cfg(not(debug_assertions))]
#[macro_export]
macro_rules! s_file {
    ($path: literal) => {
        include_str!($path).to_string()
    };
}
#[cfg(debug_assertions)]
#[macro_export]
macro_rules! s_file {
    ($path: literal) => {
        std::fs::read_to_string(concat!("src/", $path)).unwrap()
    };
}