@@ -134,7 +134,7 @@ mod tests { | |||||
use super::{Config}; | use super::{Config}; | ||||
#[test] | #[test] | ||||
fn test_can_import_valid_config() { | |||||
fn can_import_valid_config() { | |||||
let config = r#" | let config = r#" | ||||
title = "My site" | title = "My site" | ||||
base_url = "https://replace-this-with-your-url.com" | base_url = "https://replace-this-with-your-url.com" | ||||
@@ -145,7 +145,7 @@ base_url = "https://replace-this-with-your-url.com" | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_errors_when_invalid_type() { | |||||
fn errors_when_invalid_type() { | |||||
let config = r#" | let config = r#" | ||||
title = 1 | title = 1 | ||||
base_url = "https://replace-this-with-your-url.com" | base_url = "https://replace-this-with-your-url.com" | ||||
@@ -156,7 +156,7 @@ base_url = "https://replace-this-with-your-url.com" | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_errors_when_missing_required_field() { | |||||
fn errors_when_missing_required_field() { | |||||
// base_url is required | // base_url is required | ||||
let config = r#" | let config = r#" | ||||
title = "" | title = "" | ||||
@@ -167,7 +167,7 @@ title = "" | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_can_add_extra_values() { | |||||
fn can_add_extra_values() { | |||||
let config = r#" | let config = r#" | ||||
title = "My site" | title = "My site" | ||||
base_url = "https://replace-this-with-your-url.com" | base_url = "https://replace-this-with-your-url.com" | ||||
@@ -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}; |
@@ -16,7 +16,6 @@ use markdown::markdown_to_html; | |||||
use utils::{read_file, find_content_components}; | 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 | /// 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 | /// file. Those will be copied next to the rendered .html file | ||||
fn find_related_assets(path: &Path) -> Vec<PathBuf> { | fn find_related_assets(path: &Path) -> Vec<PathBuf> { | ||||
@@ -329,10 +328,10 @@ pub fn populate_previous_and_next_pages(input: &[Page]) -> Vec<Page> { | |||||
#[cfg(test)] | #[cfg(test)] | ||||
mod tests { | mod tests { | ||||
use tempdir::TempDir; | |||||
use std::fs::File; | use std::fs::File; | ||||
use tempdir::TempDir; | |||||
use front_matter::{PageFrontMatter, SortBy}; | use front_matter::{PageFrontMatter, SortBy}; | ||||
use super::{Page, find_related_assets, sort_pages, populate_previous_and_next_pages}; | use super::{Page, find_related_assets, sort_pages, populate_previous_and_next_pages}; | ||||
@@ -349,7 +348,7 @@ mod tests { | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_find_related_assets() { | |||||
fn can_find_related_assets() { | |||||
let tmp_dir = TempDir::new("example").expect("create temp dir"); | 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("index.md")).unwrap(); | ||||
File::create(tmp_dir.path().join("example.js")).unwrap(); | File::create(tmp_dir.path().join("example.js")).unwrap(); | ||||
@@ -365,7 +364,7 @@ mod tests { | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_can_sort_dates() { | |||||
fn can_sort_by_dates() { | |||||
let input = vec![ | let input = vec![ | ||||
create_page_with_date("2018-01-01"), | create_page_with_date("2018-01-01"), | ||||
create_page_with_date("2017-01-01"), | create_page_with_date("2017-01-01"), | ||||
@@ -379,7 +378,7 @@ mod tests { | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_can_sort_order() { | |||||
fn can_sort_by_order() { | |||||
let input = vec![ | let input = vec![ | ||||
create_page_with_order(2), | create_page_with_order(2), | ||||
create_page_with_order(3), | create_page_with_order(3), | ||||
@@ -393,7 +392,7 @@ mod tests { | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_can_sort_none() { | |||||
fn can_sort_by_none() { | |||||
let input = vec![ | let input = vec![ | ||||
create_page_with_order(2), | create_page_with_order(2), | ||||
create_page_with_order(3), | create_page_with_order(3), | ||||
@@ -407,7 +406,7 @@ mod tests { | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_ignore_page_with_missing_field() { | |||||
fn ignore_page_with_missing_field() { | |||||
let input = vec![ | let input = vec![ | ||||
create_page_with_order(2), | create_page_with_order(2), | ||||
create_page_with_order(3), | create_page_with_order(3), | ||||
@@ -419,7 +418,7 @@ mod tests { | |||||
} | } | ||||
#[test] | #[test] | ||||
fn test_populate_previous_and_next_pages() { | |||||
fn can_populate_previous_and_next_pages() { | |||||
let input = vec![ | let input = vec![ | ||||
create_page_with_order(3), | create_page_with_order(3), | ||||
create_page_with_order(2), | create_page_with_order(2), |
@@ -2,8 +2,7 @@ use std::collections::HashMap; | |||||
use tera::{Context, to_value, Value}; | use tera::{Context, to_value, Value}; | ||||
use errors::{Result, ResultExt}; | use errors::{Result, ResultExt}; | ||||
use page::Page; | |||||
use section::Section; | |||||
use content::{Page, Section}; | |||||
use site::Site; | use site::Site; | ||||
@@ -155,8 +154,7 @@ mod tests { | |||||
use tera::{to_value}; | use tera::{to_value}; | ||||
use front_matter::SectionFrontMatter; | use front_matter::SectionFrontMatter; | ||||
use page::Page; | |||||
use section::Section; | |||||
use content::{Page, Section}; | |||||
use super::{Paginator}; | use super::{Paginator}; | ||||
@@ -10,7 +10,7 @@ use front_matter::{SectionFrontMatter, split_section_content}; | |||||
use errors::{Result, ResultExt}; | use errors::{Result, ResultExt}; | ||||
use utils::{read_file, find_content_components}; | use utils::{read_file, find_content_components}; | ||||
use markdown::markdown_to_html; | use markdown::markdown_to_html; | ||||
use page::{Page}; | |||||
use content::Page; | |||||
#[derive(Clone, Debug, PartialEq)] | #[derive(Clone, Debug, PartialEq)] |
@@ -22,19 +22,16 @@ extern crate tempdir; | |||||
mod utils; | mod utils; | ||||
mod config; | mod config; | ||||
pub mod errors; | pub mod errors; | ||||
mod page; | |||||
mod front_matter; | mod front_matter; | ||||
mod content; | |||||
mod site; | mod site; | ||||
mod markdown; | mod markdown; | ||||
mod section; | |||||
mod pagination; | |||||
// Filters, Global Fns and default instance of Tera | // Filters, Global Fns and default instance of Tera | ||||
mod templates; | mod templates; | ||||
pub use site::{Site}; | pub use site::{Site}; | ||||
pub use config::{Config, get_config}; | pub use config::{Config, get_config}; | ||||
pub use front_matter::{PageFrontMatter, SectionFrontMatter, split_page_content, split_section_content, SortBy}; | 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 utils::{create_file}; | ||||
pub use markdown::markdown_to_html; | pub use markdown::markdown_to_html; |
@@ -10,10 +10,8 @@ use walkdir::WalkDir; | |||||
use errors::{Result, ResultExt}; | use errors::{Result, ResultExt}; | ||||
use config::{Config, get_config}; | 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 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 front_matter::{SortBy}; | ||||
use templates::{GUTENBERG_TERA, global_fns, render_redirect_template}; | use templates::{GUTENBERG_TERA, global_fns, render_redirect_template}; | ||||
@@ -3,7 +3,7 @@ use std::path::{PathBuf}; | |||||
use tera::{GlobalFn, Value, from_value, to_value, Result}; | use tera::{GlobalFn, Value, from_value, to_value, Result}; | ||||
use page::Page; | |||||
use content::Page; | |||||
pub fn make_get_page(all_pages: &HashMap<PathBuf, Page>) -> GlobalFn { | pub fn make_get_page(all_pages: &HashMap<PathBuf, Page>) -> GlobalFn { | ||||