From 0a8d36dc9fb546f1721a8ca3e2e34fb6c838e190 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sun, 25 Jul 2021 20:15:44 +0530 Subject: [PATCH] sitemap generates URL --- src/pages/panel/mod.rs | 5 ++++- src/pages/sitemap.rs | 9 ++++++++- src/static_assets/static_files.rs | 4 ++++ static/cache/img/svg/bar-chart.svg | 1 + templates/components/svg.html | 4 ---- templates/panel/navbar/index.html | 9 ++++++++- templates/sitemap.html | 16 ++++++++-------- 7 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 static/cache/img/svg/bar-chart.svg delete mode 100644 templates/components/svg.html diff --git a/src/pages/panel/mod.rs b/src/pages/panel/mod.rs index a1679de8..61b0900c 100644 --- a/src/pages/panel/mod.rs +++ b/src/pages/panel/mod.rs @@ -66,6 +66,7 @@ pub mod routes { pub sitekey: Sitekey, pub notifications: &'static str, pub settings: Settings, + pub stats: &'static str, } impl Panel { @@ -75,10 +76,11 @@ pub mod routes { sitekey: Sitekey::new(), notifications: "/notifications", settings: Settings::new(), + stats: "/stats", } } - pub const fn get_sitemap() -> [&'static str; 5] { + pub const fn get_sitemap() -> [&'static str; 6] { const PANEL: Panel = Panel::new(); const S: [&str; 2] = Sitekey::get_sitemap(); @@ -88,6 +90,7 @@ pub mod routes { S[0], S[1], Settings::get_sitemap()[0], + PANEL.stats, ] } } diff --git a/src/pages/sitemap.rs b/src/pages/sitemap.rs index 298ba413..4105ba28 100644 --- a/src/pages/sitemap.rs +++ b/src/pages/sitemap.rs @@ -26,12 +26,19 @@ use crate::PAGES; #[template(path = "sitemap.html")] struct IndexPage { urls: [&'static str; 7], + domain: &'static str, } impl Default for IndexPage { fn default() -> Self { let urls = Routes::get_sitemap(); - Self { urls } + let domain = if crate::SETTINGS.server.domain.ends_with('/') { + &crate::SETTINGS.server.domain[0..crate::SETTINGS.server.domain.len() - 1] + } else { + &crate::SETTINGS.server.domain + }; + + Self { urls, domain } } } diff --git a/src/static_assets/static_files.rs b/src/static_assets/static_files.rs index 0e5fdc49..4ece6973 100644 --- a/src/static_assets/static_files.rs +++ b/src/static_assets/static_files.rs @@ -68,6 +68,10 @@ pub mod assets { FILES.get("./static/cache/img/icon-trans.png").unwrap(), "Logo" ); + pub static ref BAR_CHART: Img = ( + FILES.get("./static/cache/img/svg/bar-chart.svg").unwrap(), + "Statistics" + ); } } diff --git a/static/cache/img/svg/bar-chart.svg b/static/cache/img/svg/bar-chart.svg new file mode 100644 index 00000000..074d7c1a --- /dev/null +++ b/static/cache/img/svg/bar-chart.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/components/svg.html b/templates/components/svg.html deleted file mode 100644 index 54cd62f1..00000000 --- a/templates/components/svg.html +++ /dev/null @@ -1,4 +0,0 @@ - - <=. ALT.> - - diff --git a/templates/panel/navbar/index.html b/templates/panel/navbar/index.html index 8b6ce4b5..507fd34b 100644 --- a/templates/panel/navbar/index.html +++ b/templates/panel/navbar/index.html @@ -30,7 +30,14 @@ - +
  • + + <.= crate::BAR_CHART.1 .> +
    + Statistics +
    +
    +
  • <.= crate::SETTINGS_ICON.1 .> diff --git a/templates/sitemap.html b/templates/sitemap.html index fc57e6ae..fe07df4f 100644 --- a/templates/sitemap.html +++ b/templates/sitemap.html @@ -1,11 +1,11 @@ -<. for url in urls.iter(){ .> - - <.= url .> - <.= crate::COMPILED_DATE .> - weekly - 0.8 - - <. } .> + <. for url in urls.iter(){ .> + + http://<.= domain .><.= url .> + <.= crate::COMPILED_DATE .> + weekly + 0.8 + +<. } .>