Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

view_file.tmpl 4.0KB

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