view_file.tmpl 3.5 KB

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