]> source.dussan.org Git - gitea.git/commitdiff
Improve External Wiki in Repo Header (#24304)
authorJakobDev <jakobdev@gmx.de>
Mon, 24 Apr 2023 16:28:37 +0000 (18:28 +0200)
committerGitHub <noreply@github.com>
Mon, 24 Apr 2023 16:28:37 +0000 (12:28 -0400)
If you use a External Wiki, with Gitea, it brings currently 2 Problems
in the Header:

1. It always uses the Wiki Icon. When you use e.g. a External Issue
Tracker, it shows the External Link icon to Indicate, that the User will
send to a External Side. This helps preventing fishing.
2. If you use a External Wiki, the Link in the Header still goes to
`{repo}/wiki` which will redirect the user to the External Wiki. That
means, that if the users hovers with the Cursor over the link, it shows
`{repo}/wiki`, so the User does not know, where he will land.

This PR fixes both.

![grafik](https://user-images.githubusercontent.com/15185051/233964455-dbca9bbe-a224-44c5-b351-5649fd9b15fc.png)

templates/repo/header.tmpl

index 5f2e135b98699f0733528c8e24833bc5b66d176d..8a6833f499316b4630c33a48be44a290decd0492 100644 (file)
                                </a>
                                {{end}}
 
-                               {{if or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki)}}
-                                       <a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki" {{if and (.Permission.CanRead $.UnitTypeExternalWiki) (not (StringUtils.HasPrefix ((.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL) (.Repository.Link)))}} target="_blank" rel="noopener noreferrer" {{end}}>
+                               {{if .Permission.CanRead $.UnitTypeWiki}}
+                                       <a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki">
                                                {{svg "octicon-book"}} {{.locale.Tr "repo.wiki"}}
                                        </a>
                                {{end}}
 
+                               {{if .Permission.CanRead $.UnitTypeExternalWiki}}
+                                       <a class="item" href="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}" target="_blank" rel="noopener noreferrer">
+                                               {{svg "octicon-link-external"}} {{.locale.Tr "repo.wiki"}}
+                                       </a>
+                               {{end}}
+
                                {{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
                                        <a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
                                                {{svg "octicon-pulse"}} {{.locale.Tr "repo.activity"}}