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.2KB

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