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

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