[frontmatter]: Include todo-list-completed
This commit is contained in:
parent
a962170436
commit
7cd847ce64
|
@ -200,6 +200,7 @@ class FavroFuse(fuse.Fuse):
|
||||||
org_id=card.organization_id.raw_id,
|
org_id=card.organization_id.raw_id,
|
||||||
seq_id=card.seq_id.raw_id,
|
seq_id=card.seq_id.raw_id,
|
||||||
),
|
),
|
||||||
|
todo_list_completed = card.todo_list_completed,
|
||||||
)
|
)
|
||||||
return self.formatter.format_card_contents(card_contents)
|
return self.formatter.format_card_contents(card_contents)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,17 @@ import frontmatter
|
||||||
import marko
|
import marko
|
||||||
import marko.md_renderer
|
import marko.md_renderer
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# FrontMatter keys
|
||||||
|
|
||||||
|
FM_KEY_TODO_LIST_COMPLETED = 'todo-list-completed'
|
||||||
|
FM_KEY_TAGS = 'tags'
|
||||||
|
FM_KEY_ASSIGNMENTS = 'assignments'
|
||||||
|
FM_KEY_DEPENDENCIES = 'dependencies'
|
||||||
|
FM_KEY_URL = 'url'
|
||||||
|
FM_KEY_ALIASES = 'aliases'
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class CardContents:
|
class CardContents:
|
||||||
|
@ -15,6 +26,7 @@ class CardContents:
|
||||||
assignments: list[str]
|
assignments: list[str]
|
||||||
card_dependencies: list[str]
|
card_dependencies: list[str]
|
||||||
url: str
|
url: str
|
||||||
|
todo_list_completed: bool | None
|
||||||
|
|
||||||
|
|
||||||
def format_obsidian_link(text: str) -> str:
|
def format_obsidian_link(text: str) -> str:
|
||||||
|
@ -53,26 +65,28 @@ class CardFileFormatter:
|
||||||
if card.identifier and card.name:
|
if card.identifier and card.name:
|
||||||
aliases.append(f'{card.identifier}: {card.name}')
|
aliases.append(f'{card.identifier}: {card.name}')
|
||||||
if aliases:
|
if aliases:
|
||||||
frontmatter_data['aliases'] = aliases
|
frontmatter_data[FM_KEY_ALIASES] = aliases
|
||||||
del aliases
|
del aliases
|
||||||
if card.tags:
|
if card.tags:
|
||||||
frontmatter_data['tags'] = card.tags
|
frontmatter_data[FM_KEY_TAGS] = card.tags
|
||||||
if card.url and self.obsidian_mode:
|
if card.url and self.obsidian_mode:
|
||||||
frontmatter_data['url'] = card.url
|
frontmatter_data[FM_KEY_URL] = card.url
|
||||||
if card.assignments:
|
if card.assignments:
|
||||||
frontmatter_data['assignments'] = card.assignments
|
frontmatter_data[FM_KEY_ASSIGNMENTS] = card.assignments
|
||||||
if self.obsidian_mode:
|
if self.obsidian_mode:
|
||||||
frontmatter_data['assignments'] = [
|
frontmatter_data[FM_KEY_ASSIGNMENTS] = [
|
||||||
format_obsidian_link(name)
|
format_obsidian_link(name)
|
||||||
for name in frontmatter_data['assignments']
|
for name in frontmatter_data[FM_KEY_ASSIGNMENTS]
|
||||||
]
|
]
|
||||||
if card.card_dependencies:
|
if card.card_dependencies:
|
||||||
frontmatter_data['dependencies'] = card.card_dependencies
|
frontmatter_data[FM_KEY_DEPENDENCIES] = card.card_dependencies
|
||||||
if self.obsidian_mode:
|
if self.obsidian_mode:
|
||||||
frontmatter_data['dependencies'] = [
|
frontmatter_data[FM_KEY_DEPENDENCIES] = [
|
||||||
format_obsidian_link(name)
|
format_obsidian_link(name)
|
||||||
for name in frontmatter_data['dependencies']
|
for name in frontmatter_data[FM_KEY_DEPENDENCIES]
|
||||||
]
|
]
|
||||||
|
if card.todo_list_completed:
|
||||||
|
frontmatter_data[FM_KEY_TODO_LIST_COMPLETED] = card.todo_list_completed
|
||||||
|
|
||||||
# Card name
|
# Card name
|
||||||
ls = []
|
ls = []
|
||||||
|
@ -110,15 +124,16 @@ class CardFileFormatter:
|
||||||
document.children.remove(elem)
|
document.children.remove(elem)
|
||||||
break
|
break
|
||||||
|
|
||||||
tags: list[str] = fm.metadata.get('tags', [])
|
tags: list[str] = fm.metadata.get(FM_KEY_TAGS, [])
|
||||||
|
|
||||||
assignments: list[str] = fm.metadata.get('assignments', [])
|
assignments: list[str] = fm.metadata.get(FM_KEY_ASSIGNMENTS, [])
|
||||||
assignments = [parse_obsidian_link(text) for text in assignments]
|
assignments = [parse_obsidian_link(text) for text in assignments]
|
||||||
|
|
||||||
card_dependencies: list[str] = fm.metadata.get('dependencies', [])
|
card_dependencies: list[str] = fm.metadata.get(FM_KEY_DEPENDENCIES, [])
|
||||||
card_dependencies = [parse_obsidian_link(text) for text in card_dependencies]
|
card_dependencies = [parse_obsidian_link(text) for text in card_dependencies]
|
||||||
|
|
||||||
url: list[str] = fm.metadata.get('url')
|
url: list[str] = fm.metadata.get(FM_KEY_URL)
|
||||||
|
todo_list_completed: bool | None = fm.metadata.get(FM_KEY_TODO_LIST_COMPLETED)
|
||||||
|
|
||||||
description = self.renderer.render_children(document).strip()
|
description = self.renderer.render_children(document).strip()
|
||||||
return CardContents(
|
return CardContents(
|
||||||
|
@ -129,4 +144,5 @@ class CardFileFormatter:
|
||||||
assignments=assignments,
|
assignments=assignments,
|
||||||
card_dependencies=card_dependencies,
|
card_dependencies=card_dependencies,
|
||||||
url=url,
|
url=url,
|
||||||
|
todo_list_completed=todo_list_completed,
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,6 +32,7 @@ dependencies:
|
||||||
tags:
|
tags:
|
||||||
- tag1
|
- tag1
|
||||||
- tag2
|
- tag2
|
||||||
|
todo-list-completed: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Name of Card
|
# Name of Card
|
||||||
|
|
Loading…
Reference in New Issue
Block a user