diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-08-23 01:58:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 19:58:11 -0400 |
commit | c0754e9d1998827a4be7b7297d87cb6e5e31500d (patch) | |
tree | 4c1e65a882e3ff601701704bd4dd3da94c8ace76 | |
parent | bf41958c16e36ce4dc74701520af828c99ecae5b (diff) | |
download | gitea-c0754e9d1998827a4be7b7297d87cb6e5e31500d.tar.gz gitea-c0754e9d1998827a4be7b7297d87cb6e5e31500d.zip |
Don't open new page for ext wiki on same repository (#20725) (#20910)
* Don't open new page for ext wiki on same repository (#20725)
- Backport of #20725
- When the external wiki has been set to a file on the repository, don't open the page on a tab.
- Resolves #20657
* Gofmt
* Fix line
Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r-- | modules/templates/helper.go | 1 | ||||
-rw-r--r-- | templates/repo/header.tmpl | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 537ef71ccf..ad39baecb9 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -454,6 +454,7 @@ func NewFuncMap() []template.FuncMap { } return items }, + "HasPrefix": strings.HasPrefix, }} } diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 94ae5ed7e2..a2f31fc950 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -206,7 +206,7 @@ {{end}} {{if or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki)}} - <a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki" {{if (.Permission.CanRead $.UnitTypeExternalWiki)}} target="_blank" rel="noopener noreferrer" {{end}}> + <a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki" {{if and (.Permission.CanRead $.UnitTypeExternalWiki) (not (HasPrefix ((.Repository.MustGetUnit $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL) (.Repository.HTMLURL)))}} target="_blank" rel="noopener noreferrer" {{end}}> {{svg "octicon-book"}} {{.i18n.Tr "repo.wiki"}} </a> {{end}} |