Add styles to output document
This commit is contained in:
parent
5e1451f7ca
commit
d170372e5a
2 changed files with 22 additions and 2 deletions
|
@ -5,13 +5,14 @@ mod strip_blank;
|
||||||
mod rebrand;
|
mod rebrand;
|
||||||
mod references;
|
mod references;
|
||||||
mod images;
|
mod images;
|
||||||
|
mod static_files;
|
||||||
|
|
||||||
|
pub const PROCESSORS: [fn(Config, String) -> Result<String, String>; 6] =
|
||||||
pub const PROCESSORS: [fn(Config, String) -> Result<String, String>; 5] =
|
|
||||||
[
|
[
|
||||||
head_cleanup::head_cleanup,
|
head_cleanup::head_cleanup,
|
||||||
rebrand::rebrand,
|
rebrand::rebrand,
|
||||||
references::references,
|
references::references,
|
||||||
images::images,
|
images::images,
|
||||||
|
static_files::static_files,
|
||||||
strip_blank::strip_blank,
|
strip_blank::strip_blank,
|
||||||
];
|
];
|
||||||
|
|
19
src/processors/static_files.rs
Normal file
19
src/processors/static_files.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use html::{sciter_start, get_html, get_head, find_first};
|
||||||
|
use sciter::Element;
|
||||||
|
use config::Config;
|
||||||
|
use assets;
|
||||||
|
|
||||||
|
fn create_css_element(style: String) -> Element {
|
||||||
|
let mut style_tag = Element::with_text("style", &style).unwrap();
|
||||||
|
style_tag.set_attribute("type", "text/css");
|
||||||
|
style_tag.set_attribute("media", "all");
|
||||||
|
return style_tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn static_files(_: Config, input: String) -> Result<String, String> {
|
||||||
|
let mut root = sciter_start(input);
|
||||||
|
let mut head = get_head(&mut root);
|
||||||
|
head.append(&create_css_element(assets::get("style.css")));
|
||||||
|
return Ok(get_html(root));
|
||||||
|
}
|
Reference in a new issue