Skip to content

Commit

Permalink
feat: 🔖 release 2.1.0 - Landmarks and docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
CRBroughton committed Nov 19, 2023
2 parents bb537a9 + e984ec9 commit 3fd2006
Show file tree
Hide file tree
Showing 24 changed files with 827 additions and 109 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
VITE_MAPBOX_KEY="MAPBOX_API_KEY"
VITE_POCKETBASE_URL="http://localhost:8090"
31 changes: 24 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
# Forager

## 2.1.0

### Minor Changes

- 2f5dabb: Users can now create landmarks - Users are now able to create landmarks. This feature
re-purposes the arbitrary item menu to allow users to
add landmarks to the map. Landmarks, like items, can also be deleted.
- a021252: move calendar month component to images menu - Previously, all added items of interest could not have
their calendar months customised. You can now customise
items 'startMonth' and 'endMonth' months, the months
you can expect to find this item in the wild. Any existing
items you have will need to be manually edited.

### Patch Changes

- 68ed2d7: Include Docker deployment options - Forager can now be deployed with a Docker image
- bb3202a: Create loading screen on application login
- ad34d82: Add migration for default services, canCreateAccounts now defaults to true
- c03d753: Create user and item seeder

## 2.0.0

### Major Changes

- Move environment settings to user account
- Users will
now have to provide thier own Mapbox API keys on account creation (this is a breaking change).
- Users will now have to ensure the appropriate
Pocketbase server URL is set on first launch to
properly communicate with the server.

- Move environment settings to user account - Users will
now have to provide thier own Mapbox API keys on account creation (this is a breaking change). - Users will now have to ensure the appropriate
Pocketbase server URL is set on first launch to
properly communicate with the server.
26 changes: 13 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
FROM node:18.12.1
FROM alpine:latest

LABEL author="Craig Broughton"
LABEL author.email="[email protected]"
ARG FORAGER_VERSION=2.0.1

WORKDIR /app
RUN apk add --no-cache \
unzip \
ca-certificates

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# download and unzip Forager
ADD https://github.com/CRBroughton/forager/releases/download/${FORAGER_VERSION}/forager-${FORAGER_VERSION}-linux.zip /tmp/forager.zip

ADD . .
RUN unzip /tmp/forager.zip -d forager
RUN cd forager && mv forager-${FORAGER_VERSION}-linux forager
RUN rm -rf /tmp/forager/zip

RUN npm i -g pnpm && pnpm i
EXPOSE 8080

ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 4000

CMD ["npm", "run", "dev"]
# start Forager
CMD ["forager/forager", "serve", "--http=0.0.0.0:8090"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ This binary will provide both the back-end and front-end of the application.

For deployment of the application, see [Pocketbases Going to Production documentation](https://pocketbase.io/docs/going-to-production/).

### Docker

The Forager repository includes a `docker-compose.yml` file, enabling
quick deployment of Forager. Simply install Docker, clone the repository
and then run `docker compose up -d`.

## Manual Installation

Regardless of manual installation method, you will require the following to build Forager:
Expand Down Expand Up @@ -114,6 +120,10 @@ Dependant on your operating system's architecture, download the latest release o
into the db folder. When running `pnpm run pocketbase:serve` for the first time,
the database migrations will ensure the correct tables are created.

If you wish to seed the database with a test user, one is provided
if you run `pnpm run pocketbase:seed` - You will need to update this
users password and Mapbox API key.

## Progressive Web Application (PWA)

Forager is a Progressive Web Application (PWA), and therefore can be installed via any browser, however requires an active connection to your [Pocketbase](https://github.com/pocketbase/pocketbase) instance.
Expand Down
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare module 'vue' {
ImageSettings: typeof import('./src/views/settings/ImageSettings.vue')['default']
InformationMark: typeof import('./src/components/InformationMark.vue')['default']
ItemDetails: typeof import('./src/components/ItemDetails.vue')['default']
LoadingScreen: typeof import('./src/components/LoadingScreen.vue')['default']
LoginForm: typeof import('./src/components/LoginForm.vue')['default']
MonthSelector: typeof import('./src/components/MonthSelector.vue')['default']
ReferenceImage: typeof import('./src/components/ReferenceImage.vue')['default']
Expand Down
3 changes: 3 additions & 0 deletions db/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/pocketbase/pocketbase/plugins/migratecmd"

_ "github.com/crbroughton/forager/migrations"
"github.com/crbroughton/forager/seeder"
)

//go:embed all:dist
Expand All @@ -21,6 +22,8 @@ var distDir embed.FS
func main() {
app := pocketbase.New()

seeder.AddSeederCommand(app)

// loosely check if it was executed using "go run"
isGoRun := strings.HasPrefix(os.Args[0], os.TempDir())

Expand Down
50 changes: 50 additions & 0 deletions db/migrations/1700070534_default_services.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package migrations

import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)

func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db)

collection, err := dao.FindCollectionByNameOrId("Services")
if err != nil {
return err
}

record := models.NewRecord(collection)

record.Set("id", 1)
record.Set("canCreateAccounts", true)

err = dao.SaveRecord(record)
if err != nil {
return err
}

return nil
}, func(db dbx.Builder) error {
dao := daos.New(db)

collection, err := dao.FindCollectionByNameOrId("Services")
if err != nil {
return err
}

record, err := dao.FindRecordById(collection.Id, "1")
if err != nil {
return err
}

err = dao.DeleteRecord(record)
if err != nil {
return err
}

return nil
})
}
87 changes: 87 additions & 0 deletions db/migrations/1700339939_landmarks_table.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package migrations

import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)

func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db)

ownerOnly := types.Pointer("@request.auth.id != '' && owner.id ?= @request.auth.id")
usersCollection, err := dao.FindCollectionByNameOrId("users")
if err != nil {
return err
}

collection := &models.Collection{
Name: "landmarks",
Type: models.CollectionTypeBase,
ListRule: ownerOnly,
ViewRule: ownerOnly,
CreateRule: types.Pointer(""),
UpdateRule: ownerOnly,
DeleteRule: ownerOnly,
System: false,
Schema: schema.NewSchema(
&schema.SchemaField{
Name: "name",
Type: schema.FieldTypeText,
Required: true,
System: false,
},
&schema.SchemaField{
Name: "owner",
Type: schema.FieldTypeRelation,
Required: true,
System: false,
Options: &schema.RelationOptions{
CollectionId: usersCollection.Id,
CascadeDelete: false,
MinSelect: types.Pointer(1),
MaxSelect: types.Pointer(1),
},
},
&schema.SchemaField{
Name: "lng",
Type: schema.FieldTypeNumber,
Required: true,
System: false,
},
&schema.SchemaField{
Name: "lat",
Type: schema.FieldTypeNumber,
Required: true,
System: false,
},
),
}

err = dao.SaveCollection(collection)

if err != nil {
return err
}

return nil
}, func(db dbx.Builder) error {
dao := daos.New(db)

collection, err := dao.FindCollectionByNameOrId("landmarks")
if err != nil {
return err
}

err = dao.DeleteCollection(collection)
if err != nil {
return err
}

return nil
})
}
Loading

0 comments on commit 3fd2006

Please sign in to comment.