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>
tokarchuk/v1.17
Gusted 2 years ago committed by GitHub
parent bf41958c16
commit c0754e9d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      modules/templates/helper.go
  2. 2
      templates/repo/header.tmpl

@ -454,6 +454,7 @@ func NewFuncMap() []template.FuncMap {
} }
return items return items
}, },
"HasPrefix": strings.HasPrefix,
}} }}
} }

@ -206,7 +206,7 @@
{{end}} {{end}}
{{if or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki)}} {{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"}} {{svg "octicon-book"}} {{.i18n.Tr "repo.wiki"}}
</a> </a>
{{end}} {{end}}

Loading…
Cancel
Save