Skip to content

Commit

Permalink
Don't open new page for ext wiki on same repository (go-gitea#20725)
Browse files Browse the repository at this point in the history
- Backport of go-gitea#20725
  - When the external wiki has been set to a file on the repository, don't open the page on a tab.
  - Resolves go-gitea#20657
  • Loading branch information
Gusted committed Aug 22, 2022
1 parent ebc8801 commit b5485ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ func NewTextFuncMap() []texttmpl.FuncMap {
return sum
},
"QueryEscape": url.QueryEscape,
"HasPrefix": strings.HasPrefix,
}}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/repo/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit b5485ca

Please sign in to comment.