diff.tmpl 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {{template "base/head" .}}
  2. <div class="repository diff">
  3. {{template "repo/header" .}}
  4. <div class="ui container">
  5. {{if .IsDiffCompare }}
  6. {{template "repo/commits_table" .}}
  7. {{else}}
  8. <h4 class="ui top attached info header">
  9. {{RenderCommitMessage .Commit.Message $.RepoLink}}
  10. <div class="ui right">
  11. <a class="ui blue tiny button" href="{{EscapePound .SourcePath}}">
  12. {{.i18n.Tr "repo.diff.browse_source"}}
  13. </a>
  14. </div>
  15. </h4>
  16. <div class="ui attached info segment">
  17. {{if .Author}}
  18. <img class="ui avatar image" src="{{.Author.AvatarLink}}" />
  19. <a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a>
  20. {{else}}
  21. <img class="ui avatar image" src="{{AvatarLink .Commit.Author.Email}}" />
  22. <strong>{{.Commit.Author.Name}}</strong>
  23. {{end}}
  24. <span class="text grey" id="authored-time">{{TimeSince .Commit.Author.When $.Lang}}</span>
  25. <div class="ui right">
  26. <div class="ui horizontal list">
  27. <div class="item">
  28. {{.i18n.Tr "repo.diff.parent"}}
  29. </div>
  30. <div class="item">
  31. {{range .Parents}}
  32. <a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSha .}}</a>
  33. {{end}}
  34. </div>
  35. <div class="item">{{.i18n.Tr "repo.diff.commit"}}</div>
  36. <div class="item"><span class="ui blue sha label">{{ShortSha .CommitId}}</span></div>
  37. </div>
  38. </div>
  39. </div>
  40. {{end}}
  41. {{if .DiffNotAvailable}}
  42. <h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
  43. {{else}}
  44. <div class="diff-detail-box diff-box">
  45. <div>
  46. <i class="fa fa-retweet"></i>
  47. {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
  48. <div class="ui right">
  49. <a class="ui tiny basic black toggle button" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
  50. </div>
  51. </div>
  52. <ol class="detail-files hide" id="diff-files">
  53. {{range .Diff.Files}}
  54. <li>
  55. <div class="diff-counter count pull-right">
  56. {{if not .IsBin}}
  57. <span class="add" data-line="{{.Addition}}">{{.Addition}}</span>
  58. <span class="bar">
  59. <span class="pull-left add"></span>
  60. <span class="pull-left del"></span>
  61. </span>
  62. <span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
  63. {{else}}
  64. <span>{{$.i18n.Tr "repo.diff.bin"}}</span>
  65. {{end}}
  66. </div>
  67. <!-- todo finish all file status, now modify, add, delete and rename -->
  68. <span class="status {{DiffTypeToStr .Type}} poping up" data-content="{{DiffTypeToStr .Type}}" data-variation="inverted tiny" data-position="right center">&nbsp;</span>
  69. <a class="file" href="#diff-{{.Index}}">{{.Name}}</a>
  70. </li>
  71. {{end}}
  72. </ol>
  73. </div>
  74. {{range $i, $file := .Diff.Files}}
  75. <div class="diff-file-box diff-box file-content" id="diff-{{.Index}}">
  76. <h4 class="ui top attached normal header">
  77. <div class="diff-counter count ui left">
  78. {{if not $file.IsBin}}
  79. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  80. <span class="bar">
  81. <span class="pull-left add"></span>
  82. <span class="pull-left del"></span>
  83. </span>
  84. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  85. {{else}}
  86. {{$.i18n.Tr "repo.diff.bin"}}
  87. {{end}}
  88. </div>
  89. <span class="file">{{$file.Name}}</span>
  90. <div class="ui right">
  91. {{if $file.IsDeleted}}
  92. <a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  93. {{else}}
  94. <a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  95. {{end}}
  96. </div>
  97. </h4>
  98. <div class="ui attached table segment">
  99. {{$isImage := (call $.IsImageFile $file.Name)}}
  100. {{if $isImage}}
  101. <div class="center">
  102. <img src="{{$.RawPath}}/{{EscapePound .Name}}">
  103. </div>
  104. {{else}}
  105. <div class="file-body file-code code-view code-diff">
  106. <table>
  107. <tbody>
  108. {{range .Sections}}
  109. {{range $k, $line := .Lines}}
  110. <tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
  111. <td class="lines-num lines-num-old">
  112. <span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
  113. </td>
  114. <td class="lines-num lines-num-new">
  115. <span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
  116. </td>
  117. <td class="lines-code">
  118. <pre>{{$line.Content}}</pre>
  119. </td>
  120. </tr>
  121. {{end}}
  122. {{end}}
  123. </tbody>
  124. </table>
  125. </div>
  126. {{end}}
  127. </div>
  128. </div>
  129. <br>
  130. {{end}}
  131. {{end}}
  132. </div>
  133. </div>
  134. {{template "base/footer" .}}