Remove a bunch more cruft

This commit is contained in:
James Mills
2022-10-05 11:19:27 +10:00
parent a07f747eb1
commit 2ba2451108
9 changed files with 10 additions and 85 deletions

View File

@@ -31,9 +31,7 @@ var (
theme string
baseURL string
// Pod Oeprator
adminUser string
adminPass string
// Oeprator
adminName string
adminEmail string
@@ -41,9 +39,7 @@ var (
resultsPerPage int
// Secrets
apiSigningKey string
cookieSecret string
magiclinkSecret string
// Email Setitngs
smtpHost string
@@ -54,8 +50,6 @@ var (
// Timeouts
sessionExpiry time.Duration
sessionCacheTTL time.Duration
apiSessionTime time.Duration
)
func init() {
@@ -64,8 +58,8 @@ func init() {
flag.BoolVarP(&version, "version", "v", false, "display version information")
// Basic options
flag.StringVarP(&name, "name", "n", internal.DefaultName, "set the pod's name")
flag.StringVarP(&description, "description", "m", internal.DefaultMetaDescription, "set the pod's description")
flag.StringVarP(&name, "name", "n", internal.DefaultName, "set the instance name")
flag.StringVarP(&description, "description", "m", internal.DefaultMetaDescription, "set the instance description")
flag.StringVarP(&data, "data", "d", internal.DefaultData, "data directory")
flag.StringVarP(&store, "store", "s", internal.DefaultStore, "store to use")
flag.StringVarP(&theme, "theme", "t", internal.DefaultTheme, "set the default theme")
@@ -74,8 +68,6 @@ func init() {
// Administration
flag.StringVarP(&adminName, "admin-name", "N", internal.DefaultAdminName, "default admin user name")
flag.StringVarP(&adminEmail, "admin-email", "E", internal.DefaultAdminEmail, "default admin user email")
flag.StringVarP(&adminUser, "admin-user", "A", internal.DefaultAdminUser, "default admin user to use")
flag.StringVarP(&adminPass, "admin-pass", "P", internal.DefaultAdminName, "default admin user name")
// Limits
flag.IntVarP(
@@ -84,18 +76,10 @@ func init() {
)
// Secrets
flag.StringVar(
&apiSigningKey, "api-signing-key", internal.DefaultAPISigningKey,
"secret to use for signing api tokens",
)
flag.StringVar(
&cookieSecret, "cookie-secret", internal.DefaultCookieSecret,
"cookie secret to use secure sessions",
)
flag.StringVar(
&magiclinkSecret, "magiclink-secret", internal.DefaultMagicLinkSecret,
"magiclink secret to use for password reset tokens",
)
// Email Setitngs
flag.StringVar(&smtpHost, "smtp-host", internal.DefaultSMTPHost, "SMTP Host to use for email sending")
@@ -109,14 +93,6 @@ func init() {
&sessionExpiry, "session-expiry", internal.DefaultSessionExpiry,
"timeout for sessions to expire",
)
flag.DurationVar(
&sessionCacheTTL, "session-cache-ttl", internal.DefaultSessionCacheTTL,
"time-to-live for cached sessions",
)
flag.DurationVar(
&apiSessionTime, "api-session-time", internal.DefaultAPISessionTime,
"timeout for api tokens to expire",
)
}
func flagNameFromEnvironmentName(s string) string {

1
go.mod
View File

@@ -18,7 +18,6 @@ require (
github.com/blevesearch/bleve/v2 v2.0.1
github.com/creasty/defaults v1.5.1
github.com/dustin/go-humanize v1.0.0
github.com/gabstv/merger v1.0.1
github.com/glycerine/go-unsnap-stream v0.0.0-20210130063903-47dfef350d96 // indirect
github.com/go-mail/mail v2.3.1+incompatible
github.com/go-shiori/go-readability v0.0.0-20201011032228-bdc871772408

2
go.sum
View File

@@ -204,8 +204,6 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/gabstv/merger v1.0.1 h1:e6y87GkAX9XSNPZNCMvYf90ZNcr2PzbtvHN3pZZOQt0=
github.com/gabstv/merger v1.0.1/go.mod h1:oQKCbAX4P6q0jk4s9Is144NojOE/HggFPb5qjPNZjq8=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
github.com/glycerine/go-unsnap-stream v0.0.0-20210130063903-47dfef350d96 h1:rCXyLrgJ598XNj7KTqPzAvwTzlyvI+clqasoNfLQStE=

View File

@@ -7,21 +7,12 @@ import (
"net/url"
"strings"
"time"
"github.com/gabstv/merger"
log "github.com/sirupsen/logrus"
)
var (
ErrConfigPathMissing = errors.New("error: config file missing")
)
// Settings contains Pod Settings that can be customised via the Web UI
type Settings struct {
Name string `yaml:"pod_name"`
Description string `yaml:"pod_description"`
}
// Config contains the server configuration parameters
type Config struct {
Debug bool
@@ -59,18 +50,6 @@ func (c *Config) IsLocalURL(url string) bool {
}
func (c *Config) LocalURL() *url.URL { return c.baseURL }
// Settings returns a `Settings` struct containing pod settings that can
// then be persisted to disk to override some configuration options.
func (c *Config) Settings() *Settings {
settings := &Settings{}
if err := merger.MergeOverwrite(settings, c); err != nil {
log.WithError(err).Warn("error creating pod settings")
}
return settings
}
// RandomSearchPrompt returns a random Search Prompt for display by the UI
func (c *Config) RandomSearchPrompt() string {
n := rand.Int() % len(c.SearchPrompts)

View File

@@ -23,9 +23,7 @@ const (
// DefaultBaseURL is the default Base URL for the app used to construct feed URLs
DefaultBaseURL = "http://0.0.0.0:8000"
// DefaultAdminXXX is the default admin user / pod operator
DefaultAdminUser = "admin"
DefaultAdminPass = "admiN"
// DefaultAdminXXX is the default admin user / operator
DefaultAdminName = "Administrator"
DefaultAdminEmail = "support@spyda.dev"
@@ -47,27 +45,15 @@ const (
// DefaultResultsPerPage is the server's default results per page to display
DefaultResultsPerPage = 10
// DefaultSessionCacheTTL is the server's default session cache ttl
DefaultSessionCacheTTL = 1 * time.Hour
// DefaultSessionExpiry is the server's default session expiry time
DefaultSessionExpiry = 240 * time.Hour // 10 days
// DefaultMagicLinkSecret is the jwt magic link secret
DefaultMagicLinkSecret = InvalidConfigValue
// Default SMTP configuration
DefaultSMTPHost = "smtp.gmail.com"
DefaultSMTPPort = 587
DefaultSMTPUser = InvalidConfigValue
DefaultSMTPPass = InvalidConfigValue
DefaultSMTPFrom = InvalidConfigValue
// DefaultAPISessionTime is the server's default session time for API tokens
DefaultAPISessionTime = 240 * time.Hour // 10 days
// DefaultAPISigningKey is the default API JWT signing key for tokens
DefaultAPISigningKey = InvalidConfigValue
)
var (
@@ -146,7 +132,7 @@ func WithBaseURL(baseURL string) Option {
}
}
// WithAdminName sets the Admin name used to identify the pod operator
// WithAdminName sets the Admin name used to identify the operator
func WithAdminName(adminName string) Option {
return func(cfg *Config) error {
cfg.AdminName = adminName
@@ -154,7 +140,7 @@ func WithAdminName(adminName string) Option {
}
}
// WithAdminEmail sets the Admin email used to contact the pod operator
// WithAdminEmail sets the Admin email used to contact the operator
func WithAdminEmail(adminEmail string) Option {
return func(cfg *Config) error {
cfg.AdminEmail = adminEmail

View File

@@ -1,6 +1,3 @@
// Copyright 2020-present Yarn.social
// SPDX-License-Identifier: AGPL-3.0-or-later
package internal
import (

View File

@@ -1,7 +1,6 @@
package internal
import (
"fmt"
"net/http"
"strings"
@@ -97,10 +96,7 @@ func (s *Server) SupportHandler() httprouter.Handle {
log.Infof("support message email sent for %s", email)
ctx.Error = false
ctx.Message = fmt.Sprintf(
"Thank you for your message! Pod operator %s will get back to you soon!",
s.config.AdminName,
)
ctx.Message = "Thank you for your message! We will get back to you soon!"
s.render("error", w, ctx)
}
}

View File

@@ -3,12 +3,6 @@
<div>
{{ .Content }}
<hr />
<footer class="container">
This is a <a href="https://twt.social">Twt.Social</a> pod.
If you would like your own pod, please contact <a href="https://twt.social/support">support</a>.
::
<a href="https://github.com/jointwt/twtxt/edit/master/internal/pages/{{ .Page }}.md">Edit on github</a>
</footer>
</div>
</article>
{{ end }}

View File

@@ -325,7 +325,7 @@ func NormalizeURL(url string) string {
}
// RedirectRefererURL constructs a Redirect URL from the given Request URL
// and possibly Referer, if the Referer's Base URL matches the Pod's Base URL
// and possibly Referer, if the Referer's Base URL matches the Server's Base URL
// will return the Referer URL otherwise the defaultURL. This is primarily used
// to redirect a user from a successful /login back to the page they were on.
func RedirectRefererURL(r *http.Request, conf *Config, defaultURL string) string {