How do reference the image files generated by external renders? #7956

Closed
opened 2025-11-02 07:42:36 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @lihanglin on GitHub (Oct 9, 2021).

Gitea Version

1.14.5

Git Version

2.17.0

Operating System

CentOS Linux release 7.9.2009

How are you running Gitea?

Use the official release

Database

SQLite

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

I did not find any tips in FAQ or documents.
Please allow me to post this question here.

I enabled the external render "asciidoctor" in Gitea to support to display *.adoc file in WEB directly.
Everything is fine but the image file.
There are wavedrom diagrams in some *.adoc files and asciidoctor would convert and generate the *.svg files when you browsed the *.adoc file each time.

The svg files cannot be referenced or fond in WEB page.
The HTML in my Gitea page is like as below to show 404 error (image not found)

<div>
<img src="/$USER/$REPO/media/branch/master/dir/diag-892f37f776e5e3e93dd838003910a66a.svg" alt="Diagram" width="819" height="520"/>
</div>

There are no "/$USER/$REPO/media/branch/master/" directory path in my server.

The generated image file is put at $AppPath where gitea binary located.
How do I set up the Gitea to reference the files generated by asciidoctor?

Thanks.

Screenshots

No response

Originally created by @lihanglin on GitHub (Oct 9, 2021). ### Gitea Version 1.14.5 ### Git Version 2.17.0 ### Operating System CentOS Linux release 7.9.2009 ### How are you running Gitea? Use the official release ### Database SQLite ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Description I did not find any tips in FAQ or documents. Please allow me to post this question here. I enabled the external render "asciidoctor" in Gitea to support to display *.adoc file in WEB directly. Everything is fine but the image file. There are wavedrom diagrams in some *.adoc files and asciidoctor would convert and generate the *.svg files when you browsed the *.adoc file each time. The svg files cannot be referenced or fond in WEB page. The HTML in my Gitea page is like as below to show 404 error (image not found) ```html <div> <img src="/$USER/$REPO/media/branch/master/dir/diag-892f37f776e5e3e93dd838003910a66a.svg" alt="Diagram" width="819" height="520"/> </div> ``` There are no "/$USER/$REPO/media/branch/master/" directory path in my server. The generated image file is put at $AppPath where gitea binary located. How do I set up the Gitea to reference the files generated by asciidoctor? Thanks. ### Screenshots _No response_
GiteaMirror added the issue/needs-feedback label 2025-11-02 07:42:36 -06:00
Author
Owner

@zeripath commented on GitHub (Oct 9, 2021):

What is your [markup] config?

@zeripath commented on GitHub (Oct 9, 2021): What is your `[markup]` config?
Author
Owner

@lihanglin commented on GitHub (Oct 10, 2021):

Hi @zeripath

My markup config as below

[markup.sanitizer.1]

; The following keys can appear once to define a sanitation policy rule.
; This section can appear multiple times by adding a unique alphanumeric suffix to define multiple rules.
; e.g., [markup.sanitizer.1] -> [markup.sanitizer.2] -> [markup.sanitizer.TeX]
; ELEMENT = span
; ALLOW_ATTR = class
; REGEXP = ^(info|warning|error)$

[markup.asciidoc]
ENABLED         = true
; List of file extensions that should be rendered by an external command
FILE_EXTENSIONS = .adoc,.asciidoc
; External command to render all matching extensions
RENDER_COMMAND = "/srv/gitea/custom/renders/asciidoctor"
; Don't pass the file on STDIN, pass the filename as argument instead.
IS_INPUT_FILE   = false

I have a wrapper for asciidoctor to preset some attribute
/srv/gitea/custom/renders/asciidoctor

/usr/local/bin/asciidoctor -s -r asciidoctor-diagram -a showtitle -a allow-uri-read -a wavedrom-format=svg -a diagram-svg-type=inline --out-file=- -
@lihanglin commented on GitHub (Oct 10, 2021): Hi @zeripath My markup config as below ```ini [markup.sanitizer.1] ; The following keys can appear once to define a sanitation policy rule. ; This section can appear multiple times by adding a unique alphanumeric suffix to define multiple rules. ; e.g., [markup.sanitizer.1] -> [markup.sanitizer.2] -> [markup.sanitizer.TeX] ; ELEMENT = span ; ALLOW_ATTR = class ; REGEXP = ^(info|warning|error)$ [markup.asciidoc] ENABLED = true ; List of file extensions that should be rendered by an external command FILE_EXTENSIONS = .adoc,.asciidoc ; External command to render all matching extensions RENDER_COMMAND = "/srv/gitea/custom/renders/asciidoctor" ; Don't pass the file on STDIN, pass the filename as argument instead. IS_INPUT_FILE = false ``` I have a wrapper for asciidoctor to preset some attribute /srv/gitea/custom/renders/asciidoctor ```bash /usr/local/bin/asciidoctor -s -r asciidoctor-diagram -a showtitle -a allow-uri-read -a wavedrom-format=svg -a diagram-svg-type=inline --out-file=- - ```
Author
Owner

@zeripath commented on GitHub (Oct 12, 2021):

Fundamentally the issue is that our external renderers are not expected to create data outside of their output streams and so it would need to include the images as a <img src="data:image/jpeg;base64,... so you would need to use data-uri attribute but you may have to adjust the sanitizer.

@zeripath commented on GitHub (Oct 12, 2021): Fundamentally the issue is that our external renderers are not expected to create data outside of their output streams and so it would need to include the images as a `<img src="data:image/jpeg;base64,...` so you would need to use data-uri attribute but you may have to adjust the sanitizer.
Author
Owner

@lihanglin commented on GitHub (Oct 13, 2021):

Hi @zeripath

It's much clear to me about the failure I hit.
Thanks.

@lihanglin commented on GitHub (Oct 13, 2021): Hi @zeripath It's much clear to me about the failure I hit. Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7956