Slugify + auto-uniquify template/script slug changes and rename published files #81

Closed
opened 2026-07-20 19:44:00 +00:00 by hugo · 1 comment
Owner

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_attrs updates file_path to templates/{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.rs update_template and engine/script.rs update_script take the raw new slug (no slugify), return a Conflict error if taken (instead of uniquifying), and never update file_path or move the published .liquid/.lua file — 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.

**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_attrs` updates file_path to `templates/{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.rs` `update_template` and `engine/script.rs` `update_script` take the raw new slug (no slugify), return a Conflict error if taken (instead of uniquifying), and never update `file_path` or move the published `.liquid`/`.lua` file — 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.
hugo added the bug label 2026-07-20 19:44:00 +00:00
Author
Owner

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.

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.
hugo closed this issue 2026-07-21 21:18:47 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#81