From 61356ce5feada204026cb0742df68ea646edc95c Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Thu, 21 Dec 2017 00:18:12 -0500 Subject: [PATCH] Implement playpen defaults Avoids issues where we enable `editable` but forget to specify `editor` (eg, https://github.com/rust-lang/rust-by-example/issues/963). Since we already include Ace editor, seems like we can just treat it as the default. --- src/config.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index acc8beea..5b597477 100644 --- a/src/config.rs +++ b/src/config.rs @@ -274,12 +274,22 @@ pub struct HtmlConfig { } /// Configuration for tweaking how the the HTML renderer handles the playpen. -#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(default, rename_all = "kebab-case")] pub struct Playpen { pub editor: PathBuf, pub editable: bool, } +impl Default for Playpen { + fn default() -> Playpen { + Playpen { + editor: PathBuf::from("ace"), + editable: false, + } + } +} + #[cfg(test)] mod tests {