feat: createTaskNote moved to own function
This commit is contained in:
parent
bb9f171579
commit
98482784bc
31
task/task.go
31
task/task.go
|
@ -69,6 +69,25 @@ func RowsToFile(taskList []table.Row, activeIndex int) []string {
|
||||||
// create task-note if it doesn't exist
|
// create task-note if it doesn't exist
|
||||||
note_path := "/home/anish/kitaab/vimwiki/task-notes/" + uuid + ".wiki"
|
note_path := "/home/anish/kitaab/vimwiki/task-notes/" + uuid + ".wiki"
|
||||||
if _, err := os.Stat(note_path); os.IsNotExist(err) {
|
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)
|
f, err := os.Create(note_path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -80,15 +99,5 @@ func RowsToFile(taskList []table.Row, activeIndex int) []string {
|
||||||
fmt.Fprintln(f, tags)
|
fmt.Fprintln(f, tags)
|
||||||
fmt.Fprintln(f, "%date "+path)
|
fmt.Fprintln(f, "%date "+path)
|
||||||
fmt.Fprintln(f, "")
|
fmt.Fprintln(f, "")
|
||||||
f.Close()
|
defer 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
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue