Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ RUN chmod +x /app/entrypoint.sh

EXPOSE 8080

ENTRYPOINT ["./entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]

CMD ["serve", "--http=0.0.0.0:8080", "--dev"]
18 changes: 15 additions & 3 deletions internal/notebasesync/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ func (h *SyncHandler) OnRecordUpdate(record *core.Record) {
dbVersion, _ := time.Parse(time.RFC3339Nano, record.GetString("version"))
fsVersion, _ := time.Parse(time.RFC3339Nano, xattrs.Version)

rawFrontmatter := record.GetString("raw_frontmatter")
frontmatterJSON := record.GetString("frontmatter")
newFrontmatter := utils.JsonToYaml(frontmatterJSON)
frontmatter := record.GetString("raw_frontmatter")
if newFrontmatter != frontmatter {
h.app.Logger().Debug("frontmatter changed, updating it and exiting")
frontmatter = newFrontmatter
record.Set("raw_frontmatter", frontmatter)
if err := h.app.Save(record); err != nil {
h.app.Logger().Error("error saving record", "error", err)
return
}
return
}
content := record.GetString("content")
dbHash := utils.GetDBHash(rawFrontmatter, content)
dbHash := utils.GetDBHash(frontmatter, content)
fsHash := utils.GetFSHash(path)

h.app.Logger().Debug("record update", "path", path, "dbVersion", dbVersion, "fsVersion", fsVersion, "dbHash", dbHash, "fsHash", fsHash)
Expand All @@ -32,7 +44,7 @@ func (h *SyncHandler) OnRecordUpdate(record *core.Record) {
return
}

err := utils.SaveToDisk(path, content, rawFrontmatter)
err := utils.SaveToDisk(path, content, frontmatter)
if err != nil {
h.app.Logger().Error("error saving file from DB", "path", path, "error", err)
return
Expand Down
75 changes: 75 additions & 0 deletions migrations/1748982700_created_filters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package migrations

import (
"encoding/json"

"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)

func init() {
m.Register(func(app core.App) error {
jsonData := `{
"createRule": null,
"deleteRule": null,
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text3208210256",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"hidden": false,
"id": "autodate2990389176",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate3332085495",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}
],
"id": "pbc_3911456871",
"indexes": [],
"listRule": null,
"name": "filters",
"system": false,
"type": "base",
"updateRule": null,
"viewRule": null
}`

collection := &core.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}

return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_3911456871")
if err != nil {
return err
}

return app.Delete(collection)
})
}
62 changes: 62 additions & 0 deletions migrations/1748982741_updated_filters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package migrations

import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)

func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_3911456871")
if err != nil {
return err
}

// add field
if err := collection.Fields.AddMarshaledJSONAt(1, []byte(`{
"autogeneratePattern": "",
"hidden": false,
"id": "text245846248",
"max": 0,
"min": 0,
"name": "label",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}`)); err != nil {
return err
}

// add field
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
"hidden": false,
"id": "json2021091213",
"maxSize": 0,
"name": "filters",
"presentable": false,
"required": false,
"system": false,
"type": "json"
}`)); err != nil {
return err
}

return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_3911456871")
if err != nil {
return err
}

// remove field
collection.Fields.RemoveById("text245846248")

// remove field
collection.Fields.RemoveById("json2021091213")

return app.Save(collection)
})
}
9 changes: 7 additions & 2 deletions web/assets/css/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@import 'tailwindcss';
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@import '@nuxt/ui';
@import "@nuxt/ui";

body {
padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px)
env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px);
}
8 changes: 4 additions & 4 deletions web/components/AppFilters.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { defineShortcuts, useFiltersStore, useTemplateRef } from '#imports'

const filtersStore = useFiltersStore()

const input = useTemplateRef('input')

const filtersStore = useFiltersStore()

defineShortcuts({
'/': () => {
input.value?.inputRef?.focus()
Expand All @@ -13,7 +13,7 @@ defineShortcuts({
</script>

<template>
<div class="flex py-4 sticky top-0 z-10 bg-(--ui-bg)">
<div>
<UButtonGroup class="w-full">
<AppDrawer />
<UInput
Expand All @@ -29,7 +29,7 @@ defineShortcuts({
>
<template #trailing>
<UButton
v-if="filtersStore.query.length"
v-if="filtersStore.query?.length"
color="neutral"
variant="link"
size="sm"
Expand Down
9 changes: 5 additions & 4 deletions web/components/BaseItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import { itemTypes } from '~/modules/pocketbase/types/schema'
const props = defineProps<BaseItemProps>()

const itemType = computed(() => {
if (Object.keys(itemTypes).includes(props.item?.frontmatter?.type ?? 'none')) {
return props.item?.frontmatter?.type
}
return itemTypes.none
const frontmatterType = props.item?.frontmatter?.type

return frontmatterType && Object.keys(itemTypes).includes(frontmatterType)
? frontmatterType
: itemTypes.none
})

const itemComponent = computed(() => {
Expand Down
Loading