asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
326 stars 98 forks source link

Easy configuration of diagram servers #272

Closed Kinokin closed 1 year ago

Kinokin commented 4 years ago

Current settings screen doesn't provide easy way to configure url for plantuml and kroki servers

Suggestion: For every diagram server have three settings

anb0s commented 4 years ago

Similar question: How kroki can be used?

I've just found the setting ""asciidoc.use_kroki": true", but if i disable the "plantuml-server-url" then diagrams are not rendered.

anb0s commented 4 years ago

see #277

danyill commented 4 years ago

@anb0s you can set the diagram servers using the attribute which is provided for each.

For asciidoctor-kroki, in the document header set the appropriate attribute, something like this:

:kroki-server-url: https://kroki.io

For asciidoctor-plantuml to set a specific server, use something like the following in the document header:

:plantuml-server-url: http://www.plantuml.com/plantuml

For more configuration options, see the extension readme.

I think we should document these more clearly in this extension's Readme but also that these configuration options are sufficiently simple that it does not warrant an additional configuration option. Additionally user's might want to vary options between documents which is why setting these options as per-document attributes seems to me to be the right idea.

So @Kinokin I'm a little resistant to adding an additional configuration option for this but I'm happy to update the Readme. I don't want to provide configuration options which avoid the need to learn the "normal use" of Asciidoctor extensions or their configuration because I think this goes against the intent of Asciidoc (we're avoiding the heavy GUI world, so creating a new GUI within vscode for this extension doesn't seem like the right idea to me).

@anb0s if you can't get asciidoctor-kroki to work, please provide a minimal document with the problem and we can take a look at it. Perhaps a good test document would be the one shown in the Readme. This should produce something like:

image

Kinokin commented 4 years ago

Adding the attributes is not an option to me. The server setup is a local setting of a user and shouldn't be part of the document.

What may work is an user defined attribute file defining the local setup.

anb0s commented 4 years ago

@danyill thank you i will try this attribute in the document, but i think (like @Kinokin ) this should be configured in VSCode as setting like it's done for PlantUML server and then passed to asciidoctor.js as attribute parameter -a kroki-server-url=http::/localhost:8000...

anb0s commented 4 years ago

I've played with document attrubute :kroki-server-url: http://localhost:8000 and it works with own server now!

E.g. for reading the PlantUML version:

Version
[plantuml, "{plantUMLDir}diagram-version", svg]
....
@startuml
checkversion
@enduml
....

image

Today it also works with uncommented line //:kroki-server-url: http://localhost:8000 or using :kroki-server-url: https://kroki.io.

It returns now newer version of PlantUML --> it looks like kroki.io was updated :) :

image

( I'm sure it did not worked two days before ;) )

@Kinokin it does not matter if the VSCode setting "asciidoc.use_asciidoctor_js": is true or false. Is it intended?

@danyill I can play now with kroki, but need a possiblity to define the kroki server in VSCode settings like for PlantUML server:

    "asciidoc.preview.attributes": {
        "plantuml-server-url": "http://localhost:8080"
        "kroki-server-url": "http://localhost:8000"
    },

or new possiblity to add / append attributes to asciidoc.js command line.

anb0s commented 4 years ago

I've now played with different setups and it looks like all the attributes defined in asciidoc.preview.attributes in settings.json are already passed to asciidoctor.js! The kroki-server-url is working as expected :

"asciidoc.preview.attributes": {
    "plantuml-server-url": "http://localhost:8080"
    "kroki-server-url": "http://localhost:8000"
}

no need to define it in all documents!

For me it's enough if it is documented and no need for UI...

P.S.: new investigation: if kroki-server-url is not provided (no attribute passed and not defined in document) it uses https://kroki.io as fallback and without i-net access it's not woking, should be documented too...

mirogta commented 4 years ago

Is there any way to disable the fallback to https://kroki.io?

We may have some potentially sensitive diagrams with Intellectual Property content that we'd rather not share with a 3rd party (kroki.io).

Also how can I tell if the fallback is happening? I can't find any logs or anything, which would tell me if my own kroki server works (it does in a browser/curl) when I try to use it from within VSCode Preview or if it falls back to kroki.io. Thanks

anb0s commented 4 years ago

@mirogta I think this should be addressed in asciidoctor-kroki so create an issue there.

mirogta commented 4 years ago

@mirogta I think this should be addressed in asciidoctor-kroki so create an issue there.

Good point - raised as https://github.com/Mogztter/asciidoctor-kroki/issues/70

danyill commented 4 years ago

@mirogta @Kinokin

You can also set kroki-server-url in the preview attributes of the extension. In this case it is set via the API and cannot be overriden without changing the User Settings (which presumably can be centrally managed in a corporate environment or if there are concerns about sensitive information).

image

This has to be set as JSON so in my settings.json I have an entry like:

"asciidoc.preview.attributes": {
      "kroki-server-url": "stayAwayFromKrokiIO"
    },

If this isn't sufficient then the standard corporate answer would be the firewall...

mirogta commented 4 years ago

@danyill thanks, that's useful.

We've added kroki.io into our firewall's whitelist, so that people can read about it and try the examples. But that means we can't use firewall to prevent leaking information.

I think it's unfortunate that the documentation and examples are on the same domain (https://kroki.io) as the API server. There is the https://docs.kroki.io/kroki/ documentation but it doesn't have the examples.

Perhaps the examples could be moved to the documentation - raised as https://github.com/yuzutech/kroki/issues/222

sturtison commented 3 years ago

Thanks all - Kroki makes it so much easier to access the diagrams.

While configuring it as covered above works, it makes it too easy for some people to not worry about the security, and hard enough for some to turn a blind eye to the security risk. Blocking kroki.io is not an option.

How can it be made easier to set these attributes - from the extension settings for example?

lidaling commented 1 year ago

My investigation is :

:kroki-server-url:http://localhost:8000 mark in adoc file header works ,but

    "asciidoc.preview.attributes": {
        "kroki-server-url": "http://localhost:8000",
    },
    "asciidoc.use_kroki": true,

does not work. Any idea for this?please

ggrossetie commented 1 year ago

It does work on my end. Did you refresh the preview?

lidaling commented 1 year ago

It does work on my end. Did you refresh the preview?

Yes ,I reopen preview with ctrl+ alt+ p command list .reopen or refresh does not work as well. In addition, the preview window is autofresh in my experience. Is there any log I can check?

ggrossetie commented 1 year ago

Which version are you using? Could you please try with the latest beta version 3.x?

lidaling commented 1 year ago

Which version are you using? Could you please try with the latest beta version 3.x?

versioned 3.0.1 is one pre-release . It does not work.setting.json as bellow:

   "asciidoc.extensions.enableKroki": true,
    "asciidoc.preview.asciidoctorAttributes": {
        "kroki-server-url": "http://localhost:8000",
    },

And more ,it seems header mark :kroki-server-url: http://localhost:8000 does not work too!

lidaling commented 1 year ago

Which version are you using? Could you please try with the latest beta version 3.x?

I start the kroki server with command java -jar kroki-server-v0.17.2.jar

ggrossetie commented 1 year ago

@lidaling Did you "Change Preview Security Settings" to enable loading content from http? Could you please share a screenshot as follows:

Version 2.9.6

image

Version 3.0.1

image

Also, please join the community chat https://asciidoctor.zulipchat.com/ to continue this discussion as we don't use the issue tracker as a support forum.

lidaling commented 1 year ago

@Mogztter

It was the key reason . I forgot to enable http content again after switch to 3.x version. It works now .

ggrossetie commented 1 year ago

Let's continue the discussion #480

Bedzior commented 1 year ago

In case someone's still wondering how to enable this for Asciidoc: the action is now called AsciiDoc: Manage Preview Security Settings and is only visible when the command palette is activated whilst in the preview.