This commit is contained in:
nose
2025-12-11 23:21:45 -08:00
parent 16d8a763cd
commit e2ffcab030
44 changed files with 3558 additions and 1793 deletions

View File

@@ -79,7 +79,7 @@ class TUIResultCard:
subtitle: Optional[str] = None
metadata: Optional[Dict[str, str]] = None
media_kind: Optional[str] = None
tags: Optional[List[str]] = None
tag: Optional[List[str]] = None
file_hash: Optional[str] = None
file_size: Optional[str] = None
duration: Optional[str] = None
@@ -88,8 +88,8 @@ class TUIResultCard:
"""Initialize default values."""
if self.metadata is None:
self.metadata = {}
if self.tags is None:
self.tags = []
if self.tag is None:
self.tag = []
@dataclass
@@ -164,7 +164,7 @@ class ResultTable:
>>> row = result_table.add_row()
>>> row.add_column("File", "document.pdf")
>>> row.add_column("Size", "2.5 MB")
>>> row.add_column("Tags", "pdf, document")
>>> row.add_column("Tag", "pdf, document")
>>> print(result_table)
"""
@@ -425,12 +425,12 @@ class ResultTable:
if hasattr(result, 'media_kind') and result.media_kind:
row.add_column("Type", result.media_kind)
# Tags summary
# Tag summary
if hasattr(result, 'tag_summary') and result.tag_summary:
tags_str = str(result.tag_summary)
if len(tags_str) > 60:
tags_str = tags_str[:57] + "..."
row.add_column("Tags", tags_str)
tag_str = str(result.tag_summary)
if len(tag_str) > 60:
tag_str = tag_str[:57] + "..."
row.add_column("Tag", tag_str)
# Duration (for media)
if hasattr(result, 'duration_seconds') and result.duration_seconds:
@@ -494,7 +494,7 @@ class ResultTable:
"""Extract and add TagItem fields to row (compact tag display).
Shows the Tag column with the tag name and Source column to identify
which storage backend the tags come from (Hydrus, local, etc.).
which storage backend the tag values come from (Hydrus, local, etc.).
All data preserved in TagItem for piping and operations.
Use @1 to select a tag, @{1,3,5} to select multiple.
"""
@@ -505,7 +505,7 @@ class ResultTable:
tag_name = tag_name[:57] + "..."
row.add_column("Tag", tag_name)
# Source/Store (where the tags come from)
# Source/Store (where the tag values come from)
if hasattr(item, 'source') and item.source:
row.add_column("Store", item.source)
@@ -527,12 +527,12 @@ class ResultTable:
file_str = "..." + file_str[-57:]
row.add_column("Path", file_str)
# Tags
if hasattr(obj, 'tags') and obj.tags:
tags_str = ", ".join(obj.tags[:3]) # First 3 tags
if len(obj.tags) > 3:
tags_str += f", +{len(obj.tags) - 3} more"
row.add_column("Tags", tags_str)
# Tag
if hasattr(obj, 'tag') and obj.tag:
tag_str = ", ".join(obj.tag[:3]) # First 3 tag values
if len(obj.tag) > 3:
tag_str += f", +{len(obj.tag) - 3} more"
row.add_column("Tag", tag_str)
# Duration
if hasattr(obj, 'duration') and obj.duration:
@@ -560,7 +560,7 @@ class ResultTable:
- type | media_kind | kind
- target | path | url
- hash | hash_hex | file_hash
- tags | tag_summary
- tag | tag_summary
- detail | description
"""
# Helper to determine if a field should be hidden from display
@@ -568,7 +568,7 @@ class ResultTable:
# Hide internal/metadata fields
hidden_fields = {
'__', 'id', 'action', 'parent_id', 'is_temp', 'path', 'extra',
'target', 'hash', 'hash_hex', 'file_hash', 'tags', 'tag_summary', 'name'
'target', 'hash', 'hash_hex', 'file_hash', 'tag', 'tag_summary', 'name'
}
if isinstance(field_name, str):
if field_name.startswith('__'):
@@ -1220,12 +1220,12 @@ class ResultTable:
title = col.value
metadata[col.name] = col.value
# Extract tags if present
tags = []
if "tags" in metadata:
tags_val = metadata["tags"]
if tags_val:
tags = [t.strip() for t in tags_val.split(",")][:5]
# Extract tag values if present
tag = []
if "Tag" in metadata:
tag_val = metadata["Tag"]
if tag_val:
tag = [t.strip() for t in tag_val.split(",")][:5]
# Try to find useful metadata fields
subtitle = metadata.get("Artist", metadata.get("Author", ""))
@@ -1239,7 +1239,7 @@ class ResultTable:
subtitle=subtitle,
metadata=metadata,
media_kind=media_kind,
tags=tags,
tag=tag,
file_hash=file_hash or None,
file_size=file_size or None,
duration=duration or None