mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 03:35:55 +01:00
continue work on #255
This commit is contained in:
parent
abc57b6e43
commit
35977cd34c
@ -141,6 +141,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
|
|||||||
"Oauth2Icon": Oauth2Icon,
|
"Oauth2Icon": Oauth2Icon,
|
||||||
"Oauth2Name": Oauth2Name,
|
"Oauth2Name": Oauth2Name,
|
||||||
"ToUtf8": ToUtf8,
|
"ToUtf8": ToUtf8,
|
||||||
|
"EscapePound": func(str string) string {
|
||||||
|
return strings.Replace(str, "#", "%23", -1)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type Actioner interface {
|
type Actioner interface {
|
||||||
|
@ -44,7 +44,6 @@ func RepoRef() macaron.Handler {
|
|||||||
}
|
}
|
||||||
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
|
ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
|
||||||
ctx.Repo.IsBranch = true
|
ctx.Repo.IsBranch = true
|
||||||
ctx.Repo.BranchName = refName
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
hasMatched := false
|
hasMatched := false
|
||||||
@ -293,73 +292,6 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||||||
ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", setting.Domain, u.LowerName, repo.LowerName)
|
ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", setting.Domain, u.LowerName, repo.LowerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// when repo is bare, not valid branch
|
|
||||||
// if !ctx.Repo.Repository.IsBare && validBranch {
|
|
||||||
// detect:
|
|
||||||
// if len(refName) > 0 {
|
|
||||||
// if gitRepo.IsBranchExist(refName) {
|
|
||||||
// ctx.Repo.IsBranch = true
|
|
||||||
// ctx.Repo.BranchName = refName
|
|
||||||
|
|
||||||
// ctx.Repo.Commit, err = gitRepo.GetCommitOfBranch(refName)
|
|
||||||
// if err != nil {
|
|
||||||
// ctx.Handle(500, "RepoAssignment invalid branch", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
|
|
||||||
|
|
||||||
// } else if gitRepo.IsTagExist(refName) {
|
|
||||||
// ctx.Repo.IsTag = true
|
|
||||||
// ctx.Repo.BranchName = refName
|
|
||||||
// ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommitOfTag(refName)
|
|
||||||
// if err != nil {
|
|
||||||
// ctx.Handle(500, "Fail to get tag commit", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// ctx.Repo.CommitId = ctx.Repo.Commit.Id.String()
|
|
||||||
// } else if len(refName) == 40 {
|
|
||||||
// ctx.Repo.IsCommit = true
|
|
||||||
// ctx.Repo.CommitId = refName
|
|
||||||
// ctx.Repo.BranchName = refName
|
|
||||||
|
|
||||||
// ctx.Repo.Commit, err = gitRepo.GetCommit(refName)
|
|
||||||
// if err != nil {
|
|
||||||
// ctx.Handle(404, "RepoAssignment invalid commit", nil)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// ctx.Handle(404, "RepoAssignment invalid repo", fmt.Errorf("branch or tag not exist: %s", refName))
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// if len(refName) == 0 {
|
|
||||||
// if gitRepo.IsBranchExist(ctx.Repo.Repository.DefaultBranch) {
|
|
||||||
// refName = ctx.Repo.Repository.DefaultBranch
|
|
||||||
// } else {
|
|
||||||
// brs, err := gitRepo.GetBranches()
|
|
||||||
// if err != nil {
|
|
||||||
// ctx.Handle(500, "GetBranches", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// refName = brs[0]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// goto detect
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ctx.Data["IsBranch"] = ctx.Repo.IsBranch
|
|
||||||
// ctx.Data["IsTag"] = ctx.Repo.IsTag
|
|
||||||
// ctx.Data["IsCommit"] = ctx.Repo.IsCommit
|
|
||||||
|
|
||||||
// ctx.Repo.CommitsCount, err = ctx.Repo.Commit.CommitsCount()
|
|
||||||
// if err != nil {
|
|
||||||
// ctx.Handle(500, "CommitsCount", err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
|
||||||
// }
|
|
||||||
|
|
||||||
// repo is bare and display enable
|
// repo is bare and display enable
|
||||||
if ctx.Repo.Repository.IsBare {
|
if ctx.Repo.Repository.IsBare {
|
||||||
log.Debug("Bare repository: %s", ctx.Repo.RepoLink)
|
log.Debug("Bare repository: %s", ctx.Repo.RepoLink)
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
<p class="text-center" id="repo-clone-help">{{$.i18n.Tr "repo.clone_helper" | Str2html}}</p>
|
<p class="text-center" id="repo-clone-help">{{$.i18n.Tr "repo.clone_helper" | Str2html}}</p>
|
||||||
<hr/>
|
<hr/>
|
||||||
<div class="text-center" id="repo-clone-zip">
|
<div class="text-center" id="repo-clone-zip">
|
||||||
<a class="btn btn-green btn-radius" href="{{$.RepoLink}}/archive/{{$.BranchName}}.zip"><i class="octicon octicon-file-zip"></i>ZIP</a>
|
<a class="btn btn-green btn-radius" href="{{$.RepoLink}}/archive/{{EscapePound $.BranchName}}.zip"><i class="octicon octicon-file-zip"></i>ZIP</a>
|
||||||
<a class="btn btn-green btn-radius" href="{{$.RepoLink}}/archive/{{$.BranchName}}.tar.gz"><i class="octicon octicon-file-zip"></i>TAR.GZ</a>
|
<a class="btn btn-green btn-radius" href="{{$.RepoLink}}/archive/{{EscapePound $.BranchName}}.tar.gz"><i class="octicon octicon-file-zip"></i>TAR.GZ</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,26 +31,26 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<ul class="menu menu-vertical switching-list {{if .IsTag}}hide{{end}}" id="repo-branch-list">
|
<ul class="menu menu-vertical switching-list {{if .IsTag}}hide{{end}}" id="repo-branch-list">
|
||||||
{{range .Branches}}
|
{{range .Branches}}
|
||||||
<li {{if eq . $.BranchName}}class="checked"{{end}}><a href="{{$.RepoLink}}/src/{{.}}"><i class="octicon octicon-check"></i>{{.}}</a></li>
|
<li {{if eq . $.BranchName}}class="checked"{{end}}><a href="{{$.RepoLink}}/src/{{EscapePound .}}"><i class="octicon octicon-check"></i>{{.}}</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="menu menu-vertical switching-list {{if not .IsTag}}hide{{end}}" id="repo-tag-list">
|
<ul class="menu menu-vertical switching-list {{if not .IsTag}}hide{{end}}" id="repo-tag-list">
|
||||||
{{range .Tags}}
|
{{range .Tags}}
|
||||||
<li {{if eq . $.BranchName}}class="checked"{{end}}><a href="{{$.RepoLink}}/src/{{.}}"><i class="octicon octicon-check"></i>{{.}}</a></li>
|
<li {{if eq . $.BranchName}}class="checked"{{end}}><a href="{{$.RepoLink}}/src/{{EscapePound .}}"><i class="octicon octicon-check"></i>{{.}}</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li id="repo-bread" class="breads">
|
<li id="repo-bread" class="breads">
|
||||||
<a class="title bread" href="{{.RepoLink}}">{{.Repository.Name}}</a>
|
<a class="title bread" href="{{.RepoLink}}/src/{{EscapePound .BranchName}}">{{.Repository.Name}}</a>
|
||||||
{{ $n := len .Treenames}}
|
{{ $n := len .Treenames}}
|
||||||
{{ $l := Subtract $n 1}}
|
{{ $l := Subtract $n 1}}
|
||||||
{{range $i, $v := .Treenames}}
|
{{range $i, $v := .Treenames}}
|
||||||
{{if eq $i $l}}
|
{{if eq $i $l}}
|
||||||
<span class="bread">{{$v}}</span>
|
<span class="bread">{{EscapePound $v}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="bread"><a href="{{$.BranchLink}}/{{index $.Paths $i}}">{{$v}}</a></span>
|
<span class="bread"><a href="{{EscapePound $.BranchLink}}/{{index $.Paths $i}}">{{$v}}</a></span>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</li>
|
</li>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<li class="border-bottom"></li>
|
<li class="border-bottom"></li>
|
||||||
<li class="head">{{if .IsViewBranch}}{{.BranchName}}{{else}}{{ShortSha .BranchName}}{{end}}</li>
|
<li class="head">{{if .IsViewBranch}}{{.BranchName}}{{else}}{{ShortSha .BranchName}}{{end}}</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="radius" href="{{.RepoLink}}/commits/{{.BranchName}}"><i class="octicon octicon-history"></i>{{.i18n.Tr "repo.commits"}} <span class="num right label label-gray label-radius">{{.CommitsCount}}</span></a>
|
<a class="radius" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}"><i class="octicon octicon-history"></i>{{.i18n.Tr "repo.commits"}} <span class="num right label label-gray label-radius">{{.CommitsCount}}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<!-- <li>
|
<!-- <li>
|
||||||
<a class="radius" href="{{.RepoLink}}/branches"><i class="octicon octicon-git-branch"></i>Branches<span class="num right label label-gray label-radius">{{.BrancheCount}}</span></a>
|
<a class="radius" href="{{.RepoLink}}/branches"><i class="octicon octicon-git-branch"></i>Branches<span class="num right label label-gray label-radius">{{.BrancheCount}}</span></a>
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
<strong class="file-name">{{.FileName}}</strong><span class="file-size">{{FileSize .FileSize}}</span>
|
<strong class="file-name">{{.FileName}}</strong><span class="file-size">{{FileSize .FileSize}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if not .ReadmeInList}}
|
{{if not .ReadmeInList}}
|
||||||
<a class="right" href="{{.RepoLink}}/commits/{{.BranchName}}/{{.TreeName}}">
|
<a class="right" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{.TreeName}}">
|
||||||
<button class="btn btn-medium btn-gray btn-right-radius btn-comb">{{.i18n.Tr "repo.file_history"}}</button>
|
<button class="btn btn-medium btn-gray btn-right-radius btn-comb">{{.i18n.Tr "repo.file_history"}}</button>
|
||||||
</a>
|
</a>
|
||||||
<a class="right" href="{{.FileLink}}">
|
<a class="right" href="{{EscapePound .FileLink}}">
|
||||||
<button class="btn btn-medium btn-gray btn-left-radius btn-comb">{{.i18n.Tr "repo.file_raw"}}</button>
|
<button class="btn btn-medium btn-gray btn-left-radius btn-comb">{{.i18n.Tr "repo.file_raw"}}</button>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -26,9 +26,9 @@
|
|||||||
{{else if not .IsFileText}}
|
{{else if not .IsFileText}}
|
||||||
<div class="view-raw">
|
<div class="view-raw">
|
||||||
{{if .IsImageFile}}
|
{{if .IsImageFile}}
|
||||||
<img src="{{.FileLink}}">
|
<img src="{{EscapePound .FileLink}}">
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="{{.FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
|
<a href="{{EscapePound .FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{else if .FileSize}}
|
{{else if .FileSize}}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
{{if .HasParentPath}}
|
{{if .HasParentPath}}
|
||||||
<tr class="has-parent">
|
<tr class="has-parent">
|
||||||
<td class="icon"></td>
|
<td class="icon"></td>
|
||||||
<td class="name"><a href="{{.BranchLink}}{{.ParentPath}}">..</a></td>
|
<td class="name"><a href="{{EscapePound .BranchLink}}{{.ParentPath}}">..</a></td>
|
||||||
<td class="msg"></td>
|
<td class="msg"></td>
|
||||||
<td class="age"></td>
|
<td class="age"></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
<span class="octicon octicon-file-{{if or $entry.IsDir}}directory{{else}}text{{end}}"></span>
|
<span class="octicon octicon-file-{{if or $entry.IsDir}}directory{{else}}text{{end}}"></span>
|
||||||
</td>
|
</td>
|
||||||
<td class="name">
|
<td class="name">
|
||||||
<a href="{{$.BranchLink}}/{{$.TreePath}}{{$entry.Name}}" class="text-truncate">{{$entry.Name}}</a>
|
<a href="{{EscapePound $.BranchLink}}/{{$.TreePath}}{{$entry.Name}}" class="text-truncate">{{$entry.Name}}</a>
|
||||||
</td>
|
</td>
|
||||||
{{end}}
|
{{end}}
|
||||||
<td class="msg">
|
<td class="msg">
|
||||||
|
Loading…
Reference in New Issue
Block a user