Skip to content

Commit a81937b

Browse files
authored
Merge pull request #28 from Dan6erbond/develop
2 parents dd7c59d + aa02fe2 commit a81937b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1755
-105
lines changed

.github/workflows/docker-publish.yml

+3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ jobs:
3131
image:
3232
- ${{ github.repository }}-frontend
3333
- ${{ github.repository }}-server
34+
- ${{ github.repository }}-tagger
3435
include:
3536
- image: ${{ github.repository }}-frontend
3637
context: "."
3738
- image: ${{ github.repository }}-server
3839
context: "server"
40+
- image: ${{ github.repository }}-tagger
41+
context: "tagger"
3942
steps:
4043
- name: Checkout repository
4144
uses: actions/checkout@v3

.github/workflows/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ jobs:
4949
image:
5050
- ${{ github.repository }}-frontend
5151
- ${{ github.repository }}-server
52+
- ${{ github.repository }}-tagger
5253
include:
5354
- image: ${{ github.repository }}-frontend
5455
context: "."
5556
- image: ${{ github.repository }}-server
5657
context: "server"
58+
- image: ${{ github.repository }}-tagger
59+
context: "tagger"
5760
steps:
5861
- name: Checkout repository
5962
uses: actions/checkout@v3

docker-compose.dev.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: "3.8"
2+
3+
services:
4+
server:
5+
build:
6+
context: server
7+
volumes:
8+
- ./pb_data:/pb/pb_data
9+
environment:
10+
TAGGER_HOST: http://tagger:80
11+
ports:
12+
- 8080:8080
13+
frontend:
14+
build:
15+
context: .
16+
environment:
17+
POCKETBASE_URL: http://127.0.0.1:8080
18+
POCKETBASE_SERVER_URL: http://server:8080
19+
ports:
20+
- 3000:3000
21+
tagger:
22+
build:
23+
context: tagger
24+
environment:
25+
POCKETBASE_URL: http://server:8080
26+
env_file: ./tagger/.env
27+
ports:
28+
- 5001:80

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@emotion/server": "^11.10.0",
1414
"@mantine/carousel": "^6.0.10",
1515
"@mantine/core": "^6.0.10",
16+
"@mantine/dates": "^6.0.11",
1617
"@mantine/dropzone": "^6.0.10",
1718
"@mantine/form": "^6.0.10",
1819
"@mantine/hooks": "^6.0.10",
@@ -25,6 +26,7 @@
2526
"@types/react": "18.2.0",
2627
"@types/react-dom": "18.2.1",
2728
"axios": "^1.4.0",
29+
"dayjs": "^1.11.7",
2830
"embla-carousel-react": "^8.0.0-rc03",
2931
"eslint": "8.39.0",
3032
"eslint-config-next": "13.3.4",

