view_file.tmpl 4.6 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 .IsPDFFile}}
  61. <iframe width="100%" height="600px" src="{{AppSubUrl}}/vendor/plugins/pdfjs/web/viewer.html?file={{EscapePound $.RawFileLink}}"></iframe>
  62. {{else}}
  63. <a href="{{EscapePound $.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
  64. {{end}}
  65. </div>
  66. {{else if .FileSize}}
  67. <table>
  68. <tbody>
  69. <tr>
  70. {{if .IsFileTooLarge}}
  71. <td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
  72. {{else}}
  73. <td class="lines-num">{{.LineNums}}</td>
  74. <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
  75. {{end}}
  76. </tr>
  77. </tbody>
  78. </table>
  79. {{end}}
  80. </div>
  81. </div>
  82. </div>
  83. <script>
  84. function submitDeleteForm() {
  85. var message = prompt("{{.i18n.Tr "repo.delete_confirm_message"}}\n\n{{.i18n.Tr "repo.delete_commit_summary"}}", "Delete '{{.TreeName}}'");
  86. if (message != null) {
  87. $("#delete-message").val(message);
  88. $("#delete-file-form").submit()
  89. }
  90. }
  91. </script>