feat: tab navigation in modal (Index/Transkript/Zusammenfassung)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,10 +36,15 @@ def save_transcript(
|
||||
|
||||
|
||||
def read_transcript(output_dir: str, filename: str) -> str | None:
|
||||
"""Return file content if filename is a plain .md file inside output_dir."""
|
||||
if os.path.basename(filename) != filename or not filename.endswith(".md"):
|
||||
"""Return file content for a .md file inside output_dir (flat or one level deep)."""
|
||||
if not filename.endswith(".md"):
|
||||
return None
|
||||
parts = filename.split("/")
|
||||
if len(parts) > 2 or any(p in (".", "..") or not p for p in parts):
|
||||
return None
|
||||
path = os.path.join(output_dir, filename)
|
||||
if not os.path.abspath(path).startswith(os.path.abspath(output_dir) + os.sep):
|
||||
return None
|
||||
if not os.path.exists(path):
|
||||
return None
|
||||
with open(path, encoding="utf-8") as f:
|
||||
@@ -57,7 +62,17 @@ def list_transcripts(output_dir: str, limit: int = 20) -> list[dict]:
|
||||
for f in files:
|
||||
full = os.path.join(output_dir, f)
|
||||
stat = os.stat(full)
|
||||
result.append({"filename": f, "path": full, "size": stat.st_size, "mtime": stat.st_mtime})
|
||||
item: dict = {"filename": f, "path": full, "size": stat.st_size, "mtime": stat.st_mtime}
|
||||
if f.endswith("-index.md"):
|
||||
base = f[: -len("-index.md")]
|
||||
related: dict[str, str] = {}
|
||||
for suffix, key in [("-transkript.md", "transkript"), ("-zusammenfassung.md", "zusammenfassung")]:
|
||||
rel_filename = f"{base}/{base}{suffix}"
|
||||
if os.path.exists(os.path.join(output_dir, rel_filename)):
|
||||
related[key] = rel_filename
|
||||
if related:
|
||||
item["related"] = related
|
||||
result.append(item)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user