Browse Source

Warn about ignored pages

index-subcmd
Vincent Prouillet 7 years ago
parent
commit
f3edef2640
4 changed files with 32 additions and 2 deletions
  1. +2
    -1
      src/cmd/build.rs
  2. +21
    -0
      src/cmd/mod.rs
  3. +2
    -1
      src/cmd/serve.rs
  4. +7
    -0
      src/site.rs

+ 2
- 1
src/cmd/build.rs View File

@@ -7,6 +7,7 @@ use gutenberg::Site;
pub fn build(config_file: &str) -> Result<()> {
let mut site = Site::new(env::current_dir().unwrap(), config_file)?;
site.load()?;
println!("-> Creating {} pages and {} sections", site.pages.len(), site.sections.len());
super::notify_site_size(&site);
super::warn_about_ignored_pages(&site);
site.build()
}

+ 21
- 0
src/cmd/mod.rs View File

@@ -5,3 +5,24 @@ mod serve;
pub use self::init::create_new_project;
pub use self::build::build;
pub use self::serve::serve;

use gutenberg::Site;

use console::warn;

fn notify_site_size(site: &Site) {
println!("-> Creating {} pages and {} sections", site.pages.len(), site.sections.len());
}

fn warn_about_ignored_pages(site: &Site) {
let ignored_pages = site.get_ignored_pages();
if !ignored_pages.is_empty() {
warn(&format!(
"{} page(s) ignored (missing date or order in a sorted section):",
ignored_pages.len()
));
for path in site.get_ignored_pages() {
warn(&format!("- {}", path.display()));
}
}
}

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

@@ -67,7 +67,8 @@ pub fn serve(interface: &str, port: &str, config_file: &str) -> Result<()> {

site.load()?;
site.enable_live_reload();
println!("-> Creating {} pages and {} sections", site.pages.len(), site.sections.len());
super::notify_site_size(&site);
super::warn_about_ignored_pages(&site);
site.build()?;
report_elapsed_time(start);



+ 7
- 0
src/site.rs View File

@@ -122,6 +122,13 @@ impl Site {
self.live_reload = true;
}

pub fn get_ignored_pages(&self) -> Vec<PathBuf> {
self.sections
.values()
.flat_map(|s| s.ignored_pages.iter().map(|p| p.file_path.clone()))
.collect()
}

/// Used by tests to change the output path to a tmp dir
#[doc(hidden)]
pub fn set_output_path<P: AsRef<Path>>(&mut self, path: P) {


Loading…
Cancel
Save