Remove a bunch more cruft
This commit is contained in:
@@ -31,9 +31,7 @@ var (
|
|||||||
theme string
|
theme string
|
||||||
baseURL string
|
baseURL string
|
||||||
|
|
||||||
// Pod Oeprator
|
// Oeprator
|
||||||
adminUser string
|
|
||||||
adminPass string
|
|
||||||
adminName string
|
adminName string
|
||||||
adminEmail string
|
adminEmail string
|
||||||
|
|
||||||
@@ -41,9 +39,7 @@ var (
|
|||||||
resultsPerPage int
|
resultsPerPage int
|
||||||
|
|
||||||
// Secrets
|
// Secrets
|
||||||
apiSigningKey string
|
|
||||||
cookieSecret string
|
cookieSecret string
|
||||||
magiclinkSecret string
|
|
||||||
|
|
||||||
// Email Setitngs
|
// Email Setitngs
|
||||||
smtpHost string
|
smtpHost string
|
||||||
@@ -54,8 +50,6 @@ var (
|
|||||||
|
|
||||||
// Timeouts
|
// Timeouts
|
||||||
sessionExpiry time.Duration
|
sessionExpiry time.Duration
|
||||||
sessionCacheTTL time.Duration
|
|
||||||
apiSessionTime time.Duration
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -64,8 +58,8 @@ func init() {
|
|||||||
flag.BoolVarP(&version, "version", "v", false, "display version information")
|
flag.BoolVarP(&version, "version", "v", false, "display version information")
|
||||||
|
|
||||||
// Basic options
|
// Basic options
|
||||||
flag.StringVarP(&name, "name", "n", internal.DefaultName, "set the pod's name")
|
flag.StringVarP(&name, "name", "n", internal.DefaultName, "set the instance name")
|
||||||
flag.StringVarP(&description, "description", "m", internal.DefaultMetaDescription, "set the pod's description")
|
flag.StringVarP(&description, "description", "m", internal.DefaultMetaDescription, "set the instance description")
|
||||||
flag.StringVarP(&data, "data", "d", internal.DefaultData, "data directory")
|
flag.StringVarP(&data, "data", "d", internal.DefaultData, "data directory")
|
||||||
flag.StringVarP(&store, "store", "s", internal.DefaultStore, "store to use")
|
flag.StringVarP(&store, "store", "s", internal.DefaultStore, "store to use")
|
||||||
flag.StringVarP(&theme, "theme", "t", internal.DefaultTheme, "set the default theme")
|
flag.StringVarP(&theme, "theme", "t", internal.DefaultTheme, "set the default theme")
|
||||||
@@ -74,8 +68,6 @@ func init() {
|
|||||||
// Administration
|
// Administration
|
||||||
flag.StringVarP(&adminName, "admin-name", "N", internal.DefaultAdminName, "default admin user name")
|
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(&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
|
// Limits
|
||||||
flag.IntVarP(
|
flag.IntVarP(
|
||||||
@@ -84,18 +76,10 @@ func init() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Secrets
|
// Secrets
|
||||||
flag.StringVar(
|
|
||||||
&apiSigningKey, "api-signing-key", internal.DefaultAPISigningKey,
|
|
||||||
"secret to use for signing api tokens",
|
|
||||||
)
|
|
||||||
flag.StringVar(
|
flag.StringVar(
|
||||||
&cookieSecret, "cookie-secret", internal.DefaultCookieSecret,
|
&cookieSecret, "cookie-secret", internal.DefaultCookieSecret,
|
||||||
"cookie secret to use secure sessions",
|
"cookie secret to use secure sessions",
|
||||||
)
|
)
|
||||||
flag.StringVar(
|
|
||||||
&magiclinkSecret, "magiclink-secret", internal.DefaultMagicLinkSecret,
|
|
||||||
"magiclink secret to use for password reset tokens",
|
|
||||||
)
|
|
||||||
|
|
||||||
// Email Setitngs
|
// Email Setitngs
|
||||||
flag.StringVar(&smtpHost, "smtp-host", internal.DefaultSMTPHost, "SMTP Host to use for email sending")
|
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,
|
&sessionExpiry, "session-expiry", internal.DefaultSessionExpiry,
|
||||||
"timeout for sessions to expire",
|
"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 {
|
func flagNameFromEnvironmentName(s string) string {
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -18,7 +18,6 @@ require (
|
|||||||
github.com/blevesearch/bleve/v2 v2.0.1
|
github.com/blevesearch/bleve/v2 v2.0.1
|
||||||
github.com/creasty/defaults v1.5.1
|
github.com/creasty/defaults v1.5.1
|
||||||
github.com/dustin/go-humanize v1.0.0
|
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/glycerine/go-unsnap-stream v0.0.0-20210130063903-47dfef350d96 // indirect
|
||||||
github.com/go-mail/mail v2.3.1+incompatible
|
github.com/go-mail/mail v2.3.1+incompatible
|
||||||
github.com/go-shiori/go-readability v0.0.0-20201011032228-bdc871772408
|
github.com/go-shiori/go-readability v0.0.0-20201011032228-bdc871772408
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -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/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.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
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/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-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
|
||||||
github.com/glycerine/go-unsnap-stream v0.0.0-20210130063903-47dfef350d96 h1:rCXyLrgJ598XNj7KTqPzAvwTzlyvI+clqasoNfLQStE=
|
github.com/glycerine/go-unsnap-stream v0.0.0-20210130063903-47dfef350d96 h1:rCXyLrgJ598XNj7KTqPzAvwTzlyvI+clqasoNfLQStE=
|
||||||
|
|||||||
@@ -7,21 +7,12 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gabstv/merger"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrConfigPathMissing = errors.New("error: config file missing")
|
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
|
// Config contains the server configuration parameters
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
@@ -59,18 +50,6 @@ func (c *Config) IsLocalURL(url string) bool {
|
|||||||
}
|
}
|
||||||
func (c *Config) LocalURL() *url.URL { return c.baseURL }
|
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
|
// RandomSearchPrompt returns a random Search Prompt for display by the UI
|
||||||
func (c *Config) RandomSearchPrompt() string {
|
func (c *Config) RandomSearchPrompt() string {
|
||||||
n := rand.Int() % len(c.SearchPrompts)
|
n := rand.Int() % len(c.SearchPrompts)
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ const (
|
|||||||
// DefaultBaseURL is the default Base URL for the app used to construct feed URLs
|
// DefaultBaseURL is the default Base URL for the app used to construct feed URLs
|
||||||
DefaultBaseURL = "http://0.0.0.0:8000"
|
DefaultBaseURL = "http://0.0.0.0:8000"
|
||||||
|
|
||||||
// DefaultAdminXXX is the default admin user / pod operator
|
// DefaultAdminXXX is the default admin user / operator
|
||||||
DefaultAdminUser = "admin"
|
|
||||||
DefaultAdminPass = "admiN"
|
|
||||||
DefaultAdminName = "Administrator"
|
DefaultAdminName = "Administrator"
|
||||||
DefaultAdminEmail = "support@spyda.dev"
|
DefaultAdminEmail = "support@spyda.dev"
|
||||||
|
|
||||||
@@ -47,27 +45,15 @@ const (
|
|||||||
// DefaultResultsPerPage is the server's default results per page to display
|
// DefaultResultsPerPage is the server's default results per page to display
|
||||||
DefaultResultsPerPage = 10
|
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 is the server's default session expiry time
|
||||||
DefaultSessionExpiry = 240 * time.Hour // 10 days
|
DefaultSessionExpiry = 240 * time.Hour // 10 days
|
||||||
|
|
||||||
// DefaultMagicLinkSecret is the jwt magic link secret
|
|
||||||
DefaultMagicLinkSecret = InvalidConfigValue
|
|
||||||
|
|
||||||
// Default SMTP configuration
|
// Default SMTP configuration
|
||||||
DefaultSMTPHost = "smtp.gmail.com"
|
DefaultSMTPHost = "smtp.gmail.com"
|
||||||
DefaultSMTPPort = 587
|
DefaultSMTPPort = 587
|
||||||
DefaultSMTPUser = InvalidConfigValue
|
DefaultSMTPUser = InvalidConfigValue
|
||||||
DefaultSMTPPass = InvalidConfigValue
|
DefaultSMTPPass = InvalidConfigValue
|
||||||
DefaultSMTPFrom = 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 (
|
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 {
|
func WithAdminName(adminName string) Option {
|
||||||
return func(cfg *Config) error {
|
return func(cfg *Config) error {
|
||||||
cfg.AdminName = adminName
|
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 {
|
func WithAdminEmail(adminEmail string) Option {
|
||||||
return func(cfg *Config) error {
|
return func(cfg *Config) error {
|
||||||
cfg.AdminEmail = adminEmail
|
cfg.AdminEmail = adminEmail
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// Copyright 2020-present Yarn.social
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
|
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -97,10 +96,7 @@ func (s *Server) SupportHandler() httprouter.Handle {
|
|||||||
log.Infof("support message email sent for %s", email)
|
log.Infof("support message email sent for %s", email)
|
||||||
|
|
||||||
ctx.Error = false
|
ctx.Error = false
|
||||||
ctx.Message = fmt.Sprintf(
|
ctx.Message = "Thank you for your message! We will get back to you soon!"
|
||||||
"Thank you for your message! Pod operator %s will get back to you soon!",
|
|
||||||
s.config.AdminName,
|
|
||||||
)
|
|
||||||
s.render("error", w, ctx)
|
s.render("error", w, ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,6 @@
|
|||||||
<div>
|
<div>
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
<hr />
|
<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>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ func NormalizeURL(url string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RedirectRefererURL constructs a Redirect URL from the given Request URL
|
// 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
|
// 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.
|
// 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 {
|
func RedirectRefererURL(r *http.Request, conf *Config, defaultURL string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user