Settings: per-user default for download_disabled
New pref download_disabled_default (stored in user_prefs + mirrored to _user_settings.json for the render pipeline). When true, apply_sidecar marks all activities as download_disabled unless the sidecar explicitly sets download_disabled: false (per-activity opt-in from the edit drawer). Settings page gets an "Activity defaults" card with the toggle.
This commit is contained in:
+15
-4
@@ -69,7 +69,7 @@ def parse_sidecar(path: Path) -> tuple[dict, str]:
|
||||
return {}, text.strip()
|
||||
|
||||
|
||||
def apply_sidecar(detail: dict, fm: dict, body: str) -> dict:
|
||||
def apply_sidecar(detail: dict, fm: dict, body: str, *, download_disabled_default: bool = False) -> dict:
|
||||
"""Apply sidecar overrides to a detail JSON dict. Returns a modified copy."""
|
||||
from bincio.extract.writer import _infer_indoor_title
|
||||
d = dict(detail)
|
||||
@@ -97,8 +97,12 @@ def apply_sidecar(detail: dict, fm: dict, body: str) -> dict:
|
||||
d["privacy"] = "unlisted" if fm["private"] else detail.get("privacy", "public")
|
||||
if "hide_stats" in fm:
|
||||
d["custom"]["hide_stats"] = [str(s) for s in (fm["hide_stats"] or [])]
|
||||
if "download_disabled" in fm:
|
||||
dd = fm.get("download_disabled") # True, False, or None (absent)
|
||||
if dd is True:
|
||||
d["download_disabled"] = True
|
||||
elif dd is None and download_disabled_default:
|
||||
d["download_disabled"] = True
|
||||
# dd is False → explicit per-activity opt-in, leave unset
|
||||
|
||||
return d
|
||||
|
||||
@@ -239,6 +243,13 @@ def _merge_all_locked(data_dir: Path) -> int:
|
||||
merged_dir = data_dir / "_merged"
|
||||
merged_acts = merged_dir / "activities"
|
||||
|
||||
_settings_path = data_dir / "_user_settings.json"
|
||||
try:
|
||||
_user_settings = json.loads(_settings_path.read_text(encoding="utf-8")) if _settings_path.exists() else {}
|
||||
except (OSError, json.JSONDecodeError):
|
||||
_user_settings = {}
|
||||
_dl_default: bool = bool(_user_settings.get("download_disabled_default", False))
|
||||
|
||||
# Collect sidecars upfront
|
||||
sidecars: dict[str, tuple[dict, str]] = {}
|
||||
if edits_dir.exists():
|
||||
@@ -287,9 +298,9 @@ def _merge_all_locked(data_dir: Path) -> int:
|
||||
detail = json.loads(src.read_text(encoding="utf-8"))
|
||||
if activity_id in sidecars:
|
||||
fm, body = sidecars[activity_id]
|
||||
detail = apply_sidecar(detail, fm, body)
|
||||
detail = apply_sidecar(detail, fm, body, download_disabled_default=_dl_default)
|
||||
else:
|
||||
detail = apply_sidecar(detail, {}, "")
|
||||
detail = apply_sidecar(detail, {}, "", download_disabled_default=_dl_default)
|
||||
if activity_id in image_lists:
|
||||
detail["custom"] = dict(detail.get("custom") or {})
|
||||
detail["custom"]["images"] = image_lists[activity_id]
|
||||
|
||||
Reference in New Issue
Block a user