view_file.tmpl 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <div id="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}}</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">
  16. <div class="ui small grey basic 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. </div>
  24. {{end}}
  25. </h4>
  26. <div class="ui attached table segment">
  27. <div class="file-view {{if .ReadmeExist}}markdown{{else if .IsFileText}}code-view{{end}} has-emoji">
  28. {{if .ReadmeExist}}
  29. {{if .FileContent}}{{.FileContent | Str2html}}{{end}}
  30. {{else if not .IsFileText}}
  31. <div class="view-raw ui center">
  32. {{if .IsImageFile}}
  33. <img src="{{EscapePound .FileLink}}">
  34. {{else if .IsPDFFile}}
  35. <iframe width="100%" height="600px" src="{{AppSubUrl}}/plugins/pdfjs-1.4.20/web/viewer.html?file={{EscapePound .FileLink}}"></iframe>
  36. {{else}}
  37. <a href="{{EscapePound .FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
  38. {{end}}
  39. </div>
  40. {{else if .FileSize}}
  41. <table>
  42. <tbody>
  43. <tr>
  44. {{if .IsFileTooLarge}}
  45. <td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
  46. {{else}}
  47. <td class="lines-num"></td>
  48. <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
  49. {{end}}
  50. </tr>
  51. </tbody>
  52. </table>
  53. {{end}}
  54. </div>
  55. </div>
  56. </div>