Browse Source

Fix XML template overriding

index-subcmd
Vincent Prouillet 7 years ago
parent
commit
dd9bab3142
3 changed files with 14 additions and 4 deletions
  1. +6
    -0
      CHANGELOG.md
  2. +1
    -1
      src/cmd/serve.rs
  3. +7
    -3
      src/site.rs

+ 6
- 0
CHANGELOG.md View File

@@ -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


+ 1
- 1
src/cmd/serve.rs View File

@@ -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() {


+ 7
- 3
src/site.rs View File

@@ -80,7 +80,7 @@ impl Site {
pub fn new<P: AsRef<Path>>(path: P, config_file: &str) -> Result<Site> {
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<()> {


Loading…
Cancel
Save