Browse Source

Merge pull request #2757 from joshfng/fix-fork-relative-url

Use relative url when showing forked from
for-closed-social
Unknwon 8 years ago
parent
commit
dfd6f8f7ab
2 changed files with 7 additions and 2 deletions
  1. +5
    -0
      models/repo.go
  2. +2
    -2
      templates/repo/header.tmpl

+ 5
- 0
models/repo.go View File

@ -326,6 +326,11 @@ func (repo *Repository) RepoLink() string {
return setting.AppSubUrl + "/" + repo.MustOwner().Name + "/" + repo.Name
}
func (repo *Repository) RepoRelLink() string {
return "/" + repo.MustOwner().Name + "/" + repo.Name
}
func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string {
return fmt.Sprintf("%s/%s/compare/%s...%s", repo.MustOwner().Name, repo.Name, oldCommitID, newCommitID)
}

+ 2
- 2
templates/repo/header.tmpl View File

@ -10,7 +10,7 @@
<div class="divider"> / </div>
<a href="{{$.RepoLink}}">{{.Name}}</a>
{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" href="{{$.Mirror.Address}}">{{$.Mirror.Address}}</a></div>{{end}}
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.RepoLink}}">{{SubStr .BaseRepo.RepoLink 1 -1}}</a></div>{{end}}
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.RepoLink}}">{{SubStr .BaseRepo.RepoRelLink 1 -1}}</a></div>{{end}}
</div>
<div class="ui right">
@ -86,4 +86,4 @@
{{else}}
<div class="ui divider"></div>
{{end}}
</div>
</div>

Loading…
Cancel
Save