diff options
Diffstat (limited to 'src/info.rs')
-rw-r--r-- | src/info.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/info.rs b/src/info.rs index c3fa0a9..1e5d8d9 100644 --- a/src/info.rs +++ b/src/info.rs @@ -1,10 +1,13 @@ -use crate::{s_file, Template}; +use crate::error::MyResult; +use crate::{s_file, state::Logic, Template}; use markup::{doctype, DynRender}; -use rocket::{get, http::ContentType}; +use rocket::{get, http::ContentType, State}; +use std::sync::Arc; #[get("/")] -pub fn r_index<'a>() -> Template<DynRender<'a>> { - Template(markup::new! { +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 { @@ -41,6 +44,17 @@ pub fn r_index<'a>() -> Template<DynRender<'a>> { 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 { @@ -54,7 +68,7 @@ pub fn r_index<'a>() -> Template<DynRender<'a>> { } } } - }) + })) } #[get("/style.css")] |