refactor: clean-up of some unused options after the template rework
This commit is contained in:
parent
f794fa3ce0
commit
7f86743f4a
6 changed files with 6 additions and 20 deletions
|
|
@ -7,9 +7,6 @@ BOOK_DATA_DIR=./data
|
|||
# Site title shown in nav and page title.
|
||||
BOOK_SITE_TITLE=guestbook
|
||||
|
||||
# Base URL of the main site (for absolute nav links).
|
||||
BOOK_SITE_URL=https://example.com
|
||||
|
||||
# Telegram bot token.
|
||||
BOOK_TELEGRAM_BOT_TOKEN=your-bot-token-here
|
||||
|
||||
|
|
|
|||
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2026 Llywelwyn
|
||||
Copyright (c) 2026 Lewis Wynne
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
|
|
@ -30,11 +30,6 @@ in
|
|||
description = "Site title shown in nav and page title.";
|
||||
};
|
||||
|
||||
siteUrl = mkOption {
|
||||
type = types.str;
|
||||
description = "Base URL of the main site (for absolute nav links).";
|
||||
};
|
||||
|
||||
telegramChatId = mkOption {
|
||||
type = types.int;
|
||||
description = "Telegram chat ID for moderation messages.";
|
||||
|
|
@ -174,7 +169,7 @@ in
|
|||
BOOK_PORT = toString cfg.port;
|
||||
BOOK_DATA_DIR = cfg.dataDir;
|
||||
BOOK_SITE_TITLE = cfg.siteTitle;
|
||||
BOOK_SITE_URL = cfg.siteUrl;
|
||||
|
||||
BOOK_TELEGRAM_CHAT_ID = toString cfg.telegramChatId;
|
||||
BOOK_HONEYPOT = if cfg.honeypot then "true" else "false";
|
||||
BOOK_MAX_NAME_LENGTH = toString cfg.maxNameLength;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ pub struct Config {
|
|||
pub port: u16,
|
||||
pub data_dir: PathBuf,
|
||||
pub site_title: String,
|
||||
pub site_url: String,
|
||||
|
||||
pub telegram_bot_token: String,
|
||||
pub telegram_chat_id: i64,
|
||||
pub honeypot: bool,
|
||||
|
|
@ -41,7 +41,7 @@ impl Config {
|
|||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|_| PathBuf::from("./data")),
|
||||
site_title: env::var("BOOK_SITE_TITLE").unwrap_or_else(|_| "guestbook".into()),
|
||||
site_url: env::var("BOOK_SITE_URL").map_err(|_| "BOOK_SITE_URL is required")?,
|
||||
|
||||
telegram_bot_token: env::var("BOOK_TELEGRAM_BOT_TOKEN")
|
||||
.map_err(|_| "BOOK_TELEGRAM_BOT_TOKEN is required")?,
|
||||
telegram_chat_id: env::var("BOOK_TELEGRAM_CHAT_ID")
|
||||
|
|
@ -115,7 +115,6 @@ mod tests {
|
|||
env::set_var("BOOK_PORT", "9999");
|
||||
env::set_var("BOOK_DATA_DIR", "/tmp/gb");
|
||||
env::set_var("BOOK_SITE_TITLE", "test.rs");
|
||||
env::set_var("BOOK_SITE_URL", "https://test.rs");
|
||||
env::set_var("BOOK_TELEGRAM_BOT_TOKEN", "123:ABC");
|
||||
env::set_var("BOOK_TELEGRAM_CHAT_ID", "12345");
|
||||
|
||||
|
|
@ -124,14 +123,12 @@ mod tests {
|
|||
assert_eq!(config.listen_addr(), "127.0.0.1:9999");
|
||||
assert_eq!(config.data_dir, PathBuf::from("/tmp/gb"));
|
||||
assert_eq!(config.site_title, "test.rs");
|
||||
assert_eq!(config.site_url, "https://test.rs");
|
||||
assert_eq!(config.telegram_chat_id, 12345);
|
||||
|
||||
// Clean up
|
||||
env::remove_var("BOOK_PORT");
|
||||
env::remove_var("BOOK_DATA_DIR");
|
||||
env::remove_var("BOOK_SITE_TITLE");
|
||||
env::remove_var("BOOK_SITE_URL");
|
||||
env::remove_var("BOOK_TELEGRAM_BOT_TOKEN");
|
||||
env::remove_var("BOOK_TELEGRAM_CHAT_ID");
|
||||
}
|
||||
|
|
@ -139,7 +136,6 @@ mod tests {
|
|||
#[test]
|
||||
fn test_defaults() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
env::set_var("BOOK_SITE_URL", "https://test.rs");
|
||||
env::set_var("BOOK_TELEGRAM_BOT_TOKEN", "123:ABC");
|
||||
env::set_var("BOOK_TELEGRAM_CHAT_ID", "12345");
|
||||
|
||||
|
|
@ -148,7 +144,6 @@ mod tests {
|
|||
assert_eq!(config.data_dir, PathBuf::from("./data"));
|
||||
assert_eq!(config.site_title, "guestbook");
|
||||
|
||||
env::remove_var("BOOK_SITE_URL");
|
||||
env::remove_var("BOOK_TELEGRAM_BOT_TOKEN");
|
||||
env::remove_var("BOOK_TELEGRAM_CHAT_ID");
|
||||
}
|
||||
|
|
@ -156,7 +151,6 @@ mod tests {
|
|||
#[test]
|
||||
fn test_missing_required() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
env::remove_var("BOOK_SITE_URL");
|
||||
env::remove_var("BOOK_TELEGRAM_BOT_TOKEN");
|
||||
env::remove_var("BOOK_TELEGRAM_CHAT_ID");
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ mod tests {
|
|||
port: 0,
|
||||
data_dir: PathBuf::from("./data"),
|
||||
site_title: "test".into(),
|
||||
site_url: "https://test.rs".into(),
|
||||
|
||||
telegram_bot_token: "fake".into(),
|
||||
telegram_chat_id: 0,
|
||||
honeypot: true,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ mod tests {
|
|||
port: 0,
|
||||
data_dir: dir.to_path_buf(),
|
||||
site_title: "test".into(),
|
||||
site_url: "https://test.rs".into(),
|
||||
|
||||
telegram_bot_token: "fake".into(),
|
||||
telegram_chat_id: 0,
|
||||
honeypot: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue