1
0

More aliases

This commit is contained in:
Jon Michael Aanes 2024-10-01 11:12:17 +02:00
parent d24bbff21d
commit 435b1fd514
2 changed files with 19 additions and 6 deletions

View File

@ -30,7 +30,8 @@ class FavroStat(fuse.Stat):
self.st_ctime = 0
CARD_FILENAME_FORMAT = 'PAR-{seq_id}.md'
CARD_IDENTIFIER_FORMAT = 'PAR-{seq_id}'
CARD_FILENAME_FORMAT = CARD_IDENTIFIER_FORMAT + '.md'
CARD_FILENAME_REGEX = r'^\/PAR\-(\d+)\.md$'
OFFICIAL_URL = 'https://favro.com/organization/{org_id}?card=par-{seq_id}'
@ -189,13 +190,15 @@ class FavroFuse(fuse.Fuse):
if dep.is_before
]
card_contents = CardContents(
CARD_IDENTIFIER_FORMAT.format(seq_id=card.seq_id.raw_id),
card.name,
card.detailed_description,
tags,
assignments,
dependencies,
url=OFFICIAL_URL.format(
org_id=card.organization_id.raw_id, seq_id=card.seq_id.raw_id,
org_id=card.organization_id.raw_id,
seq_id=card.seq_id.raw_id,
),
)
return self.formatter.format_card_contents(card_contents)

View File

@ -8,6 +8,7 @@ import marko.md_renderer
@dataclasses.dataclass(frozen=True)
class CardContents:
identifier: str | None
name: str | None
description: str | None
tags: list[str]
@ -37,8 +38,15 @@ class CardFileFormatter:
def format_card_contents(self, card: CardContents) -> str:
# Choose frontmatter data
frontmatter_data = {}
if card.name and self.obsidian_mode:
frontmatter_data['aliases'] = [card.name]
if self.obsidian_mode:
aliases = []
if card.name:
aliases.append(card.name)
if card.identifier and card.name:
aliases.append(f'{card.identifier}: {card.name}')
if aliases:
frontmatter_data['aliases'] = aliases
del aliases
if card.tags:
frontmatter_data['tags'] = card.tags
if card.url and self.obsidian_mode:
@ -72,8 +80,9 @@ class CardFileFormatter:
return frontmatter.dumps(fm)
def parse_card_contents(self, contents: str) -> CardContents:
"""
1. Strips frontmatter
"""Parses card contents.
1. Strips frontmatter and parses certain fields from the header.
2. Parses header
3. Finds content.
"""
@ -100,6 +109,7 @@ class CardFileFormatter:
description = self.renderer.render_children(document).strip()
return CardContents(
None,
name,
description,
tags=tags,