[FEAT] Document links in wiki #12439
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Does your problem still exist on the latest Forgejo version?
Yes, the problem still exists (tested on a next instance)
About your usage of Forgejo
For many projects we like having an accompanying wiki.
Problem description
In this wiki we often like to link to documents/files directly, like so (i.e.
in Home.md):Where the file
document.pdfis pushed to therepository.wiki.gitlike so:It seems, currently this is not supported. When clicking on the link in the wiki, we're redirected to the wiki itself, the document is not opened.
Potential workarounds
Edit (@mahlzahn): Currently links to documents can be used with
raw/prefix, e.g.,Forgejo Version
15.0.1
Other details about your environment (software names and versions)
Firefox esr 140.10
Solutions
Accepted solutions to address this problem will go here
TL;DR: wiki module needs to insert
.../raw/...to all links, not just images.On further investigation I might have found the cause:
NOT working: document links. i.e.:
[document](doc/document.pdf)-->https://host.com/repository/wiki/doc/document.pdfThe generated path is MISSING
.../raw/...working: images
-->https://host.com/repository/wiki/raw/images/image.pngHere, the wiki module inserts
.../raw/...so the link correctly points to the URL for the imageThis is caused most likely by
codeberg.org/forgejo/forgejo@69cf1f3333/modules/markup/html.go (L765-797)For images, the path is resolved with:
while for non-images, the path is merely joined. no distinction for other file/media types is made:
There are many related issues over there at Codeberg’s tracker, e.g., https://codeberg.org/Codeberg/Community/issues/1724 https://codeberg.org/Codeberg/Community/issues/554
And also Forgejo has these two related open issues: https://codeberg.org/forgejo/forgejo/issues/2752 https://codeberg.org/forgejo/forgejo/issues/5408
Indeed, the current workaround is
But it is not very elegant. I agree that it would be good if
doc/document.pdflinks correctly instead, but it will need special care to not be a breaking change for people which are used to already useraw/doc/document.pdf.