diff --git a/CHANGELOG.md b/CHANGELOG.md index daa450e..4d458ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,49 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.4.0](https://github.com/InioX/matugen/compare/v2.3.0...v2.4.0) - 2024-08-13 + +### Added +- add `pre_hook` and `post_hook` +- improve error message for color parsing +- change resize filter to Lanczos3 ([#89](https://github.com/InioX/matugen/pull/89)) +- increase windows stack size to 8mb (fixes [#87](https://github.com/InioX/matugen/pull/87)) +- fix relative paths for templates, format `compare_to` ([#83](https://github.com/InioX/matugen/pull/83)) +- add template formatting for hook ([#83](https://github.com/InioX/matugen/pull/83)) +- add `hook` and variables inside it ([#83](https://github.com/InioX/matugen/pull/83)) +- add color comparsion ([#83](https://github.com/InioX/matugen/pull/83)) +- add `--prefix` argument +- add `version_check` setting ([#78](https://github.com/InioX/matugen/pull/78)) + +### Fixed +- wrong display of alpha channel for `set_alpha` ([#95](https://github.com/InioX/matugen/pull/95)) +- divide all alpha values by 255 for output ([#95](https://github.com/InioX/matugen/pull/95)) +- set_alpha missing a `:` in example ([#95](https://github.com/InioX/matugen/pull/95)) +- make hooks not depend on `colors_to_compare` ([#93](https://github.com/InioX/matugen/pull/93)) +- remove useless debugging +- update arguments to remove borrow error ([#85](https://github.com/InioX/matugen/pull/85)) +- update syntax in example template ([#77](https://github.com/InioX/matugen/pull/77)) + +### Other +- oops bad merge ([#95](https://github.com/InioX/matugen/pull/95)) +- Merge branch 'main' of https://github.com/InioX/matugen +- add float parameter for `format_hsla` and `format_rgba` ([#95](https://github.com/InioX/matugen/pull/95)) +- update CHANGELOG.md +- add set_alpha filter example +- add the set_alpha filter to the engine +- add format_rgba_float and format_hsla_float functions to format the alpha value as a float instead of u8 +- add set_alpha filter +- Nix module: add package option +- Merge branch 'main' of https://github.com/InioX/matugen +- bump `material-colors` to 0.4.0 +- *(examples)* add note for `custom_colors` +- rename `compared_color` to `closest_color` ([#83](https://github.com/InioX/matugen/pull/83)) +- separate some stuff into functions +- format code +- Merge branch 'main' of https://github.com/InioX/matugen +- run `cargo fmt` +- *(readme)* update version badges + ### Added - add `set_alpha` filter diff --git a/Cargo.lock b/Cargo.lock index 76ce943..fdf8710 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1243,7 +1243,7 @@ dependencies = [ [[package]] name = "matugen" -version = "2.3.0" +version = "2.4.0" dependencies = [ "ahash", "clap", diff --git a/Cargo.toml b/Cargo.toml index aeada78..8e530f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "matugen" -version = "2.3.0" +version = "2.4.0" authors = ["InioX"] description = "A material you color generation tool with templates" repository = "https://github.com/InioX/matugen" diff --git a/example/config.toml b/example/config.toml index a3d791a..b500d2b 100644 --- a/example/config.toml +++ b/example/config.toml @@ -30,7 +30,8 @@ colors_to_compare = [ { name = "purple", color = "#800080" }, ] compare_to = "{{colors.primary.default.hex}}" -hook = 'echo "source color {{colors.source_color.default.hex}}, source image {{image}}, closest color {{closest_color}}"' +pre_hook = 'echo "source color {{colors.source_color.default.hex}}, source image {{image}}, closest color {{closest_color}}"' +post_hook = 'echo "after gen"' # Only hex values [config.custom_colors] diff --git a/src/util/template.rs b/src/util/template.rs index 30354f0..e77e8e8 100644 --- a/src/util/template.rs +++ b/src/util/template.rs @@ -54,7 +54,8 @@ pub struct Template { pub mode: Option, pub colors_to_compare: Option>, pub compare_to: Option, - pub hook: Option, + pub pre_hook: Option, + pub post_hook: Option, } #[derive(Serialize, Deserialize, Debug)] @@ -186,8 +187,8 @@ impl Template { (template.input_path.try_resolve()?.to_path_buf(), template.output_path.try_resolve()?.to_path_buf()) }; - if template.hook.is_some() { - format_hook(template, &engine, &mut render_data)?; + if template.pre_hook.is_some() { + format_hook(template, &engine, &mut render_data, template.pre_hook.as_ref().unwrap())?; } if !input_path_absolute.exists() { @@ -241,6 +242,10 @@ impl Template { i, templates, )?; + + if template.post_hook.is_some() { + format_hook(template, &engine, &mut render_data, template.post_hook.as_ref().unwrap())?; + } } Ok(()) } @@ -314,6 +319,7 @@ fn format_hook( template: &Template, engine: &Engine, render_data: &mut Value, + hook: &String ) -> Result<(), Report> { let closest_color: Option = if template.colors_to_compare.is_some() && template.compare_to.is_some() { @@ -327,7 +333,7 @@ fn format_hook( None }; - let t = engine.compile(template.hook.as_ref().unwrap())?; + let t = engine.compile(hook)?; let res = if template.colors_to_compare.is_some() && template.compare_to.is_some() { format_hook_text(render_data, closest_color, t) } else {