gitea源码

view_content.tmpl 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. {{$isTreePathRoot := not .TreeNames}}
  2. {{template "repo/sub_menu" .}}
  3. <div class="repo-button-row">
  4. <div class="repo-button-row-left">
  5. {{if not $isTreePathRoot}}
  6. <button class="repo-view-file-tree-toggle-show ui compact basic button icon not-mobile {{if .UserSettingCodeViewShowFileTree}}tw-hidden{{end}}"
  7. data-global-click="onRepoViewFileTreeToggle" data-toggle-action="show"
  8. data-tooltip-content="{{ctx.Locale.Tr "repo.diff.show_file_tree"}}">
  9. {{svg "octicon-sidebar-collapse"}}
  10. </button>
  11. {{end}}
  12. {{template "repo/branch_dropdown" dict
  13. "Repository" .Repository
  14. "ShowTabBranches" true
  15. "ShowTabTags" true
  16. "CurrentRefType" .RefFullName.RefType
  17. "CurrentRefShortName" .RefFullName.ShortName
  18. "CurrentTreePath" .TreePath
  19. "RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
  20. "AllowCreateNewRef" .CanCreateBranch
  21. "ShowViewAllRefsEntry" true
  22. }}
  23. {{if and .CanCompareOrPull .RefFullName.IsBranch (not .Repository.IsArchived)}}
  24. {{$cmpBranch := ""}}
  25. {{if ne .Repository.ID .BaseRepo.ID}}
  26. {{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}}
  27. {{end}}
  28. {{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}}
  29. {{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}}
  30. <a id="new-pull-request" role="button" class="ui compact basic button" href="{{QueryBuild $compareLink "expand" 1}}"
  31. data-tooltip-content="{{if .PullRequestCtx.Allowed}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}">
  32. {{svg "octicon-git-pull-request"}}
  33. </a>
  34. {{end}}
  35. <!-- Show go to file if on home page -->
  36. {{if $isTreePathRoot}}
  37. <a href="{{.Repository.Link}}/find/{{.RefTypeNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a>
  38. {{end}}
  39. {{if and .RefFullName.IsBranch (not .IsViewFile)}}
  40. <button class="ui dropdown basic compact jump button repo-add-file" {{if not .Repository.CanEnableEditor}}disabled{{end}}>
  41. {{ctx.Locale.Tr "repo.editor.add_file"}}
  42. {{svg "octicon-triangle-down" 14 "dropdown icon"}}
  43. <div class="menu">
  44. <a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
  45. {{ctx.Locale.Tr "repo.editor.new_file"}}
  46. </a>
  47. {{if .RepositoryUploadEnabled}}
  48. <a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
  49. {{ctx.Locale.Tr "repo.editor.upload_file"}}
  50. </a>
  51. {{end}}
  52. <a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
  53. {{ctx.Locale.Tr "repo.editor.patch"}}
  54. </a>
  55. </div>
  56. </button>
  57. {{end}}
  58. {{if and $isTreePathRoot .Repository.IsTemplate}}
  59. <a role="button" class="ui primary compact button" href="{{AppSubUrl}}/repo/create?template_id={{.Repository.ID}}">
  60. {{ctx.Locale.Tr "repo.use_template"}}
  61. </a>
  62. {{end}}
  63. {{if not $isTreePathRoot}}
  64. {{$treeNameIdxLast := Eval (len .TreeNames) "-" 1}}
  65. <span class="breadcrumb">
  66. <a class="section" href="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
  67. {{- range $i, $v := .TreeNames -}}
  68. <span class="breadcrumb-divider">/</span>
  69. {{- if eq $i $treeNameIdxLast -}}
  70. <span class="active section" title="{{$v}}">{{$v}}</span>
  71. <button class="btn interact-fg tw-mx-1" data-clipboard-text="{{$.TreePath}}" data-tooltip-content="{{ctx.Locale.Tr "copy_path"}}">{{svg "octicon-copy" 14}}</button>
  72. {{- else -}}
  73. {{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{$v}}</a></span>
  74. {{- end -}}
  75. {{- end -}}
  76. </span>
  77. {{end}}
  78. </div>
  79. <div class="repo-button-row-right">
  80. <!-- Only show clone panel in repository home page -->
  81. {{if $isTreePathRoot}}
  82. {{template "repo/clone_panel" .}}
  83. {{end}}
  84. {{if and (not $isTreePathRoot) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}}
  85. <a class="ui button" href="{{.RepoLink}}/commits/{{.RefTypeNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
  86. {{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}}
  87. </a>
  88. {{end}}
  89. </div>
  90. </div>
  91. {{if .IsViewFile}}
  92. {{template "repo/view_file" .}}
  93. {{else if .IsBlame}}
  94. {{template "repo/blame" .}}
  95. {{else}}{{/* IsViewDirectory */}}
  96. {{if $isTreePathRoot}}
  97. {{template "repo/code/upstream_diverging_info" .}}
  98. {{end}}
  99. {{template "repo/view_list" .}}
  100. {{if and .ReadmeExist (or .IsMarkup .IsPlainText)}}
  101. {{template "repo/view_file" .}}
  102. {{end}}
  103. {{end}}