Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: TUI only accessible via pico.sh #122

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 0 additions & 41 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ MINIO_PROMETHEUS_AUTH_TYPE=public
MINIO_PROMETHEUS_URL=
MINIO_PROMETHEUS_JOB_ID=minio

USE_IMGPROXY=1
IMGPROXY_DOMAIN=imgproxy.dev.pico.sh
IMGPROXY_URL=http://imgproxy:8080
IMGPROXY_ALLOWED_SOURCES=s3://,local://
Expand All @@ -27,27 +26,6 @@ AWS_SECRET_ACCESS_KEY=$MINIO_ROOT_PASSWORD
IMGPROXY_PROMETHEUS_BIND=:8081
IMGPROXY_PROMETHEUS_NAMESPACE=imgproxy

LISTS_CADDYFILE=./caddy/Caddyfile
LISTS_V4=
LISTS_V6=
LISTS_HTTP_V4=$LISTS_V4:80
LISTS_HTTP_V6=[$LISTS_V6]:80
LISTS_HTTPS_V4=$LISTS_V4:443
LISTS_HTTPS_V6=[$LISTS_V6]:443
LISTS_SSH_V4=$LISTS_V4:22
LISTS_SSH_V6=[$LISTS_V6]:22
LISTS_HOST=
LISTS_SSH_PORT=2222
LISTS_WEB_PORT=3000
LISTS_PROM_PORT=9222
LISTS_DOMAIN=lists.dev.pico.sh:3000
LISTS_EMAIL=hello@pico.sh
LISTS_SUBDOMAINS=1
LISTS_CUSTOMDOMAINS=1
LISTS_PROTOCOL=http
LISTS_ALLOW_REGISTER=1
LISTS_DEBUG=1

PASTES_CADDYFILE=./caddy/Caddyfile
PASTES_V4=
PASTES_V6=
Expand All @@ -62,11 +40,7 @@ PASTES_SSH_PORT=2222
PASTES_WEB_PORT=3000
PASTES_PROM_PORT=9222
PASTES_DOMAIN=pastes.dev.pico.sh:3001
PASTES_EMAIL=hello@pico.sh
PASTES_SUBDOMAINS=1
PASTES_CUSTOMDOMAINS=1
PASTES_PROTOCOL=http
PASTES_ALLOW_REGISTER=1
PASTES_DEBUG=1

PROSE_CADDYFILE=./caddy/Caddyfile
Expand All @@ -83,11 +57,7 @@ PROSE_SSH_PORT=2222
PROSE_WEB_PORT=3000
PROSE_PROM_PORT=9222
PROSE_DOMAIN=prose.dev.pico.sh:3002
PROSE_EMAIL=hello@pico.sh
PROSE_SUBDOMAINS=1
PROSE_CUSTOMDOMAINS=1
PROSE_PROTOCOL=http
PROSE_ALLOW_REGISTER=1
PROSE_DEBUG=1

IMGS_CADDYFILE=./caddy/Caddyfile
Expand All @@ -105,10 +75,7 @@ IMGS_WEB_PORT=3000
IMGS_PROM_PORT=9222
IMGS_DOMAIN=imgs.dev.pico.sh:3003
IMGS_EMAIL=hello@pico.sh
IMGS_SUBDOMAINS=1
IMGS_CUSTOMDOMAINS=1
IMGS_PROTOCOL=http
IMGS_ALLOW_REGISTER=1
IMGS_STORAGE_DIR=.storage
IMGS_DEBUG=1

Expand All @@ -127,11 +94,7 @@ FEEDS_SSH_PORT=2222
FEEDS_WEB_PORT=3000
FEEDS_PROM_PORT=9222
FEEDS_DOMAIN=feeds.dev.pico.sh:3004
FEEDS_EMAIL=hello@pico.sh
FEEDS_SUBDOMAINS=1
FEEDS_CUSTOMDOMAINS=1
FEEDS_PROTOCOL=http
FEEDS_ALLOW_REGISTER=1
FEEDS_DEBUG=1

