my-gitea-templates/templates/repo/ view_file.tmpl
119 lines
5.5 KiB

  1. <div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
  2. <h4 class="file-header ui top attached header">
  3. <div class="file-header-left">
  4. {{if .ReadmeInList}}
  5. {{if .FileIsSymlink}}
  6. <i class="icons"><i class="book icon"></i><i class="bottom left corner tiny inverted share icon"></i></i>
  7. {{else}}
  8. <i class="book icon"></i>
  9. {{end}}
  10. <strong>{{.FileName}}</strong>
  11. {{else}}
  12. {{ $l := Subtract (len .TreeNames) 1}}
  13. <span class="ui breadcrumb repo-path"><a class="section" href="{{.RepoLink}}/src/{{EscapePound .BranchNameSubURL}}">{{EllipsisString .Repository.Name 30}}</a>{{range $i, $v := .TreeNames}}<span class="divider">/</span>{{if ne $i $l}}{{ $p := index $.Paths $i}}<span class="section"><a href="{{EscapePound $.BranchLink}}/{{EscapePound $p}}">{{EllipsisString $v 30}}</a></span>{{end}}{{end}} <strong>{{.FileName}}</strong></span>
  14. <div class="file-info text grey normal mono">
  15. {{if .FileIsSymlink}}
  16. <div class="file-info-entry">
  17. {{.i18n.Tr "repo.symbolic_link"}}
  18. </div>
  19. {{end}}
  20. {{if .NumLinesSet}}
  21. <div class="file-info-entry">
  22. {{.NumLines}} {{.i18n.Tr (TrN .i18n.Lang .NumLines "repo.line" "repo.lines") }}
  23. </div>
  24. {{end}}
  25. {{if .FileSize}}
  26. <div class="file-info-entry">
  27. {{FileSize .FileSize}}{{if .IsLFSFile}} ({{.i18n.Tr "repo.stored_lfs"}}){{end}}
  28. </div>
  29. {{end}}
  30. {{if .LFSLock}}
  31. <div class="file-info-entry">
  32. <i class="fa fa-lock poping up disabled" data-content="{{.LFSLockHint}}" data-position="bottom center" data-variation="tiny inverted"></i>
  33. <a href="{{AppSubUrl}}/{{.LFSLock.Owner.Name}}">{{.LFSLockOwner}}</a>
  34. </div>
  35. {{end}}
  36. </div>
  37. {{end}}
  38. </div>
  39. {{if not .ReadmeInList}}
  40. <div class="file-header-right">
  41. <div class="ui right file-actions">
  42. <div class="ui buttons">
  43. <a class="ui button" href="{{EscapePound $.RawFileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
  44. {{if not .IsViewCommit}}
  45. <a class="ui button" href="{{.RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_permalink"}}</a>
  46. {{end}}
  47. {{if .IsTextFile}}
  48. <a class="ui button" href="{{.RepoLink}}/blame/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.blame"}}</a>
  49. {{end}}
  50. <a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a>
  51. </div>
  52. {{if .Repository.CanEnableEditor}}
  53. {{if .CanEditFile}}
  54. <a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><span class="btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span></a>
  55. {{else}}
  56. <span class="btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span>
  57. {{end}}
  58. {{if .CanDeleteFile}}
  59. <a href="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><span class="btn-octicon btn-octicon-danger poping up" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-trashcan" 16}}</span></a>
  60. {{else}}
  61. <span class="btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-trashcan" 16}}</span>
  62. {{end}}
  63. {{end}}
  64. </div>
  65. </div>
  66. {{end}}
  67. </h4>
  68. <div class="ui attached table unstackable segment">
  69. <div class="file-view {{if .IsMarkup}}{{.MarkupType}} markdown{{else if .IsRenderedHTML}}plain-text{{else if .IsTextFile}}code-view{{end}} has-emoji">
  70. {{if .IsMarkup}}
  71. {{if .FileContent}}{{.FileContent | Safe}}{{end}}
  72. {{else if .IsRenderedHTML}}
  73. <pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
  74. {{else if not .IsTextFile}}
  75. <div class="view-raw ui center">
  76. {{if .IsImageFile}}
  77. <img src="{{EscapePound $.RawFileLink}}">
  78. {{else if .IsVideoFile}}
  79. <video controls src="{{EscapePound $.RawFileLink}}">
  80. <strong>{{.i18n.Tr "repo.video_not_supported_in_browser"}}</strong>
  81. </video>
  82. {{else if .IsAudioFile}}
  83. <audio controls src="{{EscapePound $.RawFileLink}}">
  84. <strong>{{.i18n.Tr "repo.audio_not_supported_in_browser"}}</strong>
  85. </audio>
  86. {{else if .IsPDFFile}}
  87. <iframe width="100%" height="600px" src="{{StaticUrlPrefix}}/vendor/plugins/pdfjs/web/viewer.html?file={{EscapePound $.RawFileLink}}"></iframe>
  88. {{else}}
  89. <a href="{{EscapePound $.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
  90. {{end}}
  91. </div>
  92. {{else if .FileSize}}
  93. <table>
  94. <tbody>
  95. <tr>
  96. {{if .IsFileTooLarge}}
  97. <td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
  98. {{else}}
  99. <td class="lines-num">{{.LineNums}}</td>
  100. <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
  101. {{end}}
  102. </tr>
  103. </tbody>
  104. </table>
  105. {{end}}
  106. </div>
  107. </div>
  108. </div>
  109. <script>
  110. function submitDeleteForm() {
  111. var message = prompt("{{.i18n.Tr "repo.delete_confirm_message"}}\n\n{{.i18n.Tr "repo.delete_commit_summary"}}", "Delete '{{.TreeName}}'");
  112. if (message != null) {
  113. $("#delete-message").val(message);
  114. $("#delete-file-form").submit()
  115. }
  116. }
  117. </script>