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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 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" data-tooltip="{{.LFSLockHint}}" data-inverted="">
  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 df ac">
  35. <div class="ui right file-actions">
  36. <div class="ui buttons">
  37. <a class="ui button" href="{{EscapePound $.RawFileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
  38. {{if not .IsViewCommit}}
  39. <a class="ui button" href="{{.RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_permalink"}}</a>
  40. {{end}}
  41. {{if .IsTextFile}}
  42. <a class="ui button" href="{{.RepoLink}}/blame/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.blame"}}</a>
  43. {{end}}
  44. <a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a>
  45. </div>
  46. {{if .Repository.CanEnableEditor}}
  47. {{if .CanEditFile}}
  48. <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>
  49. {{else}}
  50. <span class="btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span>
  51. {{end}}
  52. {{if .CanDeleteFile}}
  53. <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>
  54. {{else}}
  55. <span class="btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-trashcan" 16}}</span>
  56. {{end}}
  57. {{end}}
  58. </div>
  59. </div>
  60. {{end}}
  61. </h4>
  62. <div class="ui attached table unstackable segment">
  63. <div class="file-view {{if .IsMarkup}}{{.MarkupType}} markdown{{else if .IsRenderedHTML}}plain-text{{else if .IsTextFile}}code-view{{end}}">
  64. {{if .IsMarkup}}
  65. {{if .FileContent}}{{.FileContent | Safe}}{{end}}
  66. {{else if .IsRenderedHTML}}
  67. <pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
  68. {{else if not .IsTextFile}}
  69. <div class="view-raw ui center">
  70. {{if .IsImageFile}}
  71. <img src="{{EscapePound $.RawFileLink}}">
  72. {{else if .IsVideoFile}}
  73. <video controls src="{{EscapePound $.RawFileLink}}">
  74. <strong>{{.i18n.Tr "repo.video_not_supported_in_browser"}}</strong>
  75. </video>
  76. {{else if .IsAudioFile}}
  77. <audio controls src="{{EscapePound $.RawFileLink}}">
  78. <strong>{{.i18n.Tr "repo.audio_not_supported_in_browser"}}</strong>
  79. </audio>
  80. {{else if .IsPDFFile}}
  81. <iframe width="100%" height="600px" src="{{StaticUrlPrefix}}/vendor/plugins/pdfjs/web/viewer.html?file={{EscapePound $.RawFileLink}}"></iframe>
  82. {{else}}
  83. <a href="{{EscapePound $.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
  84. {{end}}
  85. </div>
  86. {{else if .FileSize}}
  87. {{if .IsFileTooLarge}}
  88. <table>
  89. <tbody>
  90. <tr>
  91. <td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
  92. </tr>
  93. </tbody>
  94. </table>
  95. {{else}}
  96. <table>
  97. <tbody>
  98. {{range $line, $code := .FileContent}}
  99. <tr>
  100. <td id="L{{$line}}" class="lines-num">
  101. <span id="L{{$line}}" data-line-number="{{$line}}"></span>
  102. </td>
  103. <td rel="L{{$line}}" class="lines-code chroma">
  104. <code>{{$code | Safe}}</code>
  105. </td>
  106. </tr>
  107. {{end}}
  108. </tbody>
  109. </table>
  110. {{end}}
  111. {{end}}
  112. </div>
  113. </div>
  114. </div>
  115. <script>
  116. function submitDeleteForm() {
  117. var message = prompt("{{.i18n.Tr "repo.delete_confirm_message"}}\n\n{{.i18n.Tr "repo.delete_commit_summary"}}", "Delete '{{.TreeName}}'");
  118. if (message != null) {
  119. $("#delete-message").val(message);
  120. $("#delete-file-form").submit()
  121. }
  122. }
  123. </script>