Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Resolve a README's relative links against the file, not the page

796ccd9051ef49f10655088ec39b8dfb844f4124 · Keenan Nemetz · 13d ago · parent 53ff967b

Resolve a README's relative links against the file, not the page

A relative link was resolved by the browser against the URL the README happened
to be rendered at, so `docs/getting-started.md` reached
`/r/<repo>/docs/getting-started.md` from the overview page and 404'd, and the
same link broke differently from the code browser.

A document that lives in the tree now carries its own path, and its links and
images are rewritten after parsing and before rendering: markdown opens the
preview, other files open the source, images point at the raw route, a
directory opens the tree, and `.`/`..` resolve the way a reader expects with
climbing clamped at the repository root. A destination that already names
somewhere — a scheme, `//host`, a site-absolute path, a bare `#anchor` or
`?query` — is left alone, and so is any document with no place in a tree, such
as an issue body or a comment.

The rewrite works on the parsed tree rather than on the markdown text, so
reference-style links are covered too, and the source view still shows the
file's bytes unchanged.

Refs #01M5XF52R132A88C6WEQ6H6BK6

docs/ui-plan.md +4−1

@@ -90,6 +90,9 @@ Status: `done` exists today · `wip` in progress · `todo` missing.
90 90
91 91 - done — code browser: persistent file tree, HTMX file/folder swaps, blob with
92 92 line numbers, raw, markdown source with an explicit full-width preview
93 - done — a README's relative links and images resolve against the document's own
94 directory and open on the code surface, so the same README works from the
95 overview and from the code browser
93 96 - done — commit history, commit view, parent links, diff
94 97 - done — issues list/detail, comments, filters, close/reopen, labels and assignees (create and edit)
95 98 - done — change-request list/detail with Conversation, Files and Runs tabs; one-level threaded discussion UI, approvals, file tree and diff, inline review comments, close/reopen
@@ -226,7 +229,7 @@ answers rather than by layer:
226 229 | `page.go` | `Page`, `pageSection`, `who`, `nav` — the data every page and fragment starts from |
227 230 | `templatefuncs.go` | the template function map, with a note on escaping (`esc` vs `pathurl`) |
228 231 | `ui.go` | relative time, avatar initials and tone, breadcrumbs, `safePath`, the `pager` |
229 | `markdown.go` | the goldmark + bluemonday boundary and `#<ulid>` cross-references |
232 | `markdown.go` | the goldmark + bluemonday boundary, `#<ulid>` cross-references, and resolving a tree document's relative links against its own directory |
230 233 | `auth.go`, `auth_handlers.go` | passkeys, sessions, CSRF, the middleware, the sign-in pages |
231 234 | `templates.go`, `icons.go`, `file_icons.go` | embedding, the icon set, language classes |
232 235 | `templates/` | one file per destination; `chrome.html`, `components.html`, `diff.html` and `role-picker.html` hold what two surfaces share |