view_file.tmpl 4.8 KiB

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