diff options
author | Norwin <noerw@users.noreply.github.com> | 2021-06-28 01:13:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-28 01:13:20 +0200 |
commit | 9c6aeb47f7979a434bf30408992c06118c142771 (patch) | |
tree | 0aed39da360583610dee02a2d96a7a43b022d45d /templates | |
parent | 59c58553baa5597f5c2156b47fd2e47e46aa58ac (diff) | |
download | gitea-9c6aeb47f7979a434bf30408992c06118c142771.tar.gz gitea-9c6aeb47f7979a434bf30408992c06118c142771.zip |
Link to previous blames in file blame page (#16259)
Adds a link to each blame hunk, to view the blame of an earlier version of the file, similar to GitHub. Also refactors the blame render from fmtstring based to template based.
* Fix blame bottom line and add blame prior button
* Jump to previous parent commit from the commit.
* Fix previous commit link
* Fix previous blame link
* Fix the given file not exist in the previous commit.
* Fix blameRow struct not export
* fix theming issues, rename template var
* remove unused LastCommit fetch
* fix location of blame-hunk divider
* rewrite previous commit checks
* remove duplicate commit lookup
its already resolved and stored in ctx.Repo.Commit!
* split out blamePart processing into function
Co-authored-by: rogerluo410 <rogerluo410@gmail.com>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/repo/blame.tmpl | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/templates/repo/blame.tmpl b/templates/repo/blame.tmpl index 638683b25e..c7c497088a 100644 --- a/templates/repo/blame.tmpl +++ b/templates/repo/blame.tmpl @@ -23,11 +23,40 @@ <div class="file-view code-view"> <table> <tbody> - <tr> - <td class="lines-commit">{{.BlameCommitInfo}}</td> - <td class="lines-num">{{.BlameLineNums}}</td> - <td class="lines-code"><code class="chroma"><ol class="linenums">{{.BlameContent}}</ol></code></td> - </tr> + {{range $row := .BlameRows}} + <tr class="{{if and (gt $.CommitCnt 1) ($row.CommitMessage)}}top-line-blame{{end}}"> + <td class="lines-commit"> + <div class="blame-info"> + <div class="blame-data"> + <div class="blame-avatar"> + {{$row.Avatar}} + </div> + <div class="blame-message"> + <a href="{{$row.CommitURL}}" title="{{$row.CommitMessage}}"> + {{$row.CommitMessage}} + </a> + </div> + <div class="blame-time"> + {{$row.CommitSince}} + </div> + </div> + </div> + </td> + <td class="lines-blame-btn"> + {{if $row.PreviousSha}} + <a href="{{$row.PreviousShaURL}}" class="poping up" data-content='{{$.i18n.Tr "repo.blame_prior"}}' data-variation="tiny inverted"> + {{svg "octicon-versions"}} + </a> + {{end}} + </td> + <td class="lines-num"> + <span id="L{{$row.RowNumber}}" data-line-number="{{$row.RowNumber}}"></span> + </td> + <td rel="L{{$row.RowNumber}}" rel="L{{$row.RowNumber}}" class="lines-code blame-code chroma"> + <code class="code-inner pl-3">{{$row.Code}}</code> + </td> + </tr> + {{end}} </tbody> </table> </div> |