diff --git a/core/handlers/create_note.go b/core/handlers/create_note.go index 26fb406..df71e3e 100644 --- a/core/handlers/create_note.go +++ b/core/handlers/create_note.go @@ -24,7 +24,7 @@ func (h CreateNoteHandler) Handle(params []byte) (any, *rpc.Error) { return nil, &rpc.Error{Code: -32602, Message: "invalid params"} } - err := h.repository.Upsert(cmd.Title, cmd.TemplatePath, cmd.Path) + err := h.repository.Upsert(cmd.Title, cmd.Path, cmd.Path) if err != nil { return nil, &rpc.Error{Code: -1, Message: err.Error()} diff --git a/core/handlers/initialize.go b/core/handlers/initialize.go index bf35334..c6cf01f 100644 --- a/core/handlers/initialize.go +++ b/core/handlers/initialize.go @@ -2,25 +2,12 @@ package handlers import ( "encoding/json" - "github.com/KristianJBorgwarth/dendrite.daemon/config" "github.com/KristianJBorgwarth/dendrite.daemon/core/rpc" "github.com/KristianJBorgwarth/dendrite.daemon/persistence" ) type initializeCommand struct { VaultPath string `json:"vaultPath"` - TemplateDir string `json:"templateDir"` - - ScratchNote struct { - Dir string `json:"dir"` - TemplateName string `json:"templateName"` - } `json:"scratchNote"` - - DailyNote struct { - Dir string `json:"dir"` - TemplateName string `json:"templateName"` - FilenameFormat string `json:"filenameFormat"` - } `json:"dailyNote"` } type InitializeHandler struct{} @@ -35,23 +22,8 @@ func (h InitializeHandler) Handle(raw json.RawMessage) (any, *rpc.Error) { } } - cfg := &config.Config{ - VaultPath: params.VaultPath, - TemplateDir: params.TemplateDir, - ScratchNote: config.ScratchConfig{ - Dir: params.ScratchNote.Dir, - TemplateName: params.ScratchNote.TemplateName, - }, - DailyNote: config.DailyConfig{ - Dir: params.DailyNote.Dir, - TemplateName: params.DailyNote.TemplateName, - FilenameFormat: params.DailyNote.FilenameFormat, - }, - } - cfg.SetDefaults() - - err := persistence.InitializeIndex(cfg.VaultPath) + err := persistence.InitializeIndex(params.VaultPath) if err != nil { return nil, &rpc.Error{ Code: -1, @@ -59,6 +31,6 @@ func (h InitializeHandler) Handle(raw json.RawMessage) (any, *rpc.Error) { } } - return cfg, nil + return nil, nil } diff --git a/core/template/doc.go b/core/template/doc.go new file mode 100644 index 0000000..66c2031 --- /dev/null +++ b/core/template/doc.go @@ -0,0 +1,2 @@ +// Package template provides implementations for generating notes from templates +package template diff --git a/persistence/repositories/tag_repository.go b/persistence/repositories/tag_repository.go new file mode 100644 index 0000000..ea07afc --- /dev/null +++ b/persistence/repositories/tag_repository.go @@ -0,0 +1,17 @@ + +package repositories + +import "database/sql" + +type TagRepository interface { + Upsert(title string, path string, slug string) error +} + +type tagRepository struct { + db *sql.DB +} + +func NewTagRepository(db *sql.DB) TagRepository { + return &tagRepository{db: db} +} +