This commit is contained in:
Kristian Borgwarth 2026-03-23 22:32:20 +01:00
parent 722b1dbbe7
commit da4f5e2feb
4 changed files with 22 additions and 31 deletions

View file

@ -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()}

View file

@ -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
}

2
core/template/doc.go Normal file
View file

@ -0,0 +1,2 @@
// Package template provides implementations for generating notes from templates
package template

View file

@ -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}
}