fix: remove unused label configs, fix entry audio gap, canvas spacing

This commit is contained in:
Lewis Wynne 2026-04-10 02:48:55 +01:00
parent 1d209636b4
commit c3e1ff145d
4 changed files with 6 additions and 14 deletions

View file

@ -22,11 +22,9 @@ pub struct Config {
pub captcha_exact: bool, pub captcha_exact: bool,
pub captcha_casesensitive: bool, pub captcha_casesensitive: bool,
pub enable_drawings: bool, pub enable_drawings: bool,
pub label_drawing: String,
pub canvas_width: u32, pub canvas_width: u32,
pub canvas_height: u32, pub canvas_height: u32,
pub enable_voice_notes: bool, pub enable_voice_notes: bool,
pub label_voice_note: String,
pub voice_note_max_duration: u32, pub voice_note_max_duration: u32,
pub template: Option<String>, pub template: Option<String>,
pub success_template: Option<String>, pub success_template: Option<String>,
@ -114,8 +112,6 @@ impl Config {
enable_drawings: env::var("BOOK_ENABLE_DRAWINGS") enable_drawings: env::var("BOOK_ENABLE_DRAWINGS")
.map(|v| v != "false") .map(|v| v != "false")
.unwrap_or(false), .unwrap_or(false),
label_drawing: env::var("BOOK_LABEL_DRAWING")
.unwrap_or_else(|_| "Draw (optional):".into()),
canvas_width: env::var("BOOK_CANVAS_WIDTH") canvas_width: env::var("BOOK_CANVAS_WIDTH")
.unwrap_or_else(|_| "400".into()) .unwrap_or_else(|_| "400".into())
.parse() .parse()
@ -127,8 +123,6 @@ impl Config {
enable_voice_notes: env::var("BOOK_ENABLE_VOICE_NOTES") enable_voice_notes: env::var("BOOK_ENABLE_VOICE_NOTES")
.map(|v| v != "false") .map(|v| v != "false")
.unwrap_or(false), .unwrap_or(false),
label_voice_note: env::var("BOOK_LABEL_VOICE_NOTE")
.unwrap_or_else(|_| "Voice note (optional):".into()),
voice_note_max_duration: env::var("BOOK_VOICE_NOTE_MAX_DURATION") voice_note_max_duration: env::var("BOOK_VOICE_NOTE_MAX_DURATION")
.unwrap_or_else(|_| "20".into()) .unwrap_or_else(|_| "20".into())
.parse() .parse()
@ -301,7 +295,6 @@ mod tests {
assert_eq!(config.canvas_width, 400); assert_eq!(config.canvas_width, 400);
assert_eq!(config.canvas_height, 200); assert_eq!(config.canvas_height, 200);
assert_eq!(config.max_drawing_bytes(), 400 * 200 * 4); assert_eq!(config.max_drawing_bytes(), 400 * 200 * 4);
assert_eq!(config.label_drawing, "Draw (optional):");
} }
#[test] #[test]
@ -315,7 +308,6 @@ mod tests {
assert!(!config.enable_voice_notes); assert!(!config.enable_voice_notes);
assert_eq!(config.voice_note_max_duration, 20); assert_eq!(config.voice_note_max_duration, 20);
assert_eq!(config.max_voice_note_bytes(), 20 * 10 * 1024); assert_eq!(config.max_voice_note_bytes(), 20 * 10 * 1024);
assert_eq!(config.label_voice_note, "Voice note (optional):");
} }
#[test] #[test]

View file

@ -280,7 +280,7 @@ fn render_entry(entry: &Entry, config: &Config) -> String {
}; };
let drawing_html = if !entry.meta.drawing.is_empty() { let drawing_html = if !entry.meta.drawing.is_empty() {
format!( format!(
"\n<img class=\"entry-drawing\" src=\"/drawings/{}\">", "<img class=\"entry-drawing\" src=\"/drawings/{}\">",
escape_html(&entry.meta.drawing) escape_html(&entry.meta.drawing)
) )
} else { } else {
@ -288,7 +288,7 @@ fn render_entry(entry: &Entry, config: &Config) -> String {
}; };
let voice_note_html = if !entry.meta.voice_note.is_empty() { let voice_note_html = if !entry.meta.voice_note.is_empty() {
format!( format!(
"\n<span class=\"entry-voice-note\"><audio controls preload=\"metadata\" src=\"/voice_notes/{}\"></audio></span>", "<span class=\"entry-voice-note\"><audio controls preload=\"metadata\" src=\"/voice_notes/{}\"></audio></span>",
escape_html(&entry.meta.voice_note) escape_html(&entry.meta.voice_note)
) )
} else { } else {
@ -327,11 +327,9 @@ mod tests {
captcha_exact: false, captcha_exact: false,
captcha_casesensitive: false, captcha_casesensitive: false,
enable_drawings: false, enable_drawings: false,
label_drawing: "Draw (optional):".into(),
canvas_width: 400, canvas_width: 400,
canvas_height: 200, canvas_height: 200,
enable_voice_notes: false, enable_voice_notes: false,
label_voice_note: "Voice note (optional):".into(),
voice_note_max_duration: 20, voice_note_max_duration: 20,
template: None, template: None,
success_template: None, success_template: None,

View file

@ -335,11 +335,9 @@ mod tests {
captcha_exact: false, captcha_exact: false,
captcha_casesensitive: false, captcha_casesensitive: false,
enable_drawings: false, enable_drawings: false,
label_drawing: "Draw (optional):".into(),
canvas_width: 400, canvas_width: 400,
canvas_height: 200, canvas_height: 200,
enable_voice_notes: false, enable_voice_notes: false,
label_voice_note: "Voice note (optional):".into(),
voice_note_max_duration: 20, voice_note_max_duration: 20,
template: None, template: None,
success_template: None, success_template: None,

View file

@ -35,6 +35,10 @@
.guestbook-drawing-inline a { .guestbook-drawing-inline a {
cursor: pointer; cursor: pointer;
} }
.guestbook-drawing-content {
display: block;
margin-bottom: 1em;
}
.guestbook-swatch { .guestbook-swatch {
display: inline-block; display: inline-block;
width: 0.85em; width: 0.85em;