Slugify + auto-uniquify template/script slug changes and rename published files #81
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: Audit section 2.12.
bDS2: templates:
resolve_next_slug(../bDS2/lib/bds/templates.ex~line 195) slugifies the requested slug and auto-uniquifies (suffix -2, -3…) excluding self;build_update_attrsupdates file_path totemplates/{new_slug}.liquid; side-effect sync rewrites/renames the published file. Scripts mirror this in../bDS2/lib/bds/scripts.ex(script_file_path(slug)on update, ~line 117 area).Current behaviour (RuDS):
engine/template.rsupdate_templateandengine/script.rsupdate_scripttake the raw new slug (no slugify), return a Conflict error if taken (instead of uniquifying), and never updatefile_pathor move the published.liquid/.luafile — after a slug change on a published template/script, the DB row points at the old path and rebuild/diff sees an orphan.Task: For both templates and scripts: slugify input, auto-uniquify excluding self, update file_path, and for published rows rename/rewrite the file atomically (delete old path). Keep version bump + events. Add matching tests. Note file rename must also be reflected in generated-file expectations if any.
Acceptance: Tests: slug change on draft (no file) and on published (file renamed, old gone, content preserved); duplicate title input auto-uniquifies instead of erroring.
Implemented in
8a6274e. Template and script slug edits now use bDS2-compatible slug normalization and collision suffixing while excluding the edited entity. Published source files are atomically rewritten at the new canonical path with their bodies preserved and the old path removed; draft records remain fileless. Template reference cascades, version bumps, domain events, desktop/TUI/script-host callers, README documentation, and Allium UpdateTemplate/UpdateScript obligations were kept in sync. Verified against issue #81, bDS2, and Allium with focused draft/published/collision/self-exclusion/UI tests, allium check/analyse, formatting, cargo check, cargo machete, cargo build, and cargo test --workspace.