plantuml / plantuml-server

PlantUML Online Server
https://plantuml.com/
GNU General Public License v3.0
1.6k stars 463 forks source link

How to set a default theme (-theme directive for jar) with plantuml Server #233

Closed bharatrajagopalan closed 1 year ago

bharatrajagopalan commented 2 years ago

in the jar file one could use the -theme directive in the command line to select a default theme for the server. How does one achieve that with the plantuml server.

And is there a way to pass a custom theme url as an argument to the server without the !theme directive in the puml file?

Trying to setup an internal plantuml server for use and trying to simplify - enforce a default theme at server level, rather than having to have consumers use the !theme directive in every plantuml file they create.

bharatrajagopalan commented 2 years ago

As I am using the plantuml-markdown plugin with mkdocs-material' I submitted this pull requestto the plantuml-markdown team which lets the base theme be configured at plugin level and sent using the !theme directive.

It is interesting that there are a few commands that error out when !theme is used, e.g. version, listfonts, stdlib - so I have created an exception list that can be configured in the plugin. It would be nice if plantuml would just ignore the theme directive in such cases rather than error out to simplify.

Is there a full list of such commands available somewhere? Currently I configured this based on searching different parts of the site and testing.

Ruakij commented 1 year ago

You can set the environment-var PLANTUML_CONFIG_FILE to the path of your config which injects the theme.

bharatrajagopalan commented 1 year ago

@Ruakij I guess that variable is more intended to be used when using the jar file; when using the server, I am guessing that it needs to be set as a variable at the server side and is not something that can be passed in GET/POST request?

Ruakij commented 1 year ago

Sorry, the Servlet doesnt have anything for that.

Shouldnt be too hard to add though.

Of course more clean would be to load at startup, index available themes/configs and then return out of memory. More memory usage, negligible - faster response, but as the system caches anyways shouldnt be too bad.

Thats already done with the config here.

EDIT: Okay, config isnt read every time but lazy-loaded, my bad.

bharatrajagopalan commented 1 year ago

Makes sense - I will close this issue for now, but will look into the above when I get some time.

For now my pull request that I have above for plantuml-markdown does the job, so not urgent

Ruakij commented 1 year ago

Feel free to use the work i have begun: https://github.com/Ruakij/plantuml-server/tree/feat_themeFromRequest

Unfortunately its broken, the UrlDecode from path throws an Exception. Maybe you can find whats wrong.