Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v2.4.0 #86

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion example/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
14 changes: 10 additions & 4 deletions src/util/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ pub struct Template {
pub mode: Option<SchemesEnum>,
pub colors_to_compare: Option<Vec<ColorDefinition>>,
pub compare_to: Option<String>,
pub hook: Option<String>,
pub pre_hook: Option<String>,
pub post_hook: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -314,6 +319,7 @@ fn format_hook(
template: &Template,
engine: &Engine,
render_data: &mut Value,
hook: &String
) -> Result<(), Report> {
let closest_color: Option<String> =
if template.colors_to_compare.is_some() && template.compare_to.is_some() {
Expand All @@ -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 {
Expand Down