structurizr / java

Structurizr for Java
https://docs.structurizr.com/java
Apache License 2.0
998 stars 285 forks source link

Revise class and method visibilities related to styles to use them programmatically #177

Closed ggrossetie closed 2 years ago

ggrossetie commented 2 years ago

Would it be possible to mark Styles.addStylesFromTheme as public to programmatically add styles?

https://github.com/structurizr/java/blob/075db91cbee4bb95f21e768bff8bbfb589870e60/structurizr-core/src/com/structurizr/view/Styles.java#L231-L233

I want to read styles from JSON files (located in the classloader) and I want to call Styles.addStylesFromTheme directly (without calling ThemeUtils.loadThemes)

It would also make things easier if RelationshipStyle had a public constructor since I'm decoding JSON.

simonbrowndotje commented 2 years ago

Am I correct in thinking that you've copied the theme JSON files for deployment inside of Kroki, which is why you're loading them via the classloader? The problem with doing this is (1) you won't get any theme updates (for example I recently published a theme for the AWS 2022 icons, and sometimes a theme needs a small fix), and (2) you won't be able to support custom themes (e.g. if a user is using a custom theme that supports their company branding).

I'm happy to add a way for you to introduce themes into the workspace, but it won't resolve the above issues.

ggrossetie commented 2 years ago

Am I correct in thinking that you've copied the theme JSON files for deployment inside of Kroki, which is why you're loading them via the classloader?

Yes that's correct!

The problem with doing this is (1) you won't get any theme updates (for example I recently published a theme for the AWS 2022 icons, and sometimes a theme needs a small fix)

That's expected. I will regularly update them. Alternatively, I can add https://static.structurizr.com/ to the allowlist if you don't mind? But even then, I will probably take care of loading the theme using an async HTTP client with aggressive timeout settings.

and (2) you won't be able to support custom themes (e.g. if a user is using a custom theme that supports their company branding).

Kroki is very strict regarding loading custom resources. I will most likely introduce this feature at a later stage since we are already doing something similar with PlantUML.

I'm happy to add a way for you to introduce themes into the workspace

Awesome! 👍🏻