diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-03-14 15:45:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-14 07:45:11 +0000 |
commit | b094f9b75d000aa9a78194b2c14e04318d498ff2 (patch) | |
tree | 9425e708cb4c503f1cad8715f495169a68983dde /templates | |
parent | 9c673d066c2018e70e3eb0532af630fff2fc5b7a (diff) | |
download | gitea-b094f9b75d000aa9a78194b2c14e04318d498ff2.tar.gz gitea-b094f9b75d000aa9a78194b2c14e04318d498ff2.zip |
Improve repo commit view (#33877)
Fix #24623
Major changes:
1. Redirect `/owner/repo/blob/*` requests to `/owner/repo/src/commit/*`
(like GitHub)
2. Add a "view file diff" link (see screenshot below)
3. Refactor "AssertHTMLElement" to generic, now we can accurately assert
existence or number.
4. Add more tests
---------
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/repo/commits_list.tmpl | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index c8405ca748..dc800d9911 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -66,11 +66,20 @@ <td class="text right aligned">{{DateUtils.TimeSince .Author.When}}</td> {{end}} <td class="text right aligned tw-py-0"> - <button class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button> - {{if not $.PageIsWiki}}{{/* at the moment, wiki doesn't support "view at history point*/}} + <button class="btn interact-bg tw-p-2 copy-commit-id" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button> + {{/* at the moment, wiki doesn't support these "view" links like "view at history point" */}} + {{if not $.PageIsWiki}} + {{/* view single file diff */}} + {{if $.FileName}} + <a class="btn interact-bg tw-p-2 view-single-diff" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_file_diff"}}" + href="{{$commitRepoLink}}/commit/{{.ID.String}}?files={{$.FileName}}" + >{{svg "octicon-file-diff"}}</a> + {{end}} + + {{/* view at history point */}} {{$viewCommitLink := printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}} {{if $.FileName}}{{$viewCommitLink = printf "%s/%s" $viewCommitLink (PathEscapeSegments $.FileName)}}{{end}} - <a class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}" href="{{$viewCommitLink}}">{{svg "octicon-file-code"}}</a> + <a class="btn interact-bg tw-p-2 view-commit-path" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}" href="{{$viewCommitLink}}">{{svg "octicon-file-code"}}</a> {{end}} </td> </tr> |