mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-10 02:26:42 -07:00
remove obsolete template_index
This commit is contained in:
parent
e3630208fa
commit
92687016ed
2 changed files with 1 additions and 24 deletions
21
src/lib.rs
21
src/lib.rs
|
@ -18,7 +18,6 @@ use rayon::prelude::*;
|
||||||
use resource::{EmbedMetadata, ResourceBuilderConfig};
|
use resource::{EmbedMetadata, ResourceBuilderConfig};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::get_name;
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use builder::SiteBuilder;
|
use builder::SiteBuilder;
|
||||||
|
@ -103,8 +102,6 @@ pub struct Site {
|
||||||
pub site_path: PathBuf,
|
pub site_path: PathBuf,
|
||||||
/// The site's configuration.
|
/// The site's configuration.
|
||||||
pub config: SiteConfig,
|
pub config: SiteConfig,
|
||||||
/// An index of available templates.
|
|
||||||
pub template_index: HashMap<String, PathBuf>,
|
|
||||||
/// An index of available pages.
|
/// An index of available pages.
|
||||||
pub page_index: HashMap<String, PathBuf>,
|
pub page_index: HashMap<String, PathBuf>,
|
||||||
}
|
}
|
||||||
|
@ -118,23 +115,6 @@ impl Site {
|
||||||
)
|
)
|
||||||
.wrap_err("Failed to parse site config")?;
|
.wrap_err("Failed to parse site config")?;
|
||||||
|
|
||||||
let mut template_index = HashMap::new();
|
|
||||||
let templates_path = site_path.join(TEMPLATES_PATH);
|
|
||||||
for entry in WalkDir::new(&templates_path).into_iter() {
|
|
||||||
let entry = entry.wrap_err("Failed to read template entry")?;
|
|
||||||
let path = entry.path();
|
|
||||||
|
|
||||||
if let Some(ext) = path.extension() {
|
|
||||||
if ext == "hbs" && entry.file_type().is_file() {
|
|
||||||
let (_, name) = get_name(
|
|
||||||
path.strip_prefix(&templates_path)
|
|
||||||
.wrap_err("This really shouldn't have happened")?,
|
|
||||||
);
|
|
||||||
template_index.insert(name, path.to_owned());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut page_index = HashMap::new();
|
let mut page_index = HashMap::new();
|
||||||
let pages_path = site_path.join(PAGES_PATH);
|
let pages_path = site_path.join(PAGES_PATH);
|
||||||
for entry in WalkDir::new(&pages_path).into_iter() {
|
for entry in WalkDir::new(&pages_path).into_iter() {
|
||||||
|
@ -158,7 +138,6 @@ impl Site {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
site_path: site_path.to_owned(),
|
site_path: site_path.to_owned(),
|
||||||
config,
|
config,
|
||||||
template_index,
|
|
||||||
page_index,
|
page_index,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,9 +114,7 @@ fn remove(builder: &mut SiteBuilder, path: &Path, relative_path: &Path) -> eyre:
|
||||||
builder.site.page_index.remove(&page_name_str);
|
builder.site.page_index.remove(&page_name_str);
|
||||||
std::fs::remove_file(builder.build_path.join(page_name.with_extension("html")))
|
std::fs::remove_file(builder.build_path.join(page_name.with_extension("html")))
|
||||||
.with_context(|| format!("Failed to remove page at {:?}", path))?;
|
.with_context(|| format!("Failed to remove page at {:?}", path))?;
|
||||||
} else if let Ok(template_path) = relative_path.strip_prefix(TEMPLATES_PATH) {
|
} else if let Ok(_template_path) = relative_path.strip_prefix(TEMPLATES_PATH) {
|
||||||
let (_template_name, template_name_str) = get_name(template_path);
|
|
||||||
builder.site.template_index.remove(&template_name_str);
|
|
||||||
builder.tera.full_reload()?;
|
builder.tera.full_reload()?;
|
||||||
builder
|
builder
|
||||||
.site
|
.site
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue