2021-09-30 06:54:42 +02:00
|
|
|
package note
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
2021-09-30 07:10:33 +02:00
|
|
|
"ewintr.nl/shitty-ssg/pkg/adoc"
|
2021-09-30 06:54:42 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Notes []*Note
|
|
|
|
|
|
|
|
func (n *Notes) AddFileNote(fPath string) error {
|
|
|
|
content, err := ioutil.ReadFile(fPath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
note := NewNote(adoc.New(string(content)))
|
|
|
|
if note.Kind != KIND_INVALID {
|
|
|
|
*n = append(*n, note)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Notes) FilterByTerm(term string) Notes {
|
|
|
|
found := Notes{}
|
|
|
|
for _, note := range *n {
|
|
|
|
if note.Contains(term) {
|
|
|
|
found = append(found, note)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found
|
|
|
|
}
|