PGS_CADDYFILE=./caddy/Caddyfile
Expand All @@ -148,11 +111,7 @@ PGS_SSH_PORT=2222
PGS_WEB_PORT=3000
PGS_PROM_PORT=9222
PGS_DOMAIN=pgs.dev.pico.sh:3005
PGS_EMAIL=hello@pico.sh
PGS_SUBDOMAINS=1
PGS_CUSTOMDOMAINS=1
PGS_PROTOCOL=http
PGS_ALLOW_REGISTER=1
PGS_STORAGE_DIR=.storage
PGS_DEBUG=1

Expand Down
3 changes: 1 addition & 2 deletions cmd/scripts/clean-object-store/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/picosh/pico/pgs"
"github.com/picosh/pico/shared"
"github.com/picosh/pico/shared/storage"
"github.com/picosh/pico/wish/cms/config"
)

func bail(err error) {
Expand All @@ -35,7 +34,7 @@ func main() {
}
logger := slog.Default()

picoCfg := config.NewConfigCms()
picoCfg := shared.NewConfigSite()
picoCfg.Logger = logger
picoCfg.DbURL = os.Getenv("DATABASE_URL")
picoCfg.MinioURL = os.Getenv("MINIO_URL")
Expand Down
3 changes: 1 addition & 2 deletions cmd/scripts/dates/dates.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/picosh/pico/db"
"github.com/picosh/pico/db/postgres"
"github.com/picosh/pico/shared"
"github.com/picosh/pico/wish/cms/config"
)

