Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 19:26:09 +01:00

Add documentation how to render PlantUML in code blocks. (#9894)

* Add documentation how to render plantuml in code blocks.

* Review comments

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
David Svantesson 2020-01-21 00:34:23 +01:00 committed by Antoine GIRARD
parent d730725e5c
commit 9bc8413534
2 changed files with 37 additions and 1 deletions

View file

@ -18,7 +18,8 @@ menu:
Customizing Gitea is typically done using the `CustomPath` folder - by default this is Customizing Gitea is typically done using the `CustomPath` folder - by default this is
the `custom` folder from the running directory, but may be different if your build has the `custom` folder from the running directory, but may be different if your build has
set this differently. This is the central place to override configuration settings, set this differently. This is the central place to override configuration settings,
templates, etc. You can check the `CustomPath` using `gitea help`. You can override templates, etc. You can check the `CustomPath` using `gitea help`. You can also find
the path on the _Configuration_ tab in the _Site Administration_ page. You can override
the `CustomPath` by setting either the `GITEA_CUSTOM` environment variable or by the `CustomPath` by setting either the `GITEA_CUSTOM` environment variable or by
using the `--custom-path` option on the `gitea` binary. (The option will override the using the `--custom-path` option on the `gitea` binary. (The option will override the
environment variable.) environment variable.)
@ -139,6 +140,39 @@ you would need to remove `{{if .RequireHighlightJS}}` and `{{end}}`.
Mermaid will detect and use tags with `class="language-mermaid"`. Mermaid will detect and use tags with `class="language-mermaid"`.
#### Example: PlantUML
You can add [PlantUML](https://plantuml.com/) support to Gitea's markdown by using a PlantUML server.
The data is encoded and sent to the PlantUML server which generates the picture. There is an online
demo server at http://www.plantuml.com/plantuml, but if you (or your users) have sensitive data you
can set up your own [PlantUML server](https://plantuml.com/server) instead. To set up PlantUML rendering,
copy javascript files from https://gitea.com/davidsvantesson/plantuml-code-highlight and put them in your
`custom/public` folder. Then add the following to `custom/footer.tmpl`:
```html
{{if .RequireHighlightJS}}
<script src="https://your-server.com/deflate.js"></script>
<script src="https://your-server.com/encode.js"></script>
<script src="https://your-server.com/plantuml_codeblock_parse.js"></script>
<script>
<!-- Replace call with address to your plantuml server-->
parsePlantumlCodeBlocks("http://www.plantuml..com/plantuml")
</script>
{{end}}
```
You can then add blocks like the following to your markdown:
```plantuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
```
The script will detect tags with `class="language-plantuml"`, but you can change this by providing a second argument to `parsePlantumlCodeBlocks`.
## Customizing Gitea mails ## Customizing Gitea mails
The `custom/templates/mail` folder allows changing the body of every mail of Gitea. The `custom/templates/mail` folder allows changing the body of every mail of Gitea.

View file

@ -22,6 +22,8 @@ it is just a matter of:
* add some configuration to your `app.ini` file * add some configuration to your `app.ini` file
* restart your Gitea instance * restart your Gitea instance
This supports rendering of whole files. If you want to render code blocks in markdown you would need to do something with javascript. See some examples on the [Customizing Gitea](../customizing-gitea) page.
## Installing external binaries ## Installing external binaries
In order to get file rendering through external binaries, their associated packages must be installed. In order to get file rendering through external binaries, their associated packages must be installed.