Codeberg/Documentation
43
151
Fork
You've already forked Documentation
128

Can we have relative links to raw code work? #499

Open
opened 2024年12月04日 13:37:17 +01:00 by harald · 4 comments

I tried to link to some raw code in the README.md of a repository like

 [eglot-hierarchy.el](raw/branch/main/eglot-hierarchy.el)

as this seems to be the correct relative path as seen from the `README.md.

But this got an absolute URL prefixed to end up as ...../src/branch/main/raw....

It would be great if this could work.

If it is possible already, documentation in https://codeberg.org/Codeberg/Documentation/src/branch/main/content/markdown/using-links.md would be great.

(Not sure I am in the correct project. Should this rather go to pages-server or elsewhere?)

I tried to link to some raw code in the `README.md` of a repository like ```markdown [eglot-hierarchy.el](raw/branch/main/eglot-hierarchy.el) ``` as this seems to be the correct relative path as seen from the `README.md. But this got an absolute URL prefixed to end up as `...../src/branch/main/raw...`. It would be great if this could work. If it is possible already, documentation in https://codeberg.org/Codeberg/Documentation/src/branch/main/content/markdown/using-links.md would be great. (Not sure I am in the correct project. Should this rather go to pages-server or elsewhere?)
Collaborator
Copy link

Hi @harald,

The README.md actually is in the same folder as the eglot-hierarchy.el. Thus, a simple eglot-hierarchy.el or eglot-hierarchy.el should do what you want?

Edit: Probably you wanted the following? It won't work for forks, but at least for the main page.
[README.md](/Codeberg/Documentation/raw/branch/main/README.md)README.md

Hi @harald, The `README.md` actually is in the same folder as the `eglot-hierarchy.el`. Thus, a simple [eglot-hierarchy.el](eglot-hierarchy.el) or [[eglot-hierarchy.el]] should do what you want? Edit: Probably you wanted the following? It won't work for forks, but at least for the main page. `[README.md](/Codeberg/Documentation/raw/branch/main/README.md)` → [README.md](/Codeberg/Documentation/raw/branch/main/README.md)
Author
Copy link

What you suggest does not link to the raw code, but to a Forgejo rendering of the code. That's why my example has the raw/ in front of the path.

For the difference see: harald/Codeschnipselnotizen@ea7558d002/OrgmodeTryout.org

What you suggest does not link to the raw code, but to a Forgejo rendering of the code. That's why my example has the `raw/` in front of the path. For the difference see: https://codeberg.org/harald/Codeschnipselnotizen/src/commit/ea7558d002b91cb0d095bd4f49bdcd01440515f1/OrgmodeTryout.org
Collaborator
Copy link

Yes, I think that it is currently not implemented. Only with the absolute raw link including owner and repository. Would you be happy with an appended URL parameter of e.g. ?display=raw? That also is not implemented, yet.

Yes, I think that it is currently not implemented. Only with the absolute raw link including owner and repository. Would you be happy with an appended URL parameter of e.g. `?display=raw`? That also is not implemented, yet.
Author
Copy link

Hmm, so currently we have

 [eglot-hierarchy.el](raw/branch/main/some/path/eglot-hierarchy.el)

Then we would have

[eglot-hierarchy.el](some/path/eglot-hierarchy.el?display=raw)

where some/path is the normal file system path inside the git repo.

Yet, what about links to specific commits then? Consider me clicking on a specific link in the repository. In the URL bar (of reasonable browsers 😄) I see:

https://codeberg.org/harald/monqjfa/src/commit/38ac67b48612c13bcf27042f4182ac3e19a3c700/src/buma/Buma.java

From this link I can naively deduce a path relative to README.md as src/commit/38ac67b48612c13bcf27042f4182ac3e19a3c700/src/buma/Buma.java. So in addition to display=raw we might need commit=... and what not. In addition, creating the relative URL does not require me to dig through the documentation to figure out if and that those parameters exist.

Insofar the main point of my request is not a feature request but rather to remove a what seems like a misfeature --- the change of totally nice relative URL.

I am somewhat undecided whether extra parameters are worth the effort, as I can always just use the full absolute URL starting with /myuser/myrepo. Adding to the documentation a warning that relative URLs won't work may be sufficient.

Hmm, so currently we have ```markdown [eglot-hierarchy.el](raw/branch/main/some/path/eglot-hierarchy.el) ``` Then we would have ```markdown [eglot-hierarchy.el](some/path/eglot-hierarchy.el?display=raw) ``` where `some/path` is the normal file system path inside the git repo. Yet, what about links to specific commits then? Consider me clicking on a specific link in the repository. In the URL bar (of reasonable browsers 😄) I see: ``` https://codeberg.org/harald/monqjfa/src/commit/38ac67b48612c13bcf27042f4182ac3e19a3c700/src/buma/Buma.java ``` From this link I can naively deduce a path relative to `README.md` as `src/commit/38ac67b48612c13bcf27042f4182ac3e19a3c700/src/buma/Buma.java`. So in addition to `display=raw` we might need `commit=...` and what not. In addition, creating the relative URL does not require me to dig through the documentation to figure out if and that those parameters exist. Insofar the main point of my request is not a feature request but rather to remove a what seems like a misfeature --- the change of totally nice relative URL. I am somewhat undecided whether extra parameters are worth the effort, as I can always just use the full absolute URL starting with `/myuser/myrepo`. Adding to the documentation a warning that relative URLs won't work may be sufficient.
Sign in to join this conversation.
No Branch/Tag specified
main
git-pages
pr-554
pr/554
gitea-icons-shortcode
No results found.
Labels
Clear labels
Codeberg Pages

Issues affecting Codeberg Pages
Documentation Usability

Issues related to using and reading docs.codeberg.org
Forgejo
Good First Issue! 👋
Kind: Bug
Kind: Documentation
Kind: Enhancement
Kind: Feature
Kind: Question
Kind: Security
Licensing
Part: Generator

This is related to the generation of the documentation, not to the content itself
Priority: High

The priority is high
Priority: Low

The priority is low
Priority: Medium

The priority is medium
Reviewed: Confirmed

Something has been confirmed
Reviewed: Duplicate

Something exists already
Reviewed: Invalid

Something was marked as invalid
Reviewed: Wontfix

Something won't be fixed
Status: Blocked
Status: Help wanted

Contributions are welcome!
Status: In progress

Work is in progress
Status: Needs feedback

Feedback is needed
Status: Ready for Review

Work is completed
Status: Review

Review is in progress / Reviewers wanted
Status: Stale
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Documentation#499
Reference in a new issue
Codeberg/Documentation
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?