You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

view_file.tmpl 5.0KB

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