func findPosts(dbpool *sql.DB) ([]*db.Post, error) {
Expand Down Expand Up @@ -59,7 +58,7 @@ func updateDates(tx *sql.Tx, postID string, date *time.Time) error {
func main() {
logger := slog.Default()

picoCfg := config.NewConfigCms()
picoCfg := shared.NewConfigSite()
picoCfg.Logger = logger
picoCfg.DbURL = os.Getenv("DATABASE_URL")
picoDb := postgres.NewDB(picoCfg.DbURL, picoCfg.Logger)
Expand Down
4 changes: 2 additions & 2 deletions cmd/scripts/file-size-sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"

"github.com/picosh/pico/db/postgres"
"github.com/picosh/pico/wish/cms/config"
"github.com/picosh/pico/shared"
)

func bail(err error) {
Expand All @@ -18,7 +18,7 @@ func bail(err error) {
func main() {
logger := slog.Default()

picoCfg := config.NewConfigCms()
picoCfg := shared.NewConfigSite()
picoCfg.Logger = logger
picoCfg.DbURL = os.Getenv("DATABASE_URL")
picoDb := postgres.NewDB(picoCfg.DbURL, picoCfg.Logger)
Expand Down
8 changes: 4 additions & 4 deletions cmd/scripts/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/picosh/pico/db"
"github.com/picosh/pico/db/postgres"
"github.com/picosh/pico/wish/cms/config"
"github.com/picosh/pico/shared"
)

func findPosts(dbpool *sql.DB) ([]*db.Post, error) {
Expand Down Expand Up @@ -101,17 +101,17 @@ type ConflictData struct {
func main() {
logger := slog.Default()

listsCfg := config.NewConfigCms()
listsCfg := shared.NewConfigSite()
listsCfg.Logger = logger
listsCfg.DbURL = os.Getenv("LISTS_DB_URL")
listsDb := postgres.NewDB(listsCfg.DbURL, listsCfg.Logger)

proseCfg := config.NewConfigCms()
proseCfg := shared.NewConfigSite()
proseCfg.DbURL = os.Getenv("PROSE_DB_URL")
proseCfg.Logger = logger
proseDb := postgres.NewDB(proseCfg.DbURL, proseCfg.Logger)

picoCfg := config.NewConfigCms()
picoCfg := shared.NewConfigSite()
picoCfg.Logger = logger
picoCfg.DbURL = os.Getenv("PICO_DB_URL")
picoDb := postgres.NewDB(picoCfg.DbURL, picoCfg.Logger)
Expand Down
3 changes: 1 addition & 2 deletions cmd/scripts/shasum/shasum.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (

"github.com/picosh/pico/db/postgres"
"github.com/picosh/pico/shared"
"github.com/picosh/pico/wish/cms/config"
)

func main() {
logger := slog.Default()
picoCfg := config.NewConfigCms()
picoCfg := shared.NewConfigSite()
picoCfg.Logger = logger
picoCfg.DbURL = os.Getenv("DATABASE_URL")
picoDb := postgres.NewDB(picoCfg.DbURL, picoCfg.Logger)
Expand Down
3 changes: 1 addition & 2 deletions cmd/scripts/tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/picosh/pico/db"
"github.com/picosh/pico/db/postgres"
"github.com/picosh/pico/shared"
"github.com/picosh/pico/wish/cms/config"
)

func findPosts(dbpool *sql.DB) ([]*db.Post, error) {
Expand Down Expand Up @@ -52,7 +51,7 @@ func findPosts(dbpool *sql.DB) ([]*db.Post, error) {
func main() {
logger := slog.Default()

picoCfg := config.NewConfigCms()
picoCfg := shared.NewConfigSite()
picoCfg.Logger = logger
picoCfg.DbURL = os.Getenv("DATABASE_URL")
picoDb := postgres.NewDB(picoCfg.DbURL, picoCfg.Logger)
Expand Down
1 change: 0 additions & 1 deletion feeds/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func StartApiServer() {
"Starting server on port",
"port", cfg.Port,
"domain", cfg.Domain,
"email", cfg.Email,
)

logger.Error(http.ListenAndServe(portStr, router).Error())
Expand Down
46 changes: 14 additions & 32 deletions feeds/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,34 @@ package feeds

import (
"github.com/picosh/pico/shared"
"github.com/picosh/pico/wish/cms/config"
)

func NewConfigSite() *shared.ConfigSite {
debug := shared.GetEnv("FEEDS_DEBUG", "0")
domain := shared.GetEnv("FEEDS_DOMAIN", "feeds.sh")
email := shared.GetEnv("FEEDS_EMAIL", "hello@feeds.sh")
subdomains := shared.GetEnv("FEEDS_SUBDOMAINS", "0")
customdomains := shared.GetEnv("FEEDS_CUSTOMDOMAINS", "0")
port := shared.GetEnv("FEEDS_WEB_PORT", "3000")
protocol := shared.GetEnv("FEEDS_PROTOCOL", "https")
allowRegister := shared.GetEnv("FEEDS_ALLOW_REGISTER", "1")
storageDir := shared.GetEnv("IMGS_STORAGE_DIR", ".storage")
minioURL := shared.GetEnv("MINIO_URL", "")
minioUser := shared.GetEnv("MINIO_ROOT_USER", "")
minioPass := shared.GetEnv("MINIO_ROOT_PASSWORD", "")
dbURL := shared.GetEnv("DATABASE_URL", "")
sendgridKey := shared.GetEnv("SENDGRID_API_KEY", "")
useImgProxy := shared.GetEnv("USE_IMGPROXY", "1")

intro := "To get started, enter a username.\n"
intro += "To learn next steps go to our docs at https://pico.sh/feeds\n"

return &shared.ConfigSite{
Debug: debug == "1",
SubdomainsEnabled: subdomains == "1",
CustomdomainsEnabled: customdomains == "1",
UseImgProxy: useImgProxy == "1",
SendgridKey: sendgridKey,
ConfigCms: config.ConfigCms{
Domain: domain,
Email: email,
Port: port,
Protocol: protocol,
DbURL: dbURL,
StorageDir: storageDir,
MinioURL: minioURL,
MinioUser: minioUser,
MinioPass: minioPass,
Description: "An rss-to-email digest service for hackers",
IntroText: intro,
Space: "feeds",
AllowedExt: []string{".txt"},
HiddenPosts: []string{"_header.txt", "_readme.txt"},
Logger: shared.CreateLogger(debug == "1"),
AllowRegister: allowRegister == "1",
},
Debug: debug == "1",
SendgridKey: sendgridKey,
Domain: domain,
Port: port,
Protocol: protocol,
DbURL: dbURL,
StorageDir: storageDir,
MinioURL: minioURL,
MinioUser: minioUser,
MinioPass: minioPass,
Space: "feeds",
AllowedExt: []string{".txt"},
HiddenPosts: []string{"_header.txt", "_readme.txt"},
Logger: shared.CreateLogger(debug == "1"),
}
}
2 changes: 1 addition & 1 deletion feeds/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (f *Fetcher) SendEmail(username, email string, subject string, msg *MsgBody
return fmt.Errorf("(%s) does not have an email associated with their feed post", username)
}

from := mail.NewEmail("team pico", f.cfg.Email)
from := mail.NewEmail("team pico", shared.DefaultEmail)
to := mail.NewEmail(username, email)

// f.cfg.Logger.Infof("message body (%s)", plainTextContent)
Expand Down
8 changes: 4 additions & 4 deletions feeds/html/marketing.page.tmpl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{{template "base" .}}

{{define "title"}}{{.Site.Domain}} -- an rss email notification service{{end}}
{{define "title"}}{{.Site.Domain}} -- An rss email notification service{{end}}

{{define "meta"}}
<meta name="description" content="an rss email notification service" />
<meta name="description" content="An rss email notification service" />

<meta property="og:type" content="website">
<meta property="og:site_name" content="{{.Site.Domain}}">
<meta property="og:url" content="https://{{.Site.Domain}}">
<meta property="og:title" content="{{.Site.Domain}}">
<meta property="og:description" content="an rss email notification service">
<meta property="og:description" content="An rss email notification service">

<meta name="twitter:card" content="summary" />
<meta property="twitter:url" content="https://{{.Site.Domain}}">
<meta property="twitter:title" content="{{.Site.Domain}}">
<meta property="twitter:description" content="an rss email notification service">
<meta property="twitter:description" content="An rss email notification service">
<meta name="twitter:image" content="https://{{.Site.Domain}}/card.png" />
<meta name="twitter:image:src" content="https://{{.Site.Domain}}/card.png" />

Expand Down
4 changes: 1 addition & 3 deletions feeds/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import (
"github.com/charmbracelet/promwish"
"github.com/charmbracelet/ssh"
"github.com/charmbracelet/wish"
bm "github.com/charmbracelet/wish/bubbletea"
"github.com/picosh/pico/db/postgres"
"github.com/picosh/pico/filehandlers"
"github.com/picosh/pico/shared"
"github.com/picosh/pico/shared/storage"
wsh "github.com/picosh/pico/wish"
"github.com/picosh/pico/wish/cms"
"github.com/picosh/send/list"
"github.com/picosh/send/pipe"
"github.com/picosh/send/proxy"
Expand All @@ -41,7 +39,7 @@ func createRouter(handler *filehandlers.FileHandlerRouter) proxy.Router {
scp.Middleware(handler),
wishrsync.Middleware(handler),
auth.Middleware(handler),
wsh.PtyMdw(bm.Middleware(cms.Middleware(&handler.Cfg.ConfigCms, handler.Cfg))),
wsh.PtyMdw(wsh.DeprecatedNotice()),
wsh.LogMiddleware(handler.GetLogger()),
}
}
Expand Down
1 change: 0 additions & 1 deletion imgs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ func StartApiServer() {
"Starting server on port",
"port", cfg.Port,
"domain", cfg.Domain,
"email", cfg.Email,
)

logger.Error(http.ListenAndServe(portStr, router).Error())
Expand Down