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 4.4KB

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