mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-08-21 12:08:54 +02:00
The plan is that all built-in auth providers use inline SVG for more flexibility in styling and to get the GitHub icon to follow `currentcolor`. This only removes the `public/img/auth` directory and adds the missing svgs to our svg build. It should map the built-in providers to these SVGs and render them. If the user has set a Icon URL, it should render that as an `img` tag instead. ``` gitea-azure-ad gitea-bitbucket gitea-discord gitea-dropbox gitea-facebook gitea-gitea gitea-gitlab gitea-google gitea-mastodon gitea-microsoftonline gitea-nextcloud gitea-twitter gitea-yandex octicon-mark-github ``` GitHub logo is now white again on dark theme: <img width="431" alt="Screenshot 2023-06-12 at 21 45 34" src="https://github.com/go-gitea/gitea/assets/115237/27a43504-d60a-4132-a502-336b25883e4d"> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package oauth2
|
|
|
|
import (
|
|
"html/template"
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
|
"code.gitea.io/gitea/modules/svg"
|
|
)
|
|
|
|
// BaseProvider represents a common base for Provider
|
|
type BaseProvider struct {
|
|
name string
|
|
displayName string
|
|
}
|
|
|
|
// Name provides the technical name for this provider
|
|
func (b *BaseProvider) Name() string {
|
|
return b.name
|
|
}
|
|
|
|
// DisplayName returns the friendly name for this provider
|
|
func (b *BaseProvider) DisplayName() string {
|
|
return b.displayName
|
|
}
|
|
|
|
// IconHTML returns icon HTML for this provider
|
|
func (b *BaseProvider) IconHTML() template.HTML {
|
|
svgName := "gitea-" + b.name
|
|
switch b.name {
|
|
case "gplus":
|
|
svgName = "gitea-google"
|
|
case "github":
|
|
svgName = "octicon-mark-github"
|
|
}
|
|
svgHTML := svg.RenderHTML(svgName, 20, "gt-mr-3")
|
|
if svgHTML == "" {
|
|
log.Error("No SVG icon for oauth2 provider %q", b.name)
|
|
svgHTML = svg.RenderHTML("gitea-openid", 20, "gt-mr-3")
|
|
}
|
|
return svgHTML
|
|
}
|
|
|
|
// CustomURLSettings returns the custom url settings for this provider
|
|
func (b *BaseProvider) CustomURLSettings() *CustomURLSettings {
|
|
return nil
|
|
}
|
|
|
|
var _ Provider = &BaseProvider{}
|