mirror of
https://github.com/acaloiaro/newsbox
synced 2026-07-21 10:12:26 +00:00
74 lines
1.8 KiB
Go
74 lines
1.8 KiB
Go
package internal
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/gobuffalo/envy"
|
|
)
|
|
|
|
// SiteName returns the name of the current site
|
|
func SiteName() string {
|
|
return envy.Get("SITE_NAME", "Newsbox")
|
|
}
|
|
|
|
// SiteProtocol returns the scheme (http/https) that the site should use when generating URLs
|
|
func SiteProtocol() string {
|
|
return envy.Get("SITE_PROTOCOL", "https")
|
|
}
|
|
|
|
// AnalyticsEnabled returns true if analytics are enabled for this site
|
|
func AnalyticsEnabled() bool {
|
|
val, err := strconv.ParseBool(envy.Get("ENABLE_ANALYTICS", "false"))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
return val
|
|
}
|
|
|
|
// AnalyticsSelfHostingEnabled returns true if analytics are enabled for this site and the following enviornment
|
|
// variable is set: ENABLE_ANALYTICS_SELF_HOSTING
|
|
func AnalyticsSelfHostingEnabled() bool {
|
|
if !AnalyticsEnabled() {
|
|
return false
|
|
}
|
|
|
|
val, err := strconv.ParseBool(envy.Get("ENABLE_ANALYTICS_SELF_HOSTING", "false"))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
return val
|
|
}
|
|
|
|
// PaymentsEnabled returns true if payments are enabled.
|
|
// Payments are enabled by setting the following environment variables: STRIPE_KEY, STRIPE_PRICE_ID
|
|
func PaymentsEnabled() bool {
|
|
val, err := envy.MustGet("STRIPE_KEY")
|
|
if err != nil || val == "" {
|
|
return false
|
|
}
|
|
|
|
val, err = envy.MustGet("STRIPE_PRICE_ID")
|
|
if err != nil || val == "" {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// GithubLoginEnabled() returns true if Github oauth logins are enabled
|
|
// Github oauth logins are enabled by setting the following environment variables: GH_OAUTH_CLIENT_ID, GH_OAUTH_CLIENT_SECRET
|
|
func GithubLoginEnabled() bool {
|
|
val, err := envy.MustGet("GH_OAUTH_CLIENT_ID")
|
|
if err != nil || val == "" {
|
|
return false
|
|
}
|
|
|
|
val, err = envy.MustGet("GH_OAUTH_CLIENT_SECRET")
|
|
if err != nil || val == "" {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|