tag repo
This commit is contained in:
parent
722b1dbbe7
commit
da4f5e2feb
4 changed files with 22 additions and 31 deletions
|
|
@ -24,7 +24,7 @@ func (h CreateNoteHandler) Handle(params []byte) (any, *rpc.Error) {
|
||||||
return nil, &rpc.Error{Code: -32602, Message: "invalid params"}
|
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 {
|
if err != nil {
|
||||||
return nil, &rpc.Error{Code: -1, Message: err.Error()}
|
return nil, &rpc.Error{Code: -1, Message: err.Error()}
|
||||||
|
|
|
||||||
|
|
@ -2,25 +2,12 @@ package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/KristianJBorgwarth/dendrite.daemon/config"
|
|
||||||
"github.com/KristianJBorgwarth/dendrite.daemon/core/rpc"
|
"github.com/KristianJBorgwarth/dendrite.daemon/core/rpc"
|
||||||
"github.com/KristianJBorgwarth/dendrite.daemon/persistence"
|
"github.com/KristianJBorgwarth/dendrite.daemon/persistence"
|
||||||
)
|
)
|
||||||
|
|
||||||
type initializeCommand struct {
|
type initializeCommand struct {
|
||||||
VaultPath string `json:"vaultPath"`
|
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{}
|
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(params.VaultPath)
|
||||||
|
|
||||||
err := persistence.InitializeIndex(cfg.VaultPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &rpc.Error{
|
return nil, &rpc.Error{
|
||||||
Code: -1,
|
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
2
core/template/doc.go
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Package template provides implementations for generating notes from templates
|
||||||
|
package template
|
||||||
17
persistence/repositories/tag_repository.go
Normal file
17
persistence/repositories/tag_repository.go
Normal 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}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue