BOOK_STYLE_FILE for multiline css from .env
This commit is contained in:
parent
b041941a4a
commit
23fe147861
3 changed files with 17 additions and 1 deletions
|
|
@ -17,5 +17,6 @@ BOOK_LABEL_WEBSITE=Your website (optional):
|
||||||
BOOK_LABEL_MESSAGE=Your message:
|
BOOK_LABEL_MESSAGE=Your message:
|
||||||
BOOK_TEXTAREA_ROWS=8
|
BOOK_TEXTAREA_ROWS=8
|
||||||
BOOK_TEXTAREA_COLS=60
|
BOOK_TEXTAREA_COLS=60
|
||||||
|
# BOOK_STYLE_FILE=./my-styles.css
|
||||||
# BOOK_STYLE=.entry-name { font-weight: bold; }
|
# BOOK_STYLE=.entry-name { font-weight: bold; }
|
||||||
# BOOK_TEMPLATE=./templates/default.html
|
# BOOK_TEMPLATE=./templates/default.html
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,12 @@ in
|
||||||
description = "Custom CSS injected into a style tag. Use class names: .guestbook-form, .guestbook-prompt, .guestbook-label, .guestbook-input, .guestbook-textarea, .guestbook-button, .entry-header, .entry-name, .entry-website, .entry-body, .entry-separator";
|
description = "Custom CSS injected into a style tag. Use class names: .guestbook-form, .guestbook-prompt, .guestbook-label, .guestbook-input, .guestbook-textarea, .guestbook-button, .entry-header, .entry-name, .entry-website, .entry-body, .entry-separator";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
styleFile = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
default = null;
|
||||||
|
description = "Path to a CSS file. Takes precedence over style.";
|
||||||
|
};
|
||||||
|
|
||||||
formPrompt = mkOption {
|
formPrompt = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "If you visited my site, please sign my guestbook!";
|
default = "If you visited my site, please sign my guestbook!";
|
||||||
|
|
@ -177,6 +183,8 @@ in
|
||||||
BOOK_OPEN_REGISTRATION = if cfg.openRegistration then "true" else "false";
|
BOOK_OPEN_REGISTRATION = if cfg.openRegistration then "true" else "false";
|
||||||
BOOK_SEPARATOR = cfg.separator;
|
BOOK_SEPARATOR = cfg.separator;
|
||||||
BOOK_STYLE = cfg.style;
|
BOOK_STYLE = cfg.style;
|
||||||
|
} // lib.optionalAttrs (cfg.styleFile != null) {
|
||||||
|
BOOK_STYLE_FILE = cfg.styleFile;
|
||||||
BOOK_FORM_PROMPT = cfg.formPrompt;
|
BOOK_FORM_PROMPT = cfg.formPrompt;
|
||||||
BOOK_BUTTON_TEXT = cfg.buttonText;
|
BOOK_BUTTON_TEXT = cfg.buttonText;
|
||||||
BOOK_LABEL_NAME = cfg.labelName;
|
BOOK_LABEL_NAME = cfg.labelName;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,14 @@ impl Config {
|
||||||
std::fs::read_to_string(&path)
|
std::fs::read_to_string(&path)
|
||||||
.unwrap_or_else(|e| panic!("failed to read template {path}: {e}"))
|
.unwrap_or_else(|e| panic!("failed to read template {path}: {e}"))
|
||||||
}),
|
}),
|
||||||
style: env::var("BOOK_STYLE").unwrap_or_default(),
|
style: env::var("BOOK_STYLE_FILE")
|
||||||
|
.ok()
|
||||||
|
.map(|path| {
|
||||||
|
std::fs::read_to_string(&path)
|
||||||
|
.unwrap_or_else(|e| panic!("failed to read style file {path}: {e}"))
|
||||||
|
})
|
||||||
|
.or_else(|| env::var("BOOK_STYLE").ok())
|
||||||
|
.unwrap_or_default(),
|
||||||
form_prompt: env::var("BOOK_FORM_PROMPT")
|
form_prompt: env::var("BOOK_FORM_PROMPT")
|
||||||
.unwrap_or_else(|_| "If you visited my site, please sign my guestbook!".into()),
|
.unwrap_or_else(|_| "If you visited my site, please sign my guestbook!".into()),
|
||||||
button_text: env::var("BOOK_BUTTON_TEXT")
|
button_text: env::var("BOOK_BUTTON_TEXT")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue