repos / pico

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

commit
f5638be
parent
040a7d3
author
Eric Bower
date
2022-08-03 18:57:08 +0000 UTC
refactor: db -> sql and wish/cms/db -> db

It doesn't make sense to have such an important and all encompasing
package such as `wish/cms/db` to live buried in the cms code.
39 files changed,  +45, -45
M Makefile
+13, -13
 1@@ -43,28 +43,28 @@ format:
 2 .PHONY: format
 3 
 4 create:
 5-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) < ./db/setup.sql
 6+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) < ./sql/setup.sql
 7 .PHONY: create
 8 
 9 teardown:
10-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/teardown.sql
11+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/teardown.sql
12 .PHONY: teardown
13 
14 migrate:
15-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220310_init.sql
16-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220422_add_desc_to_user_and_post.sql
17-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220426_add_index_for_filename.sql
18-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220427_username_to_lower.sql
19-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220523_timestamp_with_tz.sql
20-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220721_analytics.sql
21-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220722_post_hidden.sql
22-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220727_post_change_post_contraints.sql
23-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220730_post_change_filename_to_slug.sql
24-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220801_add_post_tags.sql
25+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220310_init.sql
26+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220422_add_desc_to_user_and_post.sql
27+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220426_add_index_for_filename.sql
28+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220427_username_to_lower.sql
29+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220523_timestamp_with_tz.sql
30+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220721_analytics.sql
31+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220722_post_hidden.sql
32+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220727_post_change_post_contraints.sql
33+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220730_post_change_filename_to_slug.sql
34+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220801_add_post_tags.sql
35 .PHONY: migrate
36 
37 latest:
38-	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./db/migrations/20220801_add_post_tags.sql
39+	docker exec -i $(DB_CONTAINER) psql -U $(PGUSER) -d $(PGDATABASE) < ./sql/migrations/20220801_add_post_tags.sql
40 .PHONY: latest
41 
42 psql:
M cmd/lists/ssh/main.go
+1, -1
 1@@ -8,11 +8,11 @@ import (
 2 	"syscall"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db/postgres"
 6 	"git.sr.ht/~erock/pico/filehandlers"
 7 	"git.sr.ht/~erock/pico/lists"
 8 	"git.sr.ht/~erock/pico/shared"
 9 	"git.sr.ht/~erock/pico/wish/cms"
10-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
11 	"git.sr.ht/~erock/pico/wish/proxy"
12 	"git.sr.ht/~erock/pico/wish/send/scp"
13 	"git.sr.ht/~erock/pico/wish/send/sftp"
M cmd/pastes/ssh/main.go
+1, -1
 1@@ -11,11 +11,11 @@ import (
 2 	"syscall"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db/postgres"
 6 	"git.sr.ht/~erock/pico/filehandlers"
 7 	"git.sr.ht/~erock/pico/pastes"
 8 	"git.sr.ht/~erock/pico/shared"
 9 	"git.sr.ht/~erock/pico/wish/cms"
10-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
11 	"git.sr.ht/~erock/pico/wish/proxy"
12 	"git.sr.ht/~erock/pico/wish/send/scp"
13 	"git.sr.ht/~erock/pico/wish/send/sftp"
M cmd/prose/ssh/main.go
+1, -1
 1@@ -8,11 +8,11 @@ import (
 2 	"syscall"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db/postgres"
 6 	"git.sr.ht/~erock/pico/filehandlers"
 7 	"git.sr.ht/~erock/pico/prose"
 8 	"git.sr.ht/~erock/pico/shared"
 9 	"git.sr.ht/~erock/pico/wish/cms"
10-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
11 	"git.sr.ht/~erock/pico/wish/proxy"
12 	"git.sr.ht/~erock/pico/wish/send/scp"
13 	"git.sr.ht/~erock/pico/wish/send/sftp"
M cmd/scripts/dates/dates.go
+2, -2
 1@@ -7,11 +7,11 @@ import (
 2 	"os"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/lists"
 8 	"git.sr.ht/~erock/pico/prose"
 9 	"git.sr.ht/~erock/pico/wish/cms/config"
10-	"git.sr.ht/~erock/pico/wish/cms/db"
11-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
12 	"go.uber.org/zap"
13 )
14 
M cmd/scripts/migrate/migrate.go
+2, -2
 1@@ -7,9 +7,9 @@ import (
 2 	"log"
 3 	"os"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/wish/cms/config"
 8-	"git.sr.ht/~erock/pico/wish/cms/db"
 9-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
10 	"go.uber.org/zap"
11 )
12 
M cmd/scripts/tags/tags.go
+2, -2
 1@@ -5,10 +5,10 @@ import (
 2 	"log"
 3 	"os"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/prose"
 8 	"git.sr.ht/~erock/pico/wish/cms/config"
 9-	"git.sr.ht/~erock/pico/wish/cms/db"
10-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
11 	"go.uber.org/zap"
12 )
13 
R wish/cms/db/db.go => db/db.go
+0, -0
R wish/cms/db/postgres/storage.go => db/postgres/storage.go
+1, -1
 1@@ -9,8 +9,8 @@ import (
 2 	"strings"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/wish/cms/config"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	_ "github.com/lib/pq"
 9 	"go.uber.org/zap"
10 	"golang.org/x/exp/slices"
R wish/cms/db/util.go => db/util.go
+0, -0
M filehandlers/post_handler.go
+1, -1
 1@@ -6,8 +6,8 @@ import (
 2 	"strings"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/shared"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"git.sr.ht/~erock/pico/wish/cms/util"
 9 	"git.sr.ht/~erock/pico/wish/send/utils"
10 	"github.com/gliderlabs/ssh"
M lists/api.go
+2, -2
 1@@ -11,9 +11,9 @@ import (
 2 	"strings"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/shared"
 8-	"git.sr.ht/~erock/pico/wish/cms/db"
 9-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
10 	"github.com/gorilla/feeds"
11 	"golang.org/x/exp/slices"
12 )
M lists/gemini/gemini.go
+2, -2
 1@@ -16,10 +16,10 @@ import (
 2 	"git.sr.ht/~adnano/go-gemini"
 3 	"git.sr.ht/~adnano/go-gemini/certificate"
 4 	feeds "git.sr.ht/~aw/gorilla-feeds"
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/lists"
 8 	"git.sr.ht/~erock/pico/shared"
 9-	"git.sr.ht/~erock/pico/wish/cms/db"
10-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
11 	"golang.org/x/exp/slices"
12 )
13 
M lists/gemini/router.go
+1, -1
 1@@ -5,8 +5,8 @@ import (
 2 	"regexp"
 3 
 4 	"git.sr.ht/~adnano/go-gemini"
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/shared"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"go.uber.org/zap"
 9 )
10 
M pastes/api.go
+2, -2
 1@@ -9,9 +9,9 @@ import (
 2 	"strings"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/shared"
 8-	"git.sr.ht/~erock/pico/wish/cms/db"
 9-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
10 )
11 
12 type PageData struct {
M pastes/cron.go
+1, -1
 1@@ -3,8 +3,8 @@ package pastes
 2 import (
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/shared"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 )
 9 
10 func deleteExpiredPosts(cfg *shared.ConfigSite, dbpool db.DB) error {
M prose/api.go
+2, -2
 1@@ -11,9 +11,9 @@ import (
 2 	"strings"
 3 	"time"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/shared"
 8-	"git.sr.ht/~erock/pico/wish/cms/db"
 9-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
10 	"github.com/gorilla/feeds"
11 	"golang.org/x/exp/slices"
12 )
M shared/router.go
+1, -1
1@@ -8,7 +8,7 @@ import (
2 	"regexp"
3 	"strings"
4 
5-	"git.sr.ht/~erock/pico/wish/cms/db"
6+	"git.sr.ht/~erock/pico/db"
7 	"go.uber.org/zap"
8 )
9 
R db/migrations/20220310_init.sql => sql/migrations/20220310_init.sql
+0, -0
R db/migrations/20220422_add_desc_to_user_and_post.sql => sql/migrations/20220422_add_desc_to_user_and_post.sql
+0, -0
R db/migrations/20220426_add_index_for_filename.sql => sql/migrations/20220426_add_index_for_filename.sql
+0, -0
R db/migrations/20220427_username_to_lower.sql => sql/migrations/20220427_username_to_lower.sql
+0, -0
R db/migrations/20220523_timestamp_with_tz.sql => sql/migrations/20220523_timestamp_with_tz.sql
+0, -0
R db/migrations/20220721_analytics.sql => sql/migrations/20220721_analytics.sql
+0, -0
R db/migrations/20220722_post_hidden.sql => sql/migrations/20220722_post_hidden.sql
+0, -0
R db/migrations/20220727_post_change_post_contraints.sql => sql/migrations/20220727_post_change_post_contraints.sql
+0, -0
R db/migrations/20220730_post_change_filename_to_slug.sql => sql/migrations/20220730_post_change_filename_to_slug.sql
+0, -0
R db/migrations/20220801_add_post_tags.sql => sql/migrations/20220801_add_post_tags.sql
+0, -0
R db/setup.sql => sql/setup.sql
+0, -0
R db/teardown.sql => sql/teardown.sql
+0, -0
M wish/cms/cms.go
+2, -2
 1@@ -4,9 +4,9 @@ import (
 2 	"errors"
 3 	"fmt"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6+	"git.sr.ht/~erock/pico/db/postgres"
 7 	"git.sr.ht/~erock/pico/wish/cms/config"
 8-	"git.sr.ht/~erock/pico/wish/cms/db"
 9-	"git.sr.ht/~erock/pico/wish/cms/db/postgres"
10 	"git.sr.ht/~erock/pico/wish/cms/ui/account"
11 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
12 	"git.sr.ht/~erock/pico/wish/cms/ui/info"
M wish/cms/ui/account/create.go
+1, -1
 1@@ -5,8 +5,8 @@ import (
 2 	"fmt"
 3 	"strings"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/wish/cms/config"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
 9 	"github.com/charmbracelet/bubbles/spinner"
10 	input "github.com/charmbracelet/bubbles/textinput"
M wish/cms/ui/createkey/create.go
+1, -1
 1@@ -3,8 +3,8 @@ package createkey
 2 import (
 3 	"strings"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/wish/cms/config"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
 9 	"github.com/charmbracelet/bubbles/spinner"
10 	input "github.com/charmbracelet/bubbles/textinput"
M wish/cms/ui/info/info.go
+1, -1
 1@@ -1,8 +1,8 @@
 2 package info
 3 
 4 import (
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/wish/cms/config"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
 9 	tea "github.com/charmbracelet/bubbletea"
10 )
M wish/cms/ui/keys/keys.go
+1, -1
 1@@ -3,8 +3,8 @@ package keys
 2 import (
 3 	"fmt"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/wish/cms/config"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
 9 	"git.sr.ht/~erock/pico/wish/cms/ui/createkey"
10 	pager "github.com/charmbracelet/bubbles/paginator"
M wish/cms/ui/keys/keyview.go
+1, -1
1@@ -4,7 +4,7 @@ import (
2 	"fmt"
3 	"strings"
4 
5-	"git.sr.ht/~erock/pico/wish/cms/db"
6+	"git.sr.ht/~erock/pico/db"
7 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
8 	"golang.org/x/crypto/ssh"
9 )
M wish/cms/ui/posts/post_view.go
+1, -1
 1@@ -3,8 +3,8 @@ package posts
 2 import (
 3 	"fmt"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/wish/cms/config"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
 9 )
10 
M wish/cms/ui/posts/posts.go
+1, -1
 1@@ -7,8 +7,8 @@ import (
 2 	"github.com/charmbracelet/bubbles/spinner"
 3 	tea "github.com/charmbracelet/bubbletea"
 4 
 5+	"git.sr.ht/~erock/pico/db"
 6 	"git.sr.ht/~erock/pico/wish/cms/config"
 7-	"git.sr.ht/~erock/pico/wish/cms/db"
 8 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
 9 
10 	"go.uber.org/zap"
M wish/cms/ui/username/username.go
+1, -1
1@@ -5,7 +5,7 @@ import (
2 	"fmt"
3 	"strings"
4 
5-	"git.sr.ht/~erock/pico/wish/cms/db"
6+	"git.sr.ht/~erock/pico/db"
7 	"git.sr.ht/~erock/pico/wish/cms/ui/common"
8 	"github.com/charmbracelet/bubbles/spinner"
9 	input "github.com/charmbracelet/bubbles/textinput"