diff --git a/src/config.rs b/src/config.rs index fbcffb27..5c23a0c4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -134,7 +134,7 @@ mod tests { use super::{Config}; #[test] - fn test_can_import_valid_config() { + fn can_import_valid_config() { let config = r#" title = "My site" base_url = "https://replace-this-with-your-url.com" @@ -145,7 +145,7 @@ base_url = "https://replace-this-with-your-url.com" } #[test] - fn test_errors_when_invalid_type() { + fn errors_when_invalid_type() { let config = r#" title = 1 base_url = "https://replace-this-with-your-url.com" @@ -156,7 +156,7 @@ base_url = "https://replace-this-with-your-url.com" } #[test] - fn test_errors_when_missing_required_field() { + fn errors_when_missing_required_field() { // base_url is required let config = r#" title = "" @@ -167,7 +167,7 @@ title = "" } #[test] - fn test_can_add_extra_values() { + fn can_add_extra_values() { let config = r#" title = "My site" base_url = "https://replace-this-with-your-url.com" diff --git a/src/content/mod.rs b/src/content/mod.rs new file mode 100644 index 00000000..f88347b3 --- /dev/null +++ b/src/content/mod.rs @@ -0,0 +1,10 @@ +// TODO: move section/page and maybe pagination in this mod +// Not sure where pagination stands if I add a render mod + +mod page; +mod pagination; +mod section; + +pub use self::page::{Page, sort_pages, populate_previous_and_next_pages}; +pub use self::section::{Section}; +pub use self::pagination::{Paginator, Pager}; diff --git a/src/page.rs b/src/content/page.rs similarity index 98% rename from src/page.rs rename to src/content/page.rs index cb43ff9e..52fdadfd 100644 --- a/src/page.rs +++ b/src/content/page.rs @@ -16,7 +16,6 @@ use markdown::markdown_to_html; use utils::{read_file, find_content_components}; - /// Looks into the current folder for the path and see if there's anything that is not a .md /// file. Those will be copied next to the rendered .html file fn find_related_assets(path: &Path) -> Vec { @@ -329,10 +328,10 @@ pub fn populate_previous_and_next_pages(input: &[Page]) -> Vec { #[cfg(test)] mod tests { - use tempdir::TempDir; - use std::fs::File; + use tempdir::TempDir; + use front_matter::{PageFrontMatter, SortBy}; use super::{Page, find_related_assets, sort_pages, populate_previous_and_next_pages}; @@ -349,7 +348,7 @@ mod tests { } #[test] - fn test_find_related_assets() { + fn can_find_related_assets() { let tmp_dir = TempDir::new("example").expect("create temp dir"); File::create(tmp_dir.path().join("index.md")).unwrap(); File::create(tmp_dir.path().join("example.js")).unwrap(); @@ -365,7 +364,7 @@ mod tests { } #[test] - fn test_can_sort_dates() { + fn can_sort_by_dates() { let input = vec![ create_page_with_date("2018-01-01"), create_page_with_date("2017-01-01"), @@ -379,7 +378,7 @@ mod tests { } #[test] - fn test_can_sort_order() { + fn can_sort_by_order() { let input = vec![ create_page_with_order(2), create_page_with_order(3), @@ -393,7 +392,7 @@ mod tests { } #[test] - fn test_can_sort_none() { + fn can_sort_by_none() { let input = vec![ create_page_with_order(2), create_page_with_order(3), @@ -407,7 +406,7 @@ mod tests { } #[test] - fn test_ignore_page_with_missing_field() { + fn ignore_page_with_missing_field() { let input = vec![ create_page_with_order(2), create_page_with_order(3), @@ -419,7 +418,7 @@ mod tests { } #[test] - fn test_populate_previous_and_next_pages() { + fn can_populate_previous_and_next_pages() { let input = vec![ create_page_with_order(3), create_page_with_order(2), diff --git a/src/pagination.rs b/src/content/pagination.rs similarity index 99% rename from src/pagination.rs rename to src/content/pagination.rs index 483fad81..6e883f0d 100644 --- a/src/pagination.rs +++ b/src/content/pagination.rs @@ -2,8 +2,7 @@ use std::collections::HashMap; use tera::{Context, to_value, Value}; use errors::{Result, ResultExt}; -use page::Page; -use section::Section; +use content::{Page, Section}; use site::Site; @@ -155,8 +154,7 @@ mod tests { use tera::{to_value}; use front_matter::SectionFrontMatter; - use page::Page; - use section::Section; + use content::{Page, Section}; use super::{Paginator}; diff --git a/src/section.rs b/src/content/section.rs similarity index 99% rename from src/section.rs rename to src/content/section.rs index 7310ed8c..876432c3 100644 --- a/src/section.rs +++ b/src/content/section.rs @@ -10,7 +10,7 @@ use front_matter::{SectionFrontMatter, split_section_content}; use errors::{Result, ResultExt}; use utils::{read_file, find_content_components}; use markdown::markdown_to_html; -use page::{Page}; +use content::Page; #[derive(Clone, Debug, PartialEq)] diff --git a/src/content/utils.rs b/src/content/utils.rs new file mode 100644 index 00000000..e69de29b diff --git a/src/lib.rs b/src/lib.rs index 80fc6e17..497e94b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,19 +22,16 @@ extern crate tempdir; mod utils; mod config; pub mod errors; -mod page; mod front_matter; +mod content; mod site; mod markdown; -mod section; -mod pagination; // Filters, Global Fns and default instance of Tera mod templates; pub use site::{Site}; pub use config::{Config, get_config}; pub use front_matter::{PageFrontMatter, SectionFrontMatter, split_page_content, split_section_content, SortBy}; -pub use page::{Page, populate_previous_and_next_pages}; -pub use section::{Section}; +pub use content::{Page, Section, sort_pages}; pub use utils::{create_file}; pub use markdown::markdown_to_html; diff --git a/src/site.rs b/src/site.rs index d57fe14a..54a402ab 100644 --- a/src/site.rs +++ b/src/site.rs @@ -10,10 +10,8 @@ use walkdir::WalkDir; use errors::{Result, ResultExt}; use config::{Config, get_config}; -use page::{Page, populate_previous_and_next_pages, sort_pages}; -use pagination::Paginator; use utils::{create_file, create_directory}; -use section::{Section}; +use content::{Page, Section, Paginator, populate_previous_and_next_pages, sort_pages}; use front_matter::{SortBy}; use templates::{GUTENBERG_TERA, global_fns, render_redirect_template}; diff --git a/src/templates/global_fns.rs b/src/templates/global_fns.rs index 3205378a..87abe7d0 100644 --- a/src/templates/global_fns.rs +++ b/src/templates/global_fns.rs @@ -3,7 +3,7 @@ use std::path::{PathBuf}; use tera::{GlobalFn, Value, from_value, to_value, Result}; -use page::Page; +use content::Page; pub fn make_get_page(all_pages: &HashMap) -> GlobalFn {