diff --git a/CHANGELOG.md b/CHANGELOG.md index 1163ed7..efa9061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog +## 0.0.5 (unreleased) + +- Fix XML templates overriding and reloading + ## 0.0.4 (2017-04-23) + - Fix RSS feed link and description - Renamed `Page::url` and `Section::url` to `Page::path` and `Section::path` - Pass `current_url` and `current_path` to every template @@ -14,6 +19,7 @@ - Only load templates ending by `.html` ## 0.0.3 (2017-04-05) + - Add some colours in console - Allow using a file other than config.toml for config - Add sections to the index page context diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 936b185..dfcc4bb 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -131,7 +131,7 @@ pub fn serve(interface: &str, port: &str, config_file: &str) -> Result<()> { (ChangeKind::Templates, _) => { console::info(&format!("-> Template changed {}", path.display())); // Force refresh - rebuild_done_handling(&broadcaster, site.rebuild_after_template_change(), "/x.js"); + rebuild_done_handling(&broadcaster, site.rebuild_after_template_change(&path), "/x.js"); }, (ChangeKind::StaticFiles, p) => { if path.is_file() { diff --git a/src/site.rs b/src/site.rs index 6cd5cf6..8d01a10 100644 --- a/src/site.rs +++ b/src/site.rs @@ -80,7 +80,7 @@ impl Site { pub fn new>(path: P, config_file: &str) -> Result { let path = path.as_ref(); - let tpl_glob = format!("{}/{}", path.to_string_lossy().replace("\\", "/"), "templates/**/*.html"); + let tpl_glob = format!("{}/{}", path.to_string_lossy().replace("\\", "/"), "templates/**/*.*ml"); let mut tera = Tera::new(&tpl_glob).chain_err(|| "Error parsing templates")?; tera.extend(&GUTENBERG_TERA)?; tera.register_filter("markdown", filters::markdown); @@ -307,9 +307,13 @@ impl Site { self.build() } - pub fn rebuild_after_template_change(&mut self) -> Result<()> { + pub fn rebuild_after_template_change(&mut self, path: &Path) -> Result<()> { self.tera.full_reload()?; - self.build_pages() + match path.file_name().unwrap().to_str().unwrap() { + "sitemap.xml" => self.render_sitemap(), + "rss.xml" => self.render_rss_feed(), + _ => self.build_pages() + } } pub fn build_pages(&self) -> Result<()> {