More aliases
This commit is contained in:
parent
d24bbff21d
commit
435b1fd514
|
@ -30,7 +30,8 @@ class FavroStat(fuse.Stat):
|
||||||
self.st_ctime = 0
|
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$'
|
CARD_FILENAME_REGEX = r'^\/PAR\-(\d+)\.md$'
|
||||||
|
|
||||||
OFFICIAL_URL = 'https://favro.com/organization/{org_id}?card=par-{seq_id}'
|
OFFICIAL_URL = 'https://favro.com/organization/{org_id}?card=par-{seq_id}'
|
||||||
|
@ -189,13 +190,15 @@ class FavroFuse(fuse.Fuse):
|
||||||
if dep.is_before
|
if dep.is_before
|
||||||
]
|
]
|
||||||
card_contents = CardContents(
|
card_contents = CardContents(
|
||||||
|
CARD_IDENTIFIER_FORMAT.format(seq_id=card.seq_id.raw_id),
|
||||||
card.name,
|
card.name,
|
||||||
card.detailed_description,
|
card.detailed_description,
|
||||||
tags,
|
tags,
|
||||||
assignments,
|
assignments,
|
||||||
dependencies,
|
dependencies,
|
||||||
url=OFFICIAL_URL.format(
|
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)
|
return self.formatter.format_card_contents(card_contents)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import marko.md_renderer
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class CardContents:
|
class CardContents:
|
||||||
|
identifier: str | None
|
||||||
name: str | None
|
name: str | None
|
||||||
description: str | None
|
description: str | None
|
||||||
tags: list[str]
|
tags: list[str]
|
||||||
|
@ -37,8 +38,15 @@ class CardFileFormatter:
|
||||||
def format_card_contents(self, card: CardContents) -> str:
|
def format_card_contents(self, card: CardContents) -> str:
|
||||||
# Choose frontmatter data
|
# Choose frontmatter data
|
||||||
frontmatter_data = {}
|
frontmatter_data = {}
|
||||||
if card.name and self.obsidian_mode:
|
if self.obsidian_mode:
|
||||||
frontmatter_data['aliases'] = [card.name]
|
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:
|
if card.tags:
|
||||||
frontmatter_data['tags'] = card.tags
|
frontmatter_data['tags'] = card.tags
|
||||||
if card.url and self.obsidian_mode:
|
if card.url and self.obsidian_mode:
|
||||||
|
@ -72,8 +80,9 @@ class CardFileFormatter:
|
||||||
return frontmatter.dumps(fm)
|
return frontmatter.dumps(fm)
|
||||||
|
|
||||||
def parse_card_contents(self, contents: str) -> CardContents:
|
def parse_card_contents(self, contents: str) -> CardContents:
|
||||||
"""
|
"""Parses card contents.
|
||||||
1. Strips frontmatter
|
|
||||||
|
1. Strips frontmatter and parses certain fields from the header.
|
||||||
2. Parses header
|
2. Parses header
|
||||||
3. Finds content.
|
3. Finds content.
|
||||||
"""
|
"""
|
||||||
|
@ -100,6 +109,7 @@ class CardFileFormatter:
|
||||||
|
|
||||||
description = self.renderer.render_children(document).strip()
|
description = self.renderer.render_children(document).strip()
|
||||||
return CardContents(
|
return CardContents(
|
||||||
|
None,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user