feat: createTaskNote moved to own function
This commit is contained in:
parent
bb9f171579
commit
98482784bc
35
task/task.go
35
task/task.go
|
@ -69,26 +69,35 @@ 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) {
|
||||||
f, err := os.Create(note_path)
|
CreateTaskNote(note_path, row)
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
path := time.Now().Format(time.DateOnly)
|
|
||||||
tags := strings.Replace(row[2], " ", ":", -1)
|
|
||||||
tags = ":" + row[1] + ":" + tags + ":"
|
|
||||||
fmt.Fprintln(f, "%title "+row[3])
|
|
||||||
fmt.Fprintln(f, tags)
|
|
||||||
fmt.Fprintln(f, "%date "+path)
|
|
||||||
fmt.Fprintln(f, "")
|
|
||||||
f.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// link to task-note from pom-note
|
// link to task-note from pom-note
|
||||||
rowClone := make(table.Row, len(row))
|
rowClone := make(table.Row, len(row))
|
||||||
_ = copy(rowClone, 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] + "]]"
|
rowClone[3] = "[[../task-notes/" + uuid + ".wiki|" + row[3] + "]]"
|
||||||
rows = append(rows, strings.Join(row[1:], " - "))
|
rows = append(rows, strings.Join(rowClone[1:], " - "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateTaskNote(note_path string, row table.Row) {
|
||||||
|
f, err := os.Create(note_path)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
path := time.Now().Format(time.DateOnly)
|
||||||
|
tags := strings.Replace(row[2], " ", ":", -1)
|
||||||
|
tags = ":" + row[1] + ":" + tags + ":"
|
||||||
|
fmt.Fprintln(f, "%title "+row[3])
|
||||||
|
fmt.Fprintln(f, tags)
|
||||||
|
fmt.Fprintln(f, "%date "+path)
|
||||||
|
fmt.Fprintln(f, "")
|
||||||
|
defer f.Close()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue