repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
dea5358
parent
dae626f
author
Eric Bower
date
2024-10-28 23:02:27 +0000 UTC
refactor(pgs): move filehandler to pgs folder
6 files changed,  +7, -10
M pgs/ssh.go
+4, -6
 1@@ -13,7 +13,6 @@ import (
 2 	"github.com/charmbracelet/wish"
 3 	"github.com/picosh/pico/db"
 4 	"github.com/picosh/pico/db/postgres"
 5-	uploadassets "github.com/picosh/pico/filehandlers/assets"
 6 	"github.com/picosh/pico/shared"
 7 	"github.com/picosh/pico/shared/storage"
 8 	wsh "github.com/picosh/pico/wish"
 9@@ -28,7 +27,7 @@ import (
10 	"github.com/picosh/utils"
11 )
12 
13-func createRouter(cfg *shared.ConfigSite, handler *uploadassets.UploadAssetHandler) proxy.Router {
14+func createRouter(handler *UploadAssetHandler) proxy.Router {
15 	return func(sh ssh.Handler, s ssh.Session) []wish.Middleware {
16 		return []wish.Middleware{
17 			pipe.Middleware(handler, ""),
18@@ -43,14 +42,14 @@ func createRouter(cfg *shared.ConfigSite, handler *uploadassets.UploadAssetHandl
19 	}
20 }
21 
22-func withProxy(cfg *shared.ConfigSite, handler *uploadassets.UploadAssetHandler, otherMiddleware ...wish.Middleware) ssh.Option {
23+func withProxy(handler *UploadAssetHandler, otherMiddleware ...wish.Middleware) ssh.Option {
24 	return func(server *ssh.Server) error {
25 		err := sftp.SSHOption(handler)(server)
26 		if err != nil {
27 			return err
28 		}
29 
30-		return proxy.WithProxy(createRouter(cfg, handler), otherMiddleware...)(server)
31+		return proxy.WithProxy(createRouter(handler), otherMiddleware...)(server)
32 	}
33 }
34 
35@@ -76,7 +75,7 @@ func StartSshServer() {
36 		return
37 	}
38 
39-	handler := uploadassets.NewUploadAssetHandler(
40+	handler := NewUploadAssetHandler(
41 		dbpool,
42 		cfg,
43 		st,
44@@ -103,7 +102,6 @@ func StartSshServer() {
45 		wish.WithPublicKeyAuth(sshAuth.PubkeyAuthHandler),
46 		tunkit.WithWebTunnel(webTunnel),
47 		withProxy(
48-			cfg,
49 			handler,
50 			promwish.Middleware(fmt.Sprintf("%s:%s", host, promPort), "pgs-ssh"),
51 		),
R filehandlers/assets/handler.go => pgs/uploader.go
+1, -1
1@@ -1,4 +1,4 @@
2-package uploadassets
3+package pgs
4 
5 import (
6 	"bytes"
R pgs/api.go => pgs/web.go
+1, -1
 1@@ -125,11 +125,11 @@ func (web *WebRouter) initRouters() {
 2 	rootRouter := http.NewServeMux()
 3 	rootRouter.HandleFunc("GET /check", web.checkHandler)
 4 	rootRouter.Handle("GET /main.css", web.serveFile("main.css", "text/css"))
 5-	rootRouter.Handle("GET /card.png", web.serveFile("card.png", "image/png"))
 6 	rootRouter.Handle("GET /favicon-16x16.png", web.serveFile("favicon-16x16.png", "image/png"))
 7 	rootRouter.Handle("GET /apple-touch-icon.png", web.serveFile("apple-touch-icon.png", "image/png"))
 8 	rootRouter.Handle("GET /favicon.ico", web.serveFile("favicon.ico", "image/x-icon"))
 9 	rootRouter.Handle("GET /robots.txt", web.serveFile("robots.txt", "text/plain"))
10+
11 	rootRouter.Handle("GET /rss/updated", web.createRssHandler("updated_at"))
12 	rootRouter.Handle("GET /rss", web.createRssHandler("created_at"))
13 	rootRouter.Handle("GET /{$}", web.createPageHandler("html/marketing.page.tmpl"))
R pgs/api_asset_handler.go => pgs/web_asset_handler.go
+0, -0
R pgs/api_test.go => pgs/web_test.go
+0, -0
M pgs/wish.go
+1, -2
 1@@ -10,7 +10,6 @@ import (
 2 	"github.com/charmbracelet/wish"
 3 	bm "github.com/charmbracelet/wish/bubbletea"
 4 	"github.com/picosh/pico/db"
 5-	uploadassets "github.com/picosh/pico/filehandlers/assets"
 6 	"github.com/picosh/pico/tui/common"
 7 	sendutils "github.com/picosh/send/utils"
 8 	"github.com/picosh/utils"
 9@@ -63,7 +62,7 @@ func flagCheck(cmd *flag.FlagSet, posArg string, cmdArgs []string) bool {
10 	return true
11 }
12 
13-func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
14+func WishMiddleware(handler *UploadAssetHandler) wish.Middleware {
15 	dbpool := handler.DBPool
16 	log := handler.Cfg.Logger
17 	cfg := handler.Cfg