server/go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ require (
4646
github.com/googleapis/gax-go/v2 v2.8.0 // indirect
4747
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4848
github.com/jmespath/go-jmespath v0.4.0 // indirect
49-
github.com/joho/godotenv v1.5.1 // indirect
49+
github.com/joho/godotenv v1.5.1
5050
github.com/josharian/intern v1.0.0 // indirect
5151
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
5252
github.com/klauspost/compress v1.16.5 // indirect
@@ -55,11 +55,11 @@ require (
5555
github.com/mattn/go-colorable v0.1.13 // indirect
5656
github.com/mattn/go-isatty v0.0.18 // indirect
5757
github.com/mattn/go-sqlite3 v1.14.16 // indirect
58-
github.com/meilisearch/meilisearch-go v0.24.0 // indirect
58+
github.com/meilisearch/meilisearch-go v0.24.0
5959
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
6060
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
6161
github.com/spf13/cast v1.5.0 // indirect
62-
github.com/spf13/cobra v1.7.0 // indirect
62+
github.com/spf13/cobra v1.7.0
6363
github.com/spf13/pflag v1.0.5 // indirect
6464
github.com/valyala/bytebufferpool v1.0.0 // indirect
6565
github.com/valyala/fasthttp v1.47.0 // indirect

server/go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,6 @@ github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP
10401040
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
10411041
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
10421042
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
1043-
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
10441043
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
10451044
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
10461045
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
@@ -1799,7 +1798,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
17991798
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
18001799
github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
18011800
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
1802-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
18031801
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
18041802
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
18051803
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=

server/main.go

+26-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
"github.com/pocketbase/pocketbase/core"
1010
"github.com/pocketbase/pocketbase/plugins/migratecmd"
1111

12-
// uncomment once you have at least one .go migration file in the "migrations" directory
1312
_ "github.com/Dan6erbond/share-me/migrations"
13+
"github.com/Dan6erbond/share-me/pkg/apis"
14+
"github.com/Dan6erbond/share-me/pkg/keys"
1415
"github.com/Dan6erbond/share-me/pkg/meilisearch"
16+
"github.com/Dan6erbond/share-me/pkg/tags"
1517
)
1618

1719
func main() {
@@ -52,6 +54,29 @@ func main() {
5254
return nil
5355
})
5456

57+
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
58+
err := keys.RegisterMiddleware(e)
59+
60+
if err != nil {
61+
return err
62+
}
63+
64+
err = keys.RegisterRoutes(e)
65+
66+
if err != nil {
67+
return err
68+
}
69+
70+
err = apis.RegisterFileRoutes(e)
71+
72+
return err
73+
})
74+
75+
if os.Getenv("TAGGER_HOST") != "" {
76+
tags.RegisterCommands(app, os.Getenv("TAGGER_HOST"))
77+
tags.RegisterHooks(app, os.Getenv("TAGGER_HOST"))
78+
}
79+
5580
if err := app.Start(); err != nil {
5681
log.Fatal(err)
5782
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package migrations
2+
3+
import (
4+
"encoding/json"
5+
6+
"github.com/pocketbase/dbx"
7+
"github.com/pocketbase/pocketbase/daos"
8+
m "github.com/pocketbase/pocketbase/migrations"
9+
"github.com/pocketbase/pocketbase/models/schema"
10+
)
11+
12+
func init() {
13+
m.Register(func(db dbx.Builder) error {
14+
dao := daos.New(db);
15+
16+
collection, err := dao.FindCollectionByNameOrId("files")
17+
if err != nil {
18+
return err
19+
}
20+
21+
// add
22+
new_tags := &schema.SchemaField{}
23+
json.Unmarshal([]byte(`{
24+
"system": false,
25+
"id": "lb7aotzd",
26+
"name": "tags",
27+
"type": "json",
28+
"required": false,
29+
"unique": false,
30+
"options": {}
31+
}`), new_tags)
32+
collection.Schema.AddField(new_tags)
33+
34+
return dao.SaveCollection(collection)
35+
}, func(db dbx.Builder) error {
36+
dao := daos.New(db);
37+
38+
collection, err := dao.FindCollectionByNameOrId("files")
39+
if err != nil {
40+
return err
41+
}
42+
43+
// remove
44+
collection.Schema.RemoveField("lb7aotzd")
45+
46+
return dao.SaveCollection(collection)
47+
})
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package migrations
2+
3+
import (
4+
"encoding/json"
5+
6+
"github.com/pocketbase/dbx"
7+
"github.com/pocketbase/pocketbase/daos"
8+
m "github.com/pocketbase/pocketbase/migrations"
9+
"github.com/pocketbase/pocketbase/models/schema"
10+
)
11+
12+
func init() {
13+
m.Register(func(db dbx.Builder) error {
14+
dao := daos.New(db);
15+
16+
collection, err := dao.FindCollectionByNameOrId("files")
17+
if err != nil {
18+
return err
19+
}
20+
21+
// add
22+
new_tags_suggestions := &schema.SchemaField{}
23+
json.Unmarshal([]byte(`{
24+
"system": false,
25+
"id": "ru9qxba4",
26+
"name": "tagsSuggestions",
27+
"type": "json",
28+
"required": false,
29+
"unique": false,
30+
"options": {}
31+
}`), new_tags_suggestions)
32+
collection.Schema.AddField(new_tags_suggestions)
33+
34+
return dao.SaveCollection(collection)
35+
}, func(db dbx.Builder) error {
36+
dao := daos.New(db);
37+
38+
collection, err := dao.FindCollectionByNameOrId("files")
39+
if err != nil {
40+
return err
41+
}
42+
43+
// remove
44+
collection.Schema.RemoveField("ru9qxba4")
45+
46+
return dao.SaveCollection(collection)
47+
})
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package migrations
2+
3+
import (
4+
"encoding/json"
5+
6+
"github.com/pocketbase/dbx"
7+
"github.com/pocketbase/pocketbase/daos"
8+
m "github.com/pocketbase/pocketbase/migrations"
9+
"github.com/pocketbase/pocketbase/models/schema"
10+
)
11+
12+
func init() {
13+
m.Register(func(db dbx.Builder) error {
14+
dao := daos.New(db);
15+
16+
collection, err := dao.FindCollectionByNameOrId("posts")
17+
if err != nil {
18+
return err
19+
}
20+
21+
// add
22+
new_tags := &schema.SchemaField{}
23+
json.Unmarshal([]byte(`{
24+
"system": false,
25+
"id": "b1flf41k",
26+
"name": "tags",
27+
"type": "json",
28+
"required": false,
29+
"unique": false,
30+
"options": {}
31+
}`), new_tags)
32+
collection.Schema.AddField(new_tags)
33+
34+
return dao.SaveCollection(collection)
35+
}, func(db dbx.Builder) error {
36+
dao := daos.New(db);
37+
38+
collection, err := dao.FindCollectionByNameOrId("posts")
39+
if err != nil {
40+
return err
41+
}
42+
43+
// remove
44+
collection.Schema.RemoveField("b1flf41k")
45+
46+
return dao.SaveCollection(collection)
47+
})
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package migrations
2+
3+
import (
4+
"encoding/json"
5+
6+
"github.com/pocketbase/dbx"
7+
"github.com/pocketbase/pocketbase/daos"
8+
m "github.com/pocketbase/pocketbase/migrations"
9+
"github.com/pocketbase/pocketbase/models"
10+
)
11+
12+
func init() {
13+
m.Register(func(db dbx.Builder) error {
14+
jsonData := `{
15+
"id": "zjulwnkxemfb9i2",
16+
"created": "2023-05-19 07:30:02.938Z",
17+
"updated": "2023-05-19 07:30:02.938Z",
18+
"name": "tokens",
19+
"type": "base",
20+
"system": false,
21+
"schema": [
22+
{
23+
"system": false,
24+
"id": "i3ctfv03",
25+
"name": "revoked",
26+
"type": "bool",
27+
"required": false,
28+
"unique": false,
29+
"options": {}
30+
},
31+
{
32+
"system": false,
33+
"id": "u7i4ai5e",
34+
"name": "expires",
35+
"type": "date",
36+
"required": false,
37+
"unique": false,
38+
"options": {
39+
"min": "",
40+
"max": ""
41+
}
42+
}
43+
],
44+
"indexes": [],
45+
"listRule": null,
46+
"viewRule": null,
47+
"createRule": null,
48+
"updateRule": null,
49+
"deleteRule": null,
50+
"options": {}
51+
}`
52+
53+
collection := &models.Collection{}
54+
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
55+
return err
56+
}
57+
58+
return daos.New(db).SaveCollection(collection)
59+
}, func(db dbx.Builder) error {
60+
dao := daos.New(db);
61+
62+
collection, err := dao.FindCollectionByNameOrId("zjulwnkxemfb9i2")
63+
if err != nil {
64+
return err
65+
}
66+
67+
return dao.DeleteCollection(collection)
68+
})
69+
}

0 commit comments

Comments
 (0)