feat: activity sidecar edits via bincio edit --serve
- bincio/render/merge.py: parse sidecar .md files (YAML frontmatter +
markdown body), produce data/_merged/ with symlinks for unmodified
activities and real merged files for overridden ones; filters private
activities from index.json; sorts highlighted activities first.
Keeps extracted data pristine — re-running extract never clobbers edits.
- bincio/edit/: FastAPI edit server (port 4041) with embedded HTML/JS
edit UI; GET/POST /api/activity/{id} reads/writes sidecars; multipart
image upload to edits/images/{id}/; DELETE for image cleanup.
- bincio render now calls merge_all() before build/serve and symlinks
public/data → data/_merged/ instead of data/ directly.
- ActivityDetail.svelte: edit button (links to edit server) when
PUBLIC_EDIT_URL env var is set; respects custom.hide_stats to suppress
stat panels; description supports whitespace-preserving rendering.
- 15 unit tests covering parse_sidecar, apply_sidecar, and merge_all.
This commit is contained in:
+17
-4
@@ -61,11 +61,23 @@ def _ensure_npm(site: Path) -> None:
|
||||
subprocess.run(["npm", "install"], cwd=site, check=True)
|
||||
|
||||
|
||||
def _merge_edits(data: Path) -> None:
|
||||
"""Run the sidecar merge step, producing data/_merged/."""
|
||||
from bincio.render.merge import merge_all
|
||||
n = merge_all(data)
|
||||
if n:
|
||||
console.print(f"Merged [cyan]{n}[/cyan] sidecar edit(s) into _merged/")
|
||||
else:
|
||||
console.print("No sidecars found — _merged/ mirrors extracted data.")
|
||||
|
||||
|
||||
def _link_data(site: Path, data: Path) -> None:
|
||||
"""Symlink the BAS data store into site/public/data."""
|
||||
"""Symlink site/public/data → data/_merged/ (the post-merge output)."""
|
||||
merged = data / "_merged"
|
||||
target = merged if merged.exists() else data
|
||||
public_data = site / "public" / "data"
|
||||
if public_data.is_symlink():
|
||||
if public_data.resolve() == data:
|
||||
if public_data.resolve() == target.resolve():
|
||||
return # already correct
|
||||
public_data.unlink()
|
||||
elif public_data.exists():
|
||||
@@ -74,8 +86,8 @@ def _link_data(site: Path, data: Path) -> None:
|
||||
"remove it manually if you want bincio to manage it."
|
||||
)
|
||||
return
|
||||
public_data.symlink_to(data)
|
||||
console.print(f"Linked data: [cyan]{data}[/cyan] → [cyan]{public_data}[/cyan]")
|
||||
public_data.symlink_to(target)
|
||||
console.print(f"Linked data: [cyan]{target}[/cyan] → [cyan]{public_data}[/cyan]")
|
||||
|
||||
|
||||
@click.command()
|
||||
@@ -108,6 +120,7 @@ def render(
|
||||
console.print(f"Data: [cyan]{data}[/cyan]")
|
||||
|
||||
_ensure_npm(site)
|
||||
_merge_edits(data)
|
||||
_link_data(site, data)
|
||||
|
||||
env = {**os.environ, "BINCIO_DATA_DIR": str(data)}
|
||||
|
||||
Reference in New Issue
Block a user