Gitea: Add support for UML rendering

Created on 5 May 2018  路  11Comments  路  Source: go-gitea/gitea

Hey, a bit of a feature request.

It would be great to get UML support in Gitea鈥擯lantUML, especially. Unfortunately, I'm not aware of any native Go library for this, though. And, it seems the consensus is to minimize external dependencies.

For a rough idea as to what the final outcome might look like, it's worth taking a look at Gitlab's PlantUML integration - which can be found here.

kinfeature kinproposal

All 11 comments

Here's a tiny starting bounty. If anyone else wants to contribute: bountysource issue

Bumped the current bounty to $30.

There is no go renderer so only possibility would be to use external renderer with plantuml Java command line tool

Yeah, unfortunately, that seems to be the case. Personally, I'm not against having an optional integration with an external renderer, though. Not sure how everyone else feels, though.

There is no go renderer so only possibility would be to use external renderer with plantuml Java command line tool

java (jre) as an additional runtime dependency? Sounds not so good (also with the promise that gitea use less ressources and can be run on a raspberry pi).

@markuman if we went the route of using an external renderer like that, I would imagine this would be an optional feature

Closing due to external rendering support.

Hi, I'm sorry if there was a better place to comment. I guess this is just fyi....

[edited for additional info]

I wanted to add to the conversation that plantuml, for instance, could be supported via localhost. obviously this would mean installing graphviz and running a plantuml-server. In that sense a plantuml code block could be post processed via javascript that points to the local server. This would be a similar approach like highlight.js uses.

In the current v1.6.0 gitea manages direct server calls just fine (i.e here's an example without server routing but you get the point):

![local works](http://localhost:8989/plantuml/png/itBBB2ekKN1CBialikAoSipBByb8BOh9ImGBA2GMA_YcvXbnWRaWfZ6KQUMJ2DI6eie40000)

![remote not allowed](http://plantuml.com:80/plantuml/png/itBBB2ekKN1CBialikAoSipBByb8BOh9ImGBA2GMA_YcvXbnWRaWfZ6KQUMJ2DI6eie40000)

As I mentioned already, you could use server routing in such a way as to have a standardized FQDN that would be allowed as well. Anyway, I'm doing something like this on my personal server.

Note that via a local plantuml server this works too via proxy (note the offsite text file being referenced):

![local proxy to remote file](http://localhost:8989/plantuml/proxy?src=https://raw.github.com/plantuml/plantuml-server/master/src/main/webapp/resource/test2diagrams.txt)

[edit]
Additionally you can just generate the static images from the command line with the plantuml server jar file. Check out the cli instructions for plantuml.

# command that outputs png files to `images/`
java -jar ~/3rdparty/bin/plantuml.jar ./*.puml  -o images/

The way Gitlab support this is by using a plantuml server to generate the image (a public or private set up server). Thus they only need to compress and encode the text in base64. The resulting rendered page in GL looks like this:

<img src="http://www.plantuml.com/plantuml/png/[zlib-b64-encoded-string]" >

A more generic way to add support for this would be to add support for the following features:

  • Allow external renders to output content other than html (images and possibly other formats that can be displayed directly like pdfs). It would be possible already now by having a wrapper script that generates an html img tag for the output from the renderer.
  • Allow external render/highligher for code blocks. So you specify that code blocks for plantuml shall be using an external command to generate the output (can be html or image)

I think mermaid js has some way of doing this

Just for the record. I'm using the following external-renderer setup.

Required Software

  1. pandoc: Available via package manager
  2. plantuml
  3. pandoc-plantuml-filter: Installed via pip

Gitea Config

[markup.markdown]                                                                                                                     
ENABLED                = true                                                                                                         
FILE_EXTENSIONS = .md,.markdown                                                                                                       
RENDER_COMMAND  = pandoc -f markdown -t html --filter pandoc-plantum

Apache Rewerse Proxy

A RewriteRule is required to fix the URL-Path of the generated images :

<Directory "PATH_TO_GITEA_INSTALLATION/plantuml-images">                                                                                             
       AllowOverride None                                                                                                                
       Require all granted                                                                                                               
</Directory>                                                                                                                          

Alias /plantuml-images/ /PATH_TO_GITEA_INSTALLATION/plantuml-images/                                                                                    
RewriteEngine On                                                                                                                      
RewriteRule "^/.+/plantuml-images/([a-z0-9]*).svg$" "/plantuml-images/$1.svg" [R,L]                                                   
ProxyPass /plantuml-images !        
ProxyPass / http://127.0.0.1:3000/ nocanon
AllowEncodedSlashes NoDecode
ProxyPassReverse / http://127.0.0.1:3000/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakimfett picture jakimfett  路  3Comments

kolargol picture kolargol  路  3Comments

kifirkin picture kifirkin  路  3Comments

BNolet picture BNolet  路  3Comments

cookiengineer picture cookiengineer  路  3Comments