Skip to content

Commit

Permalink
Merge pull request #302 from epage/fix/dir
Browse files Browse the repository at this point in the history
fix(data,sass): Remove custom folder support
  • Loading branch information
epage authored Oct 21, 2017
2 parents dadb6a6 + ccdaef5 commit 692ff3b
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 111 deletions.
13 changes: 9 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@ pub enum SassOutputStyle {
Compressed,
}

const SASS_IMPORT_DIR: &'static str = "_sass";

#[derive(Debug, PartialEq)]
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SassOptions {
pub import_dir: String,
#[serde(skip)]
pub import_dir: &'static str,
pub style: SassOutputStyle,
}

impl Default for SassOptions {
fn default() -> SassOptions {
SassOptions {
import_dir: "_sass".to_owned(),
import_dir: SASS_IMPORT_DIR,
style: SassOutputStyle::Nested,
}
}
Expand All @@ -78,6 +81,8 @@ impl Default for SyntaxHighlight {
}
}

const DATA_DIR: &'static str = "_data";

#[derive(Debug, PartialEq)]
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields, default)]
Expand All @@ -86,7 +91,7 @@ pub struct Config {
pub dest: String,
pub layouts: String,
pub drafts: String,
pub data: String,
pub data: &'static str,
pub include_drafts: bool,
pub posts: String,
pub post_path: Option<String>,
Expand All @@ -113,7 +118,7 @@ impl Default for Config {
dest: "./".to_owned(),
layouts: "_layouts".to_owned(),
drafts: "_drafts".to_owned(),
data: "_data".to_owned(),
data: DATA_DIR,
include_drafts: false,
posts: "posts".to_owned(),
post_path: None,
Expand Down
13 changes: 3 additions & 10 deletions src/legacy/wildwest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,12 @@ pub enum SassOutputStyle {
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SassOptions {
pub import_dir: String,
pub style: SassOutputStyle,
}

impl Default for SassOptions {
fn default() -> SassOptions {
SassOptions {
import_dir: "_sass".to_owned(),
style: SassOutputStyle::Nested,
}
SassOptions { style: SassOutputStyle::Nested }
}
}

Expand All @@ -163,7 +159,6 @@ pub struct GlobalConfig {
pub dest: String,
pub layouts: String,
pub drafts: String,
pub data: String,
pub include_drafts: bool,
pub posts: String,
pub post_path: Option<String>,
Expand All @@ -187,7 +182,6 @@ impl Default for GlobalConfig {
dest: "./".to_owned(),
layouts: "_layouts".to_owned(),
drafts: "_drafts".to_owned(),
data: "_data".to_owned(),
include_drafts: false,
posts: "posts".to_owned(),
post_path: None,
Expand All @@ -213,7 +207,6 @@ impl From<GlobalConfig> for config::Config {
dest,
layouts,
drafts,
data,
include_drafts,
posts,
post_path,
Expand All @@ -237,21 +230,20 @@ impl From<GlobalConfig> for config::Config {

let syntax_highlight = config::SyntaxHighlight { theme: syntax_highlight.theme };
let sass = config::SassOptions {
import_dir: sass.import_dir,
style: match sass.style {
SassOutputStyle::Nested => config::SassOutputStyle::Nested,
SassOutputStyle::Expanded => config::SassOutputStyle::Expanded,
SassOutputStyle::Compact => config::SassOutputStyle::Compact,
SassOutputStyle::Compressed => config::SassOutputStyle::Compressed,
},
..Default::default()
};

config::Config {
source: source,
dest: dest,
layouts: layouts,
drafts: drafts,
data: data,
include_drafts: include_drafts,
posts: posts,
post_path: post_path,
Expand All @@ -267,6 +259,7 @@ impl From<GlobalConfig> for config::Config {
dump: vec![],
syntax_highlight: syntax_highlight,
sass: sass,
..Default::default()
}
}
}
1 change: 0 additions & 1 deletion tests/fixtures/custom_data_folder/.cobalt.yml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions tests/fixtures/custom_data_folder/_other_data_dir/movies.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions tests/fixtures/custom_data_folder/index.liquid

This file was deleted.

9 changes: 0 additions & 9 deletions tests/fixtures/custom_data_folder/movies.liquid

This file was deleted.

3 changes: 1 addition & 2 deletions tests/fixtures/sass_custom_config/.cobalt.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
sass:
import_dir: _sass_includes
style: Compressed
style: Compressed
5 changes: 0 additions & 5 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,3 @@ pub fn sass_custom_config() {
pub fn data_files() {
run_test("data_files").expect("Build error");
}

#[test]
pub fn data_files_custom_folder() {
run_test("custom_data_folder").expect("Build error");
}
8 changes: 0 additions & 8 deletions tests/target/custom_data_folder/index.html

This file was deleted.

23 changes: 0 additions & 23 deletions tests/target/custom_data_folder/movies.html

This file was deleted.

0 comments on commit 692ff3b

Please sign in to comment.