diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-04 19:05:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 19:05:07 +0800 |
commit | d149093ce3c32503b95c66208de6cb5861e4e666 (patch) | |
tree | c6b1fb9802df5c23c9a77f6c15a8f0bb58ad6376 /templates/repo | |
parent | d93f3222a5eb88fbc0f192c3bf3a0ebfd7ccc6c9 (diff) | |
download | gitea-d149093ce3c32503b95c66208de6cb5861e4e666.tar.gz gitea-d149093ce3c32503b95c66208de6cb5861e4e666.zip |
Fix code view (diff) broken layout (#23096)
Close #22911
I think it's ready for review now, feel free to test it, welcome to help
to improve.
### Before
![image](https://user-images.githubusercontent.com/2114189/220958734-06871615-b498-4143-8449-3d443f08ffaa.png)
### After
![image](https://user-images.githubusercontent.com/2114189/220958621-0dce2728-57b8-4a1f-ac5d-48c7c2d42f5c.png)
Diffstat (limited to 'templates/repo')
-rw-r--r-- | templates/repo/diff/blob_excerpt.tmpl | 6 | ||||
-rw-r--r-- | templates/repo/diff/section_split.tmpl | 30 | ||||
-rw-r--r-- | templates/repo/diff/section_unified.tmpl | 8 | ||||
-rw-r--r-- | templates/repo/settings/lfs_file.tmpl | 2 |
4 files changed, 25 insertions, 21 deletions
diff --git a/templates/repo/diff/blob_excerpt.tmpl b/templates/repo/diff/blob_excerpt.tmpl index f4f7732c50..caa428dc28 100644 --- a/templates/repo/diff/blob_excerpt.tmpl +++ b/templates/repo/diff/blob_excerpt.tmpl @@ -19,14 +19,14 @@ </a> {{end}} </td> - <td colspan="5" class="lines-code lines-code-old ">{{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}}{{/* + <td colspan="7" class="lines-code lines-code-old ">{{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}}{{/* */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}</td> {{else}} {{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}} <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$.FileNameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> <td class="blob-excerpt lines-escape lines-escape-old">{{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></a>{{end}}</td> <td class="blob-excerpt lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="gt-mono" data-type-marker=""></span>{{end}}</td> - <td class="blob-excerpt lines-code lines-code-old halfwidth">{{/* + <td class="blob-excerpt lines-code lines-code-old">{{/* */}}{{if $line.LeftIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}{{else}}{{/* */}}<code class="code-inner"></code>{{/* */}}{{end}}{{/* @@ -34,7 +34,7 @@ <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$.FileNameHash}}R{{$line.RightIdx}}{{end}}"></span></td> <td class="blob-excerpt lines-escape lines-escape-new">{{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></a>{{end}}</td> <td class="blob-excerpt lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="gt-mono" data-type-marker=""></span>{{end}}</td> - <td class="blob-excerpt lines-code lines-code-new halfwidth">{{/* + <td class="blob-excerpt lines-code lines-code-new">{{/* */}}{{if $line.RightIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}{{else}}{{/* */}}<code class="code-inner"></code>{{/* */}}{{end}}{{/* diff --git a/templates/repo/diff/section_split.tmpl b/templates/repo/diff/section_split.tmpl index c4b5ad042c..4fa81f4e62 100644 --- a/templates/repo/diff/section_split.tmpl +++ b/templates/repo/diff/section_split.tmpl @@ -1,4 +1,14 @@ {{$file := .file}} +<colgroup> + <col width="50"> + <col width="10"> + <col width="10"> + <col> + <col width="50"> + <col width="10"> + <col width="10"> + <col> +</colgroup> {{range $j, $section := $file.Sections}} {{range $k, $line := $section.Lines}} {{$hasmatch := ne $line.Match -1}} @@ -33,7 +43,7 @@ <td class="lines-num lines-num-old del-code" data-line-num="{{$line.LeftIdx}}"><span rel="diff-{{$file.NameHash}}L{{$line.LeftIdx}}"></span></td> <td class="lines-escape del-code lines-escape-old">{{if $line.LeftIdx}}{{if $leftDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $leftDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> <td class="lines-type-marker lines-type-marker-old del-code"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> - <td class="lines-code lines-code-old halfwidth del-code">{{/* + <td class="lines-code lines-code-old del-code">{{/* */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* */}}<a class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/* */}}{{svg "octicon-plus"}}{{/* @@ -48,7 +58,7 @@ <td class="lines-num lines-num-new add-code" data-line-num="{{if $match.RightIdx}}{{$match.RightIdx}}{{end}}"><span rel="{{if $match.RightIdx}}diff-{{$file.NameHash}}R{{$match.RightIdx}}{{end}}"></span></td> <td class="lines-escape add-code lines-escape-new">{{if $match.RightIdx}}{{if $rightDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $rightDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> <td class="lines-type-marker lines-type-marker-new add-code">{{if $match.RightIdx}}<span class="gt-mono" data-type-marker="{{$match.GetLineTypeMarker}}"></span>{{end}}</td> - <td class="lines-code lines-code-new halfwidth add-code">{{/* + <td class="lines-code lines-code-new add-code">{{/* */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* */}}<a class="ui primary button add-code-comment add-code-comment-right{{if (not $match.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$match.RightIdx}}">{{/* */}}{{svg "octicon-plus"}}{{/* @@ -65,7 +75,7 @@ <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$file.NameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> <td class="lines-escape lines-escape-old">{{if $line.LeftIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> <td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td> - <td class="lines-code lines-code-old halfwidth">{{/* + <td class="lines-code lines-code-old">{{/* */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 2))}}{{/* */}}<a class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/* */}}{{svg "octicon-plus"}}{{/* @@ -80,7 +90,7 @@ <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td> <td class="lines-escape lines-escape-new">{{if $line.RightIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> <td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td> - <td class="lines-code lines-code-new halfwidth">{{/* + <td class="lines-code lines-code-new">{{/* */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 3))}}{{/* */}}<a class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">{{/* */}}{{svg "octicon-plus"}}{{/* @@ -98,9 +108,6 @@ {{$match := index $section.Lines $line.Match}} {{if or (gt (len $line.Comments) 0) (gt (len $match.Comments) 0)}} <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}"> - <td class="lines-num"></td> - <td class="lines-escape"></td> - <td class="lines-type-marker"></td> <td class="add-comment-left" colspan="4"> {{if gt (len $line.Comments) 0}} {{if eq $line.GetCommentSide "previous"}} @@ -113,9 +120,6 @@ {{end}} {{end}} </td> - <td class="lines-num"></td> - <td class="lines-escape"></td> - <td class="lines-type-marker"></td> <td class="add-comment-right" colspan="4"> {{if eq $line.GetCommentSide "proposed"}} {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} @@ -130,9 +134,6 @@ {{end}} {{else if gt (len $line.Comments) 0}} <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}"> - <td class="lines-num"></td> - <td class="lines-escape"></td> - <td class="lines-type-marker"></td> <td class="add-comment-left" colspan="4"> {{if gt (len $line.Comments) 0}} {{if eq $line.GetCommentSide "previous"}} @@ -140,9 +141,6 @@ {{end}} {{end}} </td> - <td class="lines-num"></td> - <td class="lines-escape"></td> - <td class="lines-type-marker"></td> <td class="add-comment-right" colspan="4"> {{if eq $line.GetCommentSide "proposed"}} {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index e0ec85f9a6..ba4ad5b513 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -1,4 +1,11 @@ {{$file := .file}} +<colgroup> + <col width="50"> + <col width="50"> + <col width="10"> + <col width="10"> + <col> +</colgroup> {{range $j, $section := $file.Sections}} {{range $k, $line := $section.Lines}} <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{DiffLineTypeToStr .GetType}}"> @@ -49,7 +56,6 @@ </tr> {{if gt (len $line.Comments) 0}} <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}"> - <td colspan="3" class="lines-num"></td> <td class="add-comment-left add-comment-right" colspan="5"> {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}} </td> diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl index 7a1e3e9421..2ad3458501 100644 --- a/templates/repo/settings/lfs_file.tmpl +++ b/templates/repo/settings/lfs_file.tmpl @@ -48,7 +48,7 @@ <td><strong>{{.locale.Tr "repo.file_too_large"}}</strong></td> {{else}} <td class="lines-num">{{.LineNums}}</td> - <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td> + <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol>{{.FileContent}}</ol></code></pre></td> {{end}} </tr> </tbody> |