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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <div id="file-content" class="{{TabSizeClass .Editorconfig .FileName}}">
  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}}</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}}</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 .TreeName}}">{{.i18n.Tr "repo.file_permalink"}}</a>
  19. {{end}}
  20. <a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{EscapePound .TreeName}}">{{.i18n.Tr "repo.file_history"}}</a>
  21. <a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
  22. </div>
  23. {{if .FileEditLink}}
  24. <a href="{{EscapePound $.FileEditLink}}"><i class="poping up octicon octicon-pencil btn-octicon" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
  25. {{else}}
  26. <i class="octicon btn-octicon octicon-pencil poping up disabled" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
  27. {{end}}
  28. {{if .FileDeleteLink}}
  29. <form id="delete-file-form" class="ui form inline-form" action="{{EscapePound $.FileDeleteLink}}" method="post">
  30. {{.CsrfTokenHtml}}
  31. <button onclick="submitDeleteForm()" class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" type="button" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></button>
  32. <input type="hidden" id="delete-message" name="commit_message" value="">
  33. </form>
  34. {{else}}
  35. <i class="octicon btn-octicon octicon-trashcan poping up disabled" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
  36. {{end}}
  37. </div>
  38. {{end}}
  39. </h4>
  40. <div class="ui attached table segment">
  41. <div class="file-view {{if .IsMarkdown}}markdown{{else if .IsFileText}}code-view{{end}} has-emoji">
  42. {{if .IsMarkdown}}
  43. {{if .FileContent}}{{.FileContent | Str2html}}{{end}}
  44. {{else if not .IsFileText}}
  45. <div class="view-raw ui center">
  46. {{if .IsImageFile}}
  47. <img src="{{EscapePound .FileLink}}">
  48. {{else if .IsPDFFile}}
  49. <iframe width="100%" height="600px" src="{{AppSubUrl}}/plugins/pdfjs-1.4.20/web/viewer.html?file={{EscapePound .FileLink}}"></iframe>
  50. {{else}}
  51. <a href="{{EscapePound $.FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
  52. {{end}}
  53. </div>
  54. {{else if .FileSize}}
  55. <table>
  56. <tbody>
  57. <tr>
  58. {{if .IsFileTooLarge}}
  59. <td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
  60. {{else}}
  61. <td class="lines-num">{{.LineNums}}</td>
  62. <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
  63. {{end}}
  64. </tr>
  65. </tbody>
  66. </table>
  67. {{end}}
  68. </div>
  69. </div>
  70. </div>
  71. <script>
  72. function submitDeleteForm() {
  73. var message = prompt("{{.i18n.Tr "repo.delete_confirm_message"}}\n\n{{.i18n.Tr "repo.delete_commit_summary"}}", "Delete '{{.TreeName}}'");
  74. if (message != null) {
  75. $("#delete-message").val(message);
  76. $("#delete-file-form").submit()
  77. }
  78. }
  79. </script>