esteinberg / plantuml4idea

Intellij IDEA plugin for PlantUML
Apache License 2.0
629 stars 114 forks source link

Feature Request: Server render #286

Closed dragove closed 3 years ago

dragove commented 3 years ago

PlantUML supports running as a server by this command:

java -jar -picoweb

then by encode input text using brotli compression and a 'base64 like encoding algorithm' to a new text and post it to the sever to get the rendered image. It's useful if a group use the same server with same plantuml packages (e.g. C4 model package). I suggest to add a config option to use server render with a URL as an input. This feature is implemented in plantuml for vscode extension so I am looking forward to the same feature in idea. Related docs: plantuml picoserver plantuml text encoding

krasa commented 3 years ago

What is the use case? You want to run intelliJ on some server instead of running a lightweight plantuml server?

dragove commented 3 years ago

I want a config option to set a plantuml server URL(e.g. http://www.plantuml.com/plantuml). Then the plugin post my text to the URL after encoding (sth like http://www.plantuml.com/plantuml/png/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000), and return the image to the plugin preview window.

krasa commented 3 years ago

All right, that is certainly possible, but why would you do that? You could just do this, if you have some common packages: image

dragove commented 3 years ago

In a same group, I can update my packages in the server, then my coworkers can use the newest packages immediately without redownload the packages (or maybe use git pull). If the include.path can be a online path (e.g. https://raw.githubusercontent.com/xxx/yyy/master/) is also a good way to solve my problem. (It shouldn't be a problem though)

krasa commented 3 years ago

include.path is only for local folders afaik.

VS Code needs either a server or daemon for performance reasons, but for IntelliJ it sounds more like a feature creep.

There is nothing easier than adding those packages as an extra module to an IntelliJ project, and update it from VCS, if you prefer to use a single project, or update them separatelly.

But if you really want it, then pull request welcomed (it should also have an extra proxy settings). I would probably call it from org.plantuml.idea.adapter.FacadeImpl

koriit-kontakt commented 3 years ago

Hello, amazing work with the plugin! I am in a similar situation as @dragondove where I would like to use server rendering for the preview. In my use case, we use Asciidoc for our documentation. The most popular plugins for Asciidoc preview (both in IDEA and VSCode) use Kroki server for rendering embedded PlantUML diagrams. The same applies to rendering diagrams in Antora documentation portal.

This plugin fills in nicely when we want to move diagrams to separate files and edit them from there, however, we would like to have a consistent preview experience, and to achieve that we would need that server rendering option.

krasa commented 3 years ago

You can try a prototype. Saving to file is not yet implemented.

plantuml4idea.zip

krasa commented 3 years ago

plantuml4idea.zip

krasa commented 3 years ago

Done.

koriit-kontakt commented 3 years ago

Sweet! Works like a charm! Thank you.

The only problem I noticed is the "Copy as PlantUML Server link" as it is built as serverUrl + "uml/" + encoded which some servers might not support (like kroki.io). Why not use the actually rendered URL (svg/png)?

krasa commented 3 years ago

Because nobody requested it :-)

krasa commented 3 years ago

you can update

krasa commented 3 years ago

I made a change, you will need to configure the url again in the new update.

koriit-kontakt commented 3 years ago

Awesome!