feat: createTaskNote moved to own function

This commit is contained in:
Anish Lakhwara 2024-05-25 03:18:49 -07:00
parent bb9f171579
commit 98482784bc

View file

@ -69,6 +69,25 @@ func RowsToFile(taskList []table.Row, activeIndex int) []string {
// create task-note if it doesn't exist
note_path := "/home/anish/kitaab/vimwiki/task-notes/" + uuid + ".wiki"
if _, err := os.Stat(note_path); os.IsNotExist(err) {
CreateTaskNote(note_path, row)
}
// link to task-note from pom-note
rowClone := make(table.Row, len(row))
_ = copy(rowClone, row)
// TODO add links to indexs of EACH tag
rowClone[2] = ""
for _, tag := range strings.Split(row[2], " ") {
rowClone[2] += "[[../indexs/" + tag + ".wiki|" + tag + "]] "
}
rowClone[3] = "[[../task-notes/" + uuid + ".wiki|" + row[3] + "]]"
rows = append(rows, strings.Join(rowClone[1:], " - "))
}
}
return rows
}
func CreateTaskNote(note_path string, row table.Row) {
f, err := os.Create(note_path)
if err != nil {
log.Fatal(err)
@ -80,15 +99,5 @@ func RowsToFile(taskList []table.Row, activeIndex int) []string {
fmt.Fprintln(f, tags)
fmt.Fprintln(f, "%date "+path)
fmt.Fprintln(f, "")
f.Close()
}
// link to task-note from pom-note
rowClone := make(table.Row, len(row))
_ = copy(rowClone, row)
rowClone[3] = "[[../task-notes/" + uuid + ".wiki|" + row[3] + "]]"
rows = append(rows, strings.Join(row[1:], " - "))
}
}
return rows
defer f.Close()
}