chore: update wish

supply protocol from environment variable (http or https)
This commit is contained in:
Eric Bower 2022-07-13 23:34:54 -04:00
parent 407f38cd7c
commit 23e186d46c
No known key found for this signature in database
GPG key ID: 7A51A47D76D3FD02
3 changed files with 13 additions and 5 deletions

4
go.mod
View file

@ -2,8 +2,10 @@ module git.sr.ht/~erock/pastes.sh
go 1.18 go 1.18
// replace git.sr.ht/~erock/wish => /home/erock/pico/wish
require ( require (
git.sr.ht/~erock/wish v0.0.0-20220714031334-670ce9b92be6 git.sr.ht/~erock/wish v0.0.0-20220714033621-620d4ba1aa5d
github.com/alecthomas/chroma v0.10.0 github.com/alecthomas/chroma v0.10.0
github.com/charmbracelet/wish v0.5.0 github.com/charmbracelet/wish v0.5.0
github.com/gliderlabs/ssh v0.3.4 github.com/gliderlabs/ssh v0.3.4

4
go.sum
View file

@ -6,6 +6,10 @@ git.sr.ht/~erock/wish v0.0.0-20220714010731-7947bf10c388 h1:goL6fa09OPdg+LB2ceJG
git.sr.ht/~erock/wish v0.0.0-20220714010731-7947bf10c388/go.mod h1:QZKk7m9jc9iXah90daPGhQkSfNfxSVvpb6nfVeI+MM0= git.sr.ht/~erock/wish v0.0.0-20220714010731-7947bf10c388/go.mod h1:QZKk7m9jc9iXah90daPGhQkSfNfxSVvpb6nfVeI+MM0=
git.sr.ht/~erock/wish v0.0.0-20220714031334-670ce9b92be6 h1:MXCqjuHgZ081oVyBb4JO6jMyKLA3HTsvOVJJBFF3L/Y= git.sr.ht/~erock/wish v0.0.0-20220714031334-670ce9b92be6 h1:MXCqjuHgZ081oVyBb4JO6jMyKLA3HTsvOVJJBFF3L/Y=
git.sr.ht/~erock/wish v0.0.0-20220714031334-670ce9b92be6/go.mod h1:QZKk7m9jc9iXah90daPGhQkSfNfxSVvpb6nfVeI+MM0= git.sr.ht/~erock/wish v0.0.0-20220714031334-670ce9b92be6/go.mod h1:QZKk7m9jc9iXah90daPGhQkSfNfxSVvpb6nfVeI+MM0=
git.sr.ht/~erock/wish v0.0.0-20220714031736-47b0eaae6231 h1:o5oGYrwl3Qpug5DnjPa3+m/EsWhN2zZveYqHQVvbUe4=
git.sr.ht/~erock/wish v0.0.0-20220714031736-47b0eaae6231/go.mod h1:QZKk7m9jc9iXah90daPGhQkSfNfxSVvpb6nfVeI+MM0=
git.sr.ht/~erock/wish v0.0.0-20220714033621-620d4ba1aa5d h1:M/Ub98kMgfAZ/4jjbSLsc58TLqYGYzmMr0bxsSyUvgc=
git.sr.ht/~erock/wish v0.0.0-20220714033621-620d4ba1aa5d/go.mod h1:QZKk7m9jc9iXah90daPGhQkSfNfxSVvpb6nfVeI+MM0=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=

View file

@ -28,6 +28,7 @@ func NewConfigSite() *ConfigSite {
subdomains := GetEnv("PASTES_SUBDOMAINS", "0") subdomains := GetEnv("PASTES_SUBDOMAINS", "0")
port := GetEnv("PASTES_WEB_PORT", "3000") port := GetEnv("PASTES_WEB_PORT", "3000")
dbURL := GetEnv("DATABASE_URL", "") dbURL := GetEnv("DATABASE_URL", "")
protocol := GetEnv("PASTES_PROTOCOL", "https")
subdomainsEnabled := false subdomainsEnabled := false
if subdomains == "1" { if subdomains == "1" {
subdomainsEnabled = true subdomainsEnabled = true
@ -44,6 +45,7 @@ func NewConfigSite() *ConfigSite {
ConfigCms: config.ConfigCms{ ConfigCms: config.ConfigCms{
Domain: domain, Domain: domain,
Port: port, Port: port,
Protocol: protocol,
Email: email, Email: email,
DbURL: dbURL, DbURL: dbURL,
Description: "a pastebin for hackers.", Description: "a pastebin for hackers.",
@ -63,7 +65,7 @@ func (c *ConfigSite) GetSiteData() *SitePageData {
func (c *ConfigSite) BlogURL(username string) string { func (c *ConfigSite) BlogURL(username string) string {
if c.IsSubdomains() { if c.IsSubdomains() {
return fmt.Sprintf("//%s.%s", username, c.Domain) return fmt.Sprintf("%s://%s.%s", c.Protocol, username, c.Domain)
} }
return fmt.Sprintf("/%s", username) return fmt.Sprintf("/%s", username)
@ -72,7 +74,7 @@ func (c *ConfigSite) BlogURL(username string) string {
func (c *ConfigSite) PostURL(username, filename string) string { func (c *ConfigSite) PostURL(username, filename string) string {
fname := url.PathEscape(filename) fname := url.PathEscape(filename)
if c.IsSubdomains() { if c.IsSubdomains() {
return fmt.Sprintf("//%s.%s/%s", username, c.Domain, fname) return fmt.Sprintf("%s://%s.%s/%s", c.Protocol, username, c.Domain, fname)
} }
return fmt.Sprintf("/%s/%s", username, fname) return fmt.Sprintf("/%s/%s", username, fname)
@ -84,7 +86,7 @@ func (c *ConfigSite) IsSubdomains() bool {
func (c *ConfigSite) RssBlogURL(username string) string { func (c *ConfigSite) RssBlogURL(username string) string {
if c.IsSubdomains() { if c.IsSubdomains() {
return fmt.Sprintf("//%s.%s/rss", username, c.Domain) return fmt.Sprintf("%s://%s.%s/rss", c.Protocol, username, c.Domain)
} }
return fmt.Sprintf("/%s/rss", username) return fmt.Sprintf("/%s/rss", username)
@ -100,7 +102,7 @@ func (c *ConfigSite) HomeURL() string {
func (c *ConfigSite) ReadURL() string { func (c *ConfigSite) ReadURL() string {
if c.IsSubdomains() { if c.IsSubdomains() {
return fmt.Sprintf("https://%s/read", c.Domain) return fmt.Sprintf("%s://%s/read", c.Protocol, c.Domain)
} }
return "/read" return "/read"