diff --git a/source/cli/run.rs b/source/cli/run.rs index 9793d9d..0e09651 100644 --- a/source/cli/run.rs +++ b/source/cli/run.rs @@ -110,6 +110,7 @@ pub async fn run() -> Result<()> { groups, user_count_group.as_ref().map(|group| group.subscribers), ) + .await .render_to_file(&output) .await?; generate_css(&output).await?; diff --git a/source/templates/base.html b/source/templates/base.html index e2b6571..d507fc4 100644 --- a/source/templates/base.html +++ b/source/templates/base.html @@ -10,10 +10,12 @@ {% block head %}{% endblock %} + {{ extra_head_html|safe }} {% block body %}{% endblock %} + {{ extra_body_html|safe }} diff --git a/source/templates/mod.rs b/source/templates/mod.rs index 235edf1..1a7d63a 100644 --- a/source/templates/mod.rs +++ b/source/templates/mod.rs @@ -2,7 +2,10 @@ use { askama::Template, - async_std::{fs::write, path::PathBuf}, + async_std::{ + fs::{read_to_string, write}, + path::PathBuf, + }, chrono::NaiveDate, color_eyre::Result, }; @@ -13,6 +16,12 @@ use crate::{group_data::GroupDataModel, utilities::today}; #[derive(Template)] #[template(path = "index.html")] pub struct HomeTemplate { + /// Extra HTML to insert in the body. + pub extra_body_html: String, + + /// Extra HTML to insert in the head. + pub extra_head_html: String, + /// The groups to create the table with. pub groups: Vec, @@ -28,8 +37,16 @@ pub struct HomeTemplate { impl HomeTemplate { /// Create a new [`HomeTemplate`]. - pub fn new(groups: Vec, user_count: Option) -> Self { + pub async fn new( + groups: Vec, + user_count: Option, + ) -> Self { + let extra_body_html = read_to_string("extra-body.html").await; + let extra_head_html = read_to_string("extra-head.html").await; + Self { + extra_body_html: extra_body_html.unwrap_or_default(), + extra_head_html: extra_head_html.unwrap_or_default(), groups, page_title: "Tildes Statistics".to_string(), today: today(),