diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-08-20 16:47:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-20 15:47:04 +0100 |
commit | 3d52edc7a43ca429b7921b96c3663c32179881ab (patch) | |
tree | 58b7d67d10324012936d907fff4ce733537382d7 | |
parent | 8cceee4084c116dedc731da050d49549a8f71a1d (diff) | |
download | gitea-3d52edc7a43ca429b7921b96c3663c32179881ab.tar.gz gitea-3d52edc7a43ca429b7921b96c3663c32179881ab.zip |
Don't open new page for ext wiki on same repository (#20725)
- When the external wiki has been set to a file on the repository, don't
open the page on a tab.
- Resolves #20657
-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 602afec413..410857f37e 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -453,6 +453,7 @@ func NewFuncMap() []template.FuncMap { } return items }, + "HasPrefix": strings.HasPrefix, }} } diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index e6ed76bb60..a08196f264 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"}} {{.locale.Tr "repo.wiki"}} </a> {{end}} |