feat: add title and description fields to capture grammar
Implement | prefix for titles and // separator for descriptions across the full stack: parser, schema, API, CLI, and web frontend. - Parser: line-aware extraction for |title, |title // desc, // leading desc, body // inline desc. URL-safe (skips :// lines). Modifiers (#tag, @time, ^card) extracted from all segments. - Schema: ALTER TABLE migration adds title, description columns - DB: Entity/EntityUpdate structs, all CRUD queries updated - API: title/description on create/update/response, body validation relaxed (title-only entries valid) - CLI: shows title as scan label when present - Web: parseInput mirrors Go parser, list shows title, detail pane renders title + description with double-click inline editing - Tests: 10 new cases (grammar, entity, API) — 71 total, all pass
This commit is contained in:
+27
-19
@@ -10,22 +10,26 @@ import (
|
||||
)
|
||||
|
||||
type CreateEntityRequest struct {
|
||||
Body string `json:"body"`
|
||||
Glyph *string `json:"glyph"`
|
||||
TimeAnchor *string `json:"time_anchor"`
|
||||
Tags []string `json:"tags"`
|
||||
CardType *string `json:"card_type"`
|
||||
CardData *string `json:"card_data"`
|
||||
Body string `json:"body"`
|
||||
Title *string `json:"title"`
|
||||
Description *string `json:"description"`
|
||||
Glyph *string `json:"glyph"`
|
||||
TimeAnchor *string `json:"time_anchor"`
|
||||
Tags []string `json:"tags"`
|
||||
CardType *string `json:"card_type"`
|
||||
CardData *string `json:"card_data"`
|
||||
}
|
||||
|
||||
type UpdateEntityRequest struct {
|
||||
Body *string `json:"body"`
|
||||
Glyph *string `json:"glyph"`
|
||||
TimeAnchor *string `json:"time_anchor"`
|
||||
Tags *[]string `json:"tags"`
|
||||
Pinned *bool `json:"pinned"`
|
||||
CardType *string `json:"card_type"`
|
||||
CardData *string `json:"card_data"`
|
||||
Body *string `json:"body"`
|
||||
Title *string `json:"title"`
|
||||
Description *string `json:"description"`
|
||||
Glyph *string `json:"glyph"`
|
||||
TimeAnchor *string `json:"time_anchor"`
|
||||
Tags *[]string `json:"tags"`
|
||||
Pinned *bool `json:"pinned"`
|
||||
CardType *string `json:"card_type"`
|
||||
CardData *string `json:"card_data"`
|
||||
}
|
||||
|
||||
type PromoteRequest struct {
|
||||
@@ -119,8 +123,8 @@ func createEntity(store *db.Store) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
if req.Body == "" {
|
||||
writeError(w, http.StatusBadRequest, "invalid_input", "body is required")
|
||||
if req.Body == "" && req.Title == nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid_input", "body or title is required")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -134,10 +138,12 @@ func createEntity(store *db.Store) http.HandlerFunc {
|
||||
}
|
||||
|
||||
e := &db.Entity{
|
||||
Body: req.Body,
|
||||
Glyph: glyph,
|
||||
TimeAnchor: req.TimeAnchor,
|
||||
Tags: req.Tags,
|
||||
Body: req.Body,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
Glyph: glyph,
|
||||
TimeAnchor: req.TimeAnchor,
|
||||
Tags: req.Tags,
|
||||
}
|
||||
|
||||
if req.CardType != nil {
|
||||
@@ -186,6 +192,8 @@ func updateEntity(store *db.Store) http.HandlerFunc {
|
||||
|
||||
u := &db.EntityUpdate{}
|
||||
u.Body = req.Body
|
||||
u.Title = req.Title
|
||||
u.Description = req.Description
|
||||
u.Tags = req.Tags
|
||||
u.Pinned = req.Pinned
|
||||
u.CardData = req.CardData
|
||||
|
||||
Reference in New Issue
Block a user