aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/data/db.go4
-rw-r--r--pkg/index/index.go6
-rw-r--r--pkg/query/lexer.go1
3 files changed, 10 insertions, 1 deletions
diff --git a/pkg/data/db.go b/pkg/data/db.go
index 6837da1..2d9e6c0 100644
--- a/pkg/data/db.go
+++ b/pkg/data/db.go
@@ -104,6 +104,7 @@ func createSchema(db *sql.DB, version string) error {
CREATE TABLE IF NOT EXISTS Documents(
id INTEGER PRIMARY KEY,
path TEXT UNIQUE NOT NULL,
+ headings TEXT,
title TEXT,
date INT,
fileTime INT,
@@ -257,6 +258,7 @@ func createSchema(db *sql.DB, version string) error {
SELECT
d.id AS docId,
d.path,
+ d.headings,
d.title,
d.date,
d.fileTime,
@@ -394,7 +396,7 @@ func (q Query) Execute(ctx context.Context, artifact query.CompilationArtifact)
}
compiledQuery := fmt.Sprintf(`
- SELECT DISTINCT docId, path, title, date, fileTime, meta
+ SELECT DISTINCT docId, path, headings, title, date, fileTime, meta
FROM Search
WHERE %s`, artifact.Query)
diff --git a/pkg/index/index.go b/pkg/index/index.go
index b354bbf..b79ef2f 100644
--- a/pkg/index/index.go
+++ b/pkg/index/index.go
@@ -23,6 +23,7 @@ import (
var ErrHeaderParse error = errors.New("Unable to parse YAML header")
var linkRegex *regexp.Regexp
+// TODO: add headings field
type Document struct {
Path string `yaml:"-" json:"path"`
Title string `yaml:"title" json:"title"`
@@ -41,6 +42,7 @@ type ParseOpts struct {
IgnoreDateError bool
IgnoreMetaError bool
IgnoreHidden bool
+ // TODO: add IgnoreHeadings
}
type InfoPath struct {
@@ -75,6 +77,7 @@ var _ yaml.BytesMarshaler = (*Document)(nil)
func (doc *Document) MarshalYAML() ([]byte, error) {
return yaml.Marshal(yaml.MapSlice{
{Key: "path", Value: doc.Path},
+ // TODO: add headings
{Key: "title", Value: doc.Title},
{Key: "date", Value: doc.Date},
{Key: "filetime", Value: doc.FileTime},
@@ -209,6 +212,7 @@ func (doc Document) Equal(other Document) bool {
}
}
+ // TODO: handle headings
return true
}
@@ -377,6 +381,7 @@ func NewDocCmp(field string, reverse bool) (func(*Document, *Document) int, bool
return func(a, b *Document) int {
return descMod * strings.Compare(a.OtherMeta, b.OtherMeta)
}, true
+ // TODO: add headings
}
return nil, false
@@ -408,6 +413,7 @@ func ParseDoc(path string, opts ParseOpts) (*Document, error) {
return nil, errors.Join(ErrHeaderParse, err)
}
+ // TODO: parse headings simultaneously with links
if opts.ParseLinks {
var buf bytes.Buffer
f.Seek(pos, io.SeekStart)
diff --git a/pkg/query/lexer.go b/pkg/query/lexer.go
index de344b7..aa877cf 100644
--- a/pkg/query/lexer.go
+++ b/pkg/query/lexer.go
@@ -40,6 +40,7 @@ const (
TOK_CAT_TAGS
TOK_CAT_LINKS
TOK_CAT_META
+ // TODO: add headings
// values
TOK_VAL_STR
TOK_VAL_DATETIME