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

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