mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Use title, when present, as root ancestor of entries instead of file path
This commit is contained in:
parent
ddb07def0d
commit
55785d50c3
3 changed files with 20 additions and 12 deletions
|
@ -110,7 +110,7 @@ class OrgToEntries(TextToEntries):
|
||||||
|
|
||||||
compiled = heading
|
compiled = heading
|
||||||
if state.verbose > 2:
|
if state.verbose > 2:
|
||||||
logger.debug(f"Title: {parsed_entry.heading}")
|
logger.debug(f"Title: {heading}")
|
||||||
|
|
||||||
if parsed_entry.tags:
|
if parsed_entry.tags:
|
||||||
tags_str = " ".join(parsed_entry.tags)
|
tags_str = " ".join(parsed_entry.tags)
|
||||||
|
|
|
@ -80,7 +80,7 @@ def makelist(file, filename):
|
||||||
} # populated from #+SEQ_TODO line
|
} # populated from #+SEQ_TODO line
|
||||||
level = ""
|
level = ""
|
||||||
heading = ""
|
heading = ""
|
||||||
ancestor_headings = [f"{filename}"]
|
ancestor_headings = []
|
||||||
bodytext = ""
|
bodytext = ""
|
||||||
introtext = ""
|
introtext = ""
|
||||||
tags = list() # set of all tags in headline
|
tags = list() # set of all tags in headline
|
||||||
|
@ -257,6 +257,9 @@ def makelist(file, filename):
|
||||||
n.priority = priority_search.group(1)
|
n.priority = priority_search.group(1)
|
||||||
n.heading = priority_search.group(2)
|
n.heading = priority_search.group(2)
|
||||||
|
|
||||||
|
# Prefix filepath/title to ancestors
|
||||||
|
n.ancestors = [file_title] + n.ancestors
|
||||||
|
|
||||||
# Set SOURCE property to a file+heading based org-mode link to the entry
|
# Set SOURCE property to a file+heading based org-mode link to the entry
|
||||||
if n.level == 0:
|
if n.level == 0:
|
||||||
n.properties["LINE"] = f"file:{normalize_filename(filename)}::0"
|
n.properties["LINE"] = f"file:{normalize_filename(filename)}::0"
|
||||||
|
@ -295,15 +298,20 @@ class Orgnode(object):
|
||||||
self._logbook = list() # List of clock-in, clock-out tuples representing logbook entries
|
self._logbook = list() # List of clock-in, clock-out tuples representing logbook entries
|
||||||
self._ancestor_headings = ancestor_headings.copy()
|
self._ancestor_headings = ancestor_headings.copy()
|
||||||
|
|
||||||
# Look for priority in headline and transfer to prty field
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ancestors(self):
|
def ancestors(self) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Return the Heading text of the node without the TODO tag
|
Return the ancestor headings of the node
|
||||||
"""
|
"""
|
||||||
return self._ancestor_headings
|
return self._ancestor_headings
|
||||||
|
|
||||||
|
@ancestors.setter
|
||||||
|
def ancestors(self, new_ancestors):
|
||||||
|
"""
|
||||||
|
Update the ancestor headings of the node
|
||||||
|
"""
|
||||||
|
self._ancestor_headings = new_ancestors
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def heading(self):
|
def heading(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -262,7 +262,7 @@ Body Line 1"""
|
||||||
assert entries[0].closed == ""
|
assert entries[0].closed == ""
|
||||||
assert entries[0].scheduled == ""
|
assert entries[0].scheduled == ""
|
||||||
assert entries[0].deadline == ""
|
assert entries[0].deadline == ""
|
||||||
assert entries[0].ancestors == []
|
assert entries[0].ancestors == ["test"]
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@ -287,7 +287,7 @@ Body Line 1
|
||||||
assert entries[0].closed == ""
|
assert entries[0].closed == ""
|
||||||
assert entries[0].scheduled == ""
|
assert entries[0].scheduled == ""
|
||||||
assert entries[0].deadline == ""
|
assert entries[0].deadline == ""
|
||||||
assert entries[0].ancestors == []
|
assert entries[0].ancestors == ["title1 title2"]
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@ -308,10 +308,10 @@ entry body
|
||||||
assert len(entries) == 2
|
assert len(entries) == 2
|
||||||
assert entries[0].heading == "Title"
|
assert entries[0].heading == "Title"
|
||||||
assert entries[0].body == "intro body\n"
|
assert entries[0].body == "intro body\n"
|
||||||
assert entries[0].ancestors == []
|
assert entries[0].ancestors == ["Title"]
|
||||||
assert entries[1].heading == "Entry Heading"
|
assert entries[1].heading == "Entry Heading"
|
||||||
assert entries[1].body == "entry body\n\n"
|
assert entries[1].body == "entry body\n\n"
|
||||||
assert entries[1].ancestors == [f"{orgfile}"]
|
assert entries[1].ancestors == ["Title"]
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@ -332,10 +332,10 @@ entry body
|
||||||
assert len(entries) == 2
|
assert len(entries) == 2
|
||||||
assert entries[0].heading == "Title1 Title2"
|
assert entries[0].heading == "Title1 Title2"
|
||||||
assert entries[0].body == "intro body\n"
|
assert entries[0].body == "intro body\n"
|
||||||
assert entries[0].ancestors == []
|
assert entries[0].ancestors == ["Title1 Title2"]
|
||||||
assert entries[1].heading == "Entry Heading"
|
assert entries[1].heading == "Entry Heading"
|
||||||
assert entries[1].body == "entry body\n\n"
|
assert entries[1].body == "entry body\n\n"
|
||||||
assert entries[1].ancestors == [f"{orgfile}"]
|
assert entries[0].ancestors == ["Title1 Title2"]
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue