mirror of
1
Fork 0
forgejo/modules
forgejo-backport-action 0ecf28f37f [v10.0/forgejo] Fix inline file preview for rendered files (#6685)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/6572

### What?

This fixes the inline file preview for rendered files (e.g., markdown). [Here, a live issue in v11](https://v11.next.forgejo.org/mahlzahn/test-inline-file-preview/issues/1) and [the same in v7 (with even more bugs)](https://v7.next.forgejo.org/mahlzahn/test-inline-file-preview/issues/1).

It fixes
1. the inline preview for possibly rendered files, when the link is specified with `?display=source`. This happens, e.g., if you are watching a (e.g., markdown) file in source and then want to link some of its lines.
2. the link to the source file inside the inline preview for possible rendered files (currently it links to the rendered version and then the `#L…` cannot point to the correct lines). This is done by always adding `?display=source` to the link.

### Screenshots
<details><summary>

#### Before

</summary>

![image](/attachments/898f82d5-d116-465a-89e2-ed83da189762)

</details>
<details><summary>

#### After

</summary>

![image](/attachments/41058620-47f3-4f6a-b427-66ef33c1a07f)

</details>

### Tests

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

I think that this minor edit does not need special tests. Some backend tests have been updated to reflect the addition of URL parameters.

#### Manual testing
- create a repository with a file that can be rendered with couple of lines inside, e.g., a markdown README.md
- go to the source of this file (e.g., `…/src/branch/main/README.md`)
- click on the `<> View Source` button (or add `?display=source` to the URL)
- click on one of the lines, then on the three dots, then on ”Reference in a new issue“
- continue creating the issue

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [ ] I do not want this change to show in the release notes.
- [ ] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6685
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2025-01-25 11:38:02 +00:00
..
actions Fix wrong status of `Set up Job` when first step is skipped (#32120) 2024-09-29 10:38:49 +02:00
activitypub test: fix test linting 2024-11-11 12:44:36 +01:00
analyze
assetfs
auth chore: avoid using gock 2024-12-18 06:40:02 +01:00
avatar
base fix: extend `forgejo_auth_token` table 2024-11-15 10:59:36 +01:00
cache Increase `cacheContextLifetime` to reduce false reports (#32011) 2024-09-14 17:09:03 +02:00
card [v10.0/forgejo] feat: Add summary card for repos and releases 2025-01-01 22:00:26 +01:00
charset refactor: remove redundant err declarations (#32381) 2024-11-05 09:33:15 +01:00
container
csv
emoji
eventsource fix: use better code to group UID and stopwatches 2024-11-16 15:59:02 +01:00
forgefed
generate
git feat: filepath filter for code search (#6143) 2024-12-22 12:24:29 +00:00
gitgraph fix: Proper paring of date for git commits 2024-11-10 22:23:28 +01:00
gitrepo
graceful chore: remove some Windows-specific files 2024-09-19 20:39:55 +05:00
hcaptcha
highlight feat: highlight Gradle Kotlin as Kotlin 2024-12-04 22:06:33 +01:00
hostmatcher Support allowed hosts for migrations to work with proxy (#32025) 2024-09-14 17:52:54 +02:00
html
httpcache Fix wrong last modify time (#32102) 2024-09-27 08:42:48 +02:00
httplib Fix wrong last modify time (#32102) 2024-09-27 08:42:48 +02:00
indexer feat: filepath filter for code search (#6143) 2024-12-22 12:24:29 +00:00
issue/template [CHORE] Use forked `binding` library 2024-11-05 22:47:34 +01:00
json
keying feat: harden keying implementation 2024-12-25 00:10:18 +01:00
label
lfs Add User-Agent for gitea's self-implemented lfs client. (branding) 2024-12-17 06:18:24 +01:00
log chore: Make Forgejo build with go1.24 2024-12-17 16:12:22 +01:00
markup [v10.0/forgejo] Fix inline file preview for rendered files (#6685) 2025-01-25 11:38:02 +00:00
mcaptcha
metrics
migration Support migrating GitHub/GitLab PR draft status (#32242) 2024-10-20 09:24:25 +02:00
nosql [FEAT] Only implement used API of Redis client 2024-08-30 04:33:15 +02:00
optional
options
packages fix: maven fallback to parent groupId 2024-12-21 11:48:09 +01:00
paginator
pprof
private
process chore: remove some Windows-specific files 2024-09-19 20:39:55 +05:00
proxy
proxyprotocol
public
queue chore: update mock redis client 2024-09-01 05:42:34 +02:00
recaptcha
references fix trailing comma not matched in the case of alphanumeric issue (#32945) 2024-12-30 08:26:54 +00:00
regexplru
repository feat: allow changing default branch update style 2024-12-23 18:55:25 +03:00
secret [v10.0/forgejo] fix: teach the doctor about orphaned two_factor rows (#6651) 2025-01-22 07:47:34 +00:00
session [FEAT] Only implement used API of Redis client 2024-08-30 04:33:15 +02:00
setting [v10.0/forgejo] fix: load settings for valid user and email check (#6678) 2025-01-24 12:25:00 +00:00
sitemap
ssh fix: ensure correct ssh public key is used for authentication 2024-12-12 05:54:07 +01:00
storage Add artifacts test fixture (#30300) 2024-11-05 09:33:15 +01:00
structs feat: allow changing default branch update style 2024-12-23 18:55:25 +03:00
svg
sync
system
templates chore(branding): strip metadata information from the footer 2024-12-30 15:30:02 +00:00
test
testlogger test: add trailing newline to `testlogger.go:recordError` message 2024-11-14 14:38:47 +01:00
timeutil [PORT] Refactor DateUtils and merge TimeSince (gitea#32409) 2024-11-10 22:23:27 +01:00
translation i18n: Add dummy language for checking translation keys (#5785) 2024-11-05 09:59:04 +00:00
turnstile
typesniffer Update modules/typesniffer/typesniffer.go 2024-11-28 10:27:33 +00:00
updatechecker
uri
user
util Validate OAuth Redirect URIs (#32643) 2024-12-03 10:19:22 +01:00
validation Validate OAuth Redirect URIs (#32643) 2024-12-03 10:19:22 +01:00
web [CHORE] Use forked `binding` library 2024-11-05 22:47:34 +01:00
webhook
zstd Cache generated binary across jobs 2024-08-26 23:43:09 +02:00