Open cweagans opened 2 years ago
The Kroki server only includes the following JVM-based diagrams libraries:
[Ditaa](http://ditaa.sourceforge.net/)
[PlantUML](https://github.com/plantuml/plantuml) including [C4 model](https://github.com/RicardoNiepel/C4-PlantUML)
[Structurizr](https://github.com/structurizr/dsl)
[UMlet](https://github.com/umlet/umlet)
If you want to use additional diagram libraries, you will either need to install them manually on your system or use [Docker or Podman](https://docs.kroki.io/kroki/setup/install/#docker-podman)
It appears to be a wrapper around the other diagram renderers so including the other type is required
True. The hosted service has all of them included though.
@cweagans Quick question, cold you provide an example of footer.tmpl
use with your current script please?
Literally just this:
<script src="/assets/kroki.js" type="text/javascript"></script>
This is the entire contents of my custom/
directory:
custom/public/kroki.js
custom/templates/custom/footer.tmpl
kroki.js
is the JS in the issue body above.
Literally just this:
<script src="/assets/kroki.js" type="text/javascript"></script>
This is the entire contents of my
custom/
directory:custom/public/kroki.js custom/templates/custom/footer.tmpl
kroki.js
is the JS in the issue body above.
Thanks, with that and a docker-compose self-host it works perfectly. :partying_face:
@cweagans I've found a weird beaviour not sure if the issue is from the kroki.js
.
If you put two wavedrom
(any block of code) back two back only the first is render. I suspect that a sequece exist to early during the fetch of block of code. Do you have the same issue on your side?
I've fixed the issue by remplacing the:
for (var block_i = 0; block_i < codeBlocks.length; block_i++) {
with:
Array.from(codeBlocks).forEach(function(element, index, array) {
and codeBlocks[block_i]
to element
Hi, I am trying to get this to work in a dockerized instance but cannot get the examples to render properly. My docker compose file looks like this:
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.21.10
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=postgres
- GITEA__database__HOST=db:5432
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=****
- GITEA__server__PROTOCOL=https
- GITEA__server__HTTP_PORT=443
- GITEA__server__DOMAIN=${DOMAIN}
- GITEA__server__SSH_DOMAIN=${DOMAIN}
- GITEA__server__ROOT_URL=https://${DOMAIN}/
- GITEA__server__CERT_FILE=/certificates/fullchain.pem
- GITEA__server__KEY_FILE=/certificates/privkey.pem
- GITEA__APP_NAME=${APP_NAME}
restart: unless-stopped
networks:
- gitea
volumes:
- ./gitea:/data
- ./customizations/public:/data/gitea/public
- ./customizations/templates/custom:/data/gitea/templates/custom
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- ./certificates:/certificates
ports:
- "443:443"
- "222:22"
depends_on:
- db
db:
image: postgres:14
restart: unless-stopped
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=****
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- ./postgres:/var/lib/postgresql/data
I have the files configured as described above (without the fix so far) but none of the diagrams renders.
I am probably missing something, but I cannot tell what.
@Crown0815 Your compose file doesn't have the docker for kroki. Just to be sure do you have at least the base docker up for kroki?
check: here
Hi @alexandreSalconiDenis,
I did not have these services indeed. I added them now, but still none of the diagrams render. I assumed it was unnecessary to self-host based on this line from the kroki.js
script:
newDiagram.innerHTML = '<img src="https://kroki.io/' + currentValue + '/svg/' + payload + '" />';
I assumed that this would go to the hosted kroki
instance and render the images there.
The contents of kroki.js
from here can be taken as is, right? I am unfortunately not familiar with JavaScript so I just took the script as I found it.
For everyone interested in this topic:
As described in help, there are two ways to do this.
The first way is to draw when rendering markdown (including wiki), which is basically the way @cweagans does it.
However, it needed to be placed in custom/public/assets/kroki.js
instead of custom/public/kroki.js
.
Also, if you want to reference a self-hosted kroki server, you need to replace https://kroki.io/
with your own server.
- newDiagram.innerHTML = '<img src="https://kroki.io/' + currentValue + '/svg/' + payload + '" />';
+ const SERVER_URL = "https://your-kroki-server.example.com/"
+ newDiagram.innerHTML = '<img src=' + SERVER_URL + currentValue + '/svg/' + payload + '" />';
And another way is to render file.plantuml
when opened directly.
This one requires editing app.ini
and calling the renderer.
I didn't know how to call it at first, but it is no problem, just run the API from curl.
[markup.plantuml]
ENABLED = true
FILE_EXTENSIONS = .puml,.plantuml,.pu
RENDER_COMMAND = "curl --data-binary @- https://your-kroki-server.example.com/plantuml/svg"
IS_INPUT_FILE = false
RENDER_CONTENT_MODE = no-sanitizer
I hope this helps.
@arika0093 Thank you so much.
However, it needed to be placed in custom/public/assets/kroki.js instead of custom/public/kroki.js.
This was the issue on my side. Now I get the diagrams to render properly.
I came across an issue which I am curious if there is a solution for. I am using ꞉
(U+a789) in a Ditaa
diagram, which breaks the diagram because the warning
The character U+a789 "꞉" could be confused with the ASCII character U+003a ":", which is more common in source code. [Adjust settings](https://github.com/go-gitea/gitea/issues/20803)
Is also included in the rendering. Is there a way to exclude it from rendering the warning?
Feature Description
It would be cool if Gitea allowed users to opt in to using Kroki for rendering diagrams. It is possible to self-host Kroki in case users don't want to send their diagram data to a third party service for rendering. Kroki supports almost two dozen kinds of diagrams (including Mermaid, which is already supported -- maybe it would be worth replacing the Mermaid support with Kroki?).
I think this will need some thinking around what configuration options are offered. Off the top of my head, I think it would need the following, but not sure:
In my Gitea instance, I have this in a
kroki.js
file that I load from my custom footer template:Screenshots
This is a test page that I created in a wiki that shows all the different diagram types (note that the Mermaid diagram looks different because it's using the default Gitea rendering instead of Kroki):
Screenshot
![kroki demo](https://user-images.githubusercontent.com/101590/184734904-7f39b890-fb1e-4e18-8c8a-ac2c11e7a751.png)Markdown source for demo page
```` ```blockdiag blockdiag { Kroki -> generates -> "Block diagrams"; Kroki -> is -> "very easy!"; Kroki [color = "greenyellow"]; "Block diagrams" [color = "pink"]; "very easy!" [color = "orange"]; } ``` ```bpmn