mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-23 05:46:09 +02:00
Make template simpler
This commit is contained in:
parent
be7a6b6057
commit
f769c8bf43
@ -21,6 +21,7 @@ import (
|
|||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
unit_model "code.gitea.io/gitea/models/unit"
|
unit_model "code.gitea.io/gitea/models/unit"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/cache"
|
"code.gitea.io/gitea/modules/cache"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/gitrepo"
|
"code.gitea.io/gitea/modules/gitrepo"
|
||||||
@ -743,6 +744,21 @@ const (
|
|||||||
RepoRefBlob
|
RepoRefBlob
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func RefTypeName(refType RepoRefType) string {
|
||||||
|
switch refType {
|
||||||
|
case RepoRefBranch:
|
||||||
|
return "branch"
|
||||||
|
case RepoRefTag:
|
||||||
|
return "tag"
|
||||||
|
case RepoRefCommit:
|
||||||
|
return "commit"
|
||||||
|
case RepoRefBlob:
|
||||||
|
return "blob"
|
||||||
|
default:
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const headRefName = "HEAD"
|
const headRefName = "HEAD"
|
||||||
|
|
||||||
// RepoRef handles repository reference names when the ref name is not
|
// RepoRef handles repository reference names when the ref name is not
|
||||||
@ -988,6 +1004,8 @@ func RepoRefByType(detectRefType RepoRefType, opts ...RepoRefByTypeOptions) func
|
|||||||
|
|
||||||
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
||||||
ctx.Data["RefName"] = ctx.Repo.RefName
|
ctx.Data["RefName"] = ctx.Repo.RefName
|
||||||
|
ctx.Data["RefShortName"] = util.Iif(refType == RepoRefCommit, base.ShortSha(ctx.Repo.RefName), ctx.Repo.RefName)
|
||||||
|
ctx.Data["RefType"] = RefTypeName(refType)
|
||||||
ctx.Data["BranchNameSubURL"] = ctx.Repo.BranchNameSubURL()
|
ctx.Data["BranchNameSubURL"] = ctx.Repo.BranchNameSubURL()
|
||||||
ctx.Data["TagName"] = ctx.Repo.TagName
|
ctx.Data["TagName"] = ctx.Repo.TagName
|
||||||
ctx.Data["CommitID"] = ctx.Repo.CommitID
|
ctx.Data["CommitID"] = ctx.Repo.CommitID
|
||||||
|
@ -1,21 +1,9 @@
|
|||||||
{{- /* for repo home (default branch) and /owner/repo/src/branch/the-name */ -}}
|
|
||||||
{{- $branchDropdownCurrentRefType := "branch" -}}
|
|
||||||
{{- $branchDropdownCurrentRefShortName := .ctxData.BranchName -}}
|
|
||||||
{{- if .IsViewTag -}}
|
|
||||||
{{- /* for /owner/repo/src/tag/the-name */ -}}
|
|
||||||
{{- $branchDropdownCurrentRefType = "tag" -}}
|
|
||||||
{{- $branchDropdownCurrentRefShortName = .ctxData.TagName -}}
|
|
||||||
{{- else if .IsViewCommit -}}
|
|
||||||
{{- /* for /owner/repo/src/commit/000000 */ -}}
|
|
||||||
{{- $branchDropdownCurrentRefType = "commit" -}}
|
|
||||||
{{- $branchDropdownCurrentRefShortName = ShortSha .ctxData.CommitID -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{template "repo/branch_dropdown" dict
|
{{template "repo/branch_dropdown" dict
|
||||||
"Repository" .ctxData.Repository
|
"Repository" .ctxData.Repository
|
||||||
"ShowTabBranches" true
|
"ShowTabBranches" true
|
||||||
"ShowTabTags" true
|
"ShowTabTags" true
|
||||||
"CurrentRefType" $branchDropdownCurrentRefType
|
"CurrentRefType" .ctxData.RefType
|
||||||
"CurrentRefShortName" $branchDropdownCurrentRefShortName
|
"CurrentRefShortName" .ctxData.RefShortName
|
||||||
"CurrentTreePath" .ctxData.TreePath
|
"CurrentTreePath" .ctxData.TreePath
|
||||||
"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
|
"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
|
||||||
"AllowCreateNewRef" .ctxData.CanCreateBranch
|
"AllowCreateNewRef" .ctxData.CanCreateBranch
|
||||||
|
@ -1,16 +1,3 @@
|
|||||||
{{- /* for repo home (default branch) and /owner/repo/src/branch/the-name */ -}}
|
|
||||||
{{- $branchDropdownCurrentRefType := "branch" -}}
|
|
||||||
{{- $branchDropdownCurrentRefShortName := .BranchName -}}
|
|
||||||
{{- if .IsViewTag -}}
|
|
||||||
{{- /* for /owner/repo/src/tag/the-name */ -}}
|
|
||||||
{{- $branchDropdownCurrentRefType = "tag" -}}
|
|
||||||
{{- $branchDropdownCurrentRefShortName = .TagName -}}
|
|
||||||
{{- else if .IsViewCommit -}}
|
|
||||||
{{- /* for /owner/repo/src/commit/000000 */ -}}
|
|
||||||
{{- $branchDropdownCurrentRefType = "commit" -}}
|
|
||||||
{{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
<div class="view-file-tree-sidebar-top">
|
<div class="view-file-tree-sidebar-top">
|
||||||
<div class="sidebar-header">
|
<div class="sidebar-header">
|
||||||
<button class="hide-tree-sidebar-button ui compact basic button icon" title="{{ctx.Locale.Tr "repo.diff.hide_file_tree"}}">
|
<button class="hide-tree-sidebar-button ui compact basic button icon" title="{{ctx.Locale.Tr "repo.diff.hide_file_tree"}}">
|
||||||
@ -24,7 +11,7 @@
|
|||||||
<div id="view-file-tree" class="is-loading"
|
<div id="view-file-tree" class="is-loading"
|
||||||
data-api-base-url="{{.RepoLink}}"
|
data-api-base-url="{{.RepoLink}}"
|
||||||
data-tree-path="{{$.TreePath}}"
|
data-tree-path="{{$.TreePath}}"
|
||||||
data-current-ref-type="{{$branchDropdownCurrentRefType}}"
|
data-current-ref-type="{{.RefType}}"
|
||||||
data-current-ref-short-name="{{$branchDropdownCurrentRefShortName}}"
|
data-current-ref-short-name="{{.RefShortName}}"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user