From c85fe973b72f9062f4dae985a64d0a7bb7d1c24d Mon Sep 17 00:00:00 2001 From: Jochen Kupperschmidt Date: Sun, 19 May 2024 03:26:28 +0200 Subject: [PATCH] Make title, subtitle configurable --- CHANGELOG.md | 2 ++ config-example.toml | 3 +++ src/config.rs | 2 ++ src/main.rs | 4 +++- src/templates/index.html | 8 +++++--- src/templating.rs | 4 ++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75cad22..2ee182b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## 0.4.0 (unreleased) +- Made title and optional subtitle configurable. + - Added generator and timestamp to page footer. - Raised minimum supported Rust version to 1.76.0. diff --git a/config-example.toml b/config-example.toml index b208a3e..ec2fb77 100644 --- a/config-example.toml +++ b/config-example.toml @@ -1,3 +1,6 @@ +title = "Title" +subtitle = "Subtitle" + [discord] bot_token = "your-secret-bot-token" guild_id = "your-guild-id" diff --git a/src/config.rs b/src/config.rs index d6421aa..bb4877f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,6 +11,8 @@ use std::path::Path; #[derive(Debug, Deserialize)] pub(crate) struct Config { + pub title: String, + pub subtitle: Option, pub discord: DiscordConfig, } diff --git a/src/main.rs b/src/main.rs index 3a065a7..dbce150 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,9 @@ fn main() -> Result<()> { let generated_at = Utc::now(); match args.output_format { - cli::OutputFormat::Html => templating::render_html(roles, generated_at, writer)?, + cli::OutputFormat::Html => { + templating::render_html(config.title, config.subtitle, roles, generated_at, writer)? + } cli::OutputFormat::Json => model::write_roles(roles, writer)?, cli::OutputFormat::Text => templating::render_text(roles, writer)?, }; diff --git a/src/templates/index.html b/src/templates/index.html index 721c5cb..3796997 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -3,7 +3,7 @@ - OrgaTalk Discord – Orga team roles and memberships + {{ title }}{% if subtitle %} – {{ subtitle }}{% endif %}