3.8 KiB
3.8 KiB
Page Link Feature Specification
Goals
- Allow linking a Dokuwiki page to a media folder via a stable UUID.
- Enable the
blobsalias so plugin syntaxes can useblobs/*in place of a concrete path when the page is linked. - Keep behavior stable and maintainable; avoid heavy scanning on each page view.
Non-Goals
- Automatic creation of
.pagelinkfiles (user must create manually). - Automatic selection of which folder to link (user decides by placing
.pagelink). - Cross-page bulk management UI.
Core Concept
- Each page can have one UUID stored in page metadata.
- A folder is considered linked to the page if it contains a
.pagelinkfile whose content matches the page’s UUID.
Data Model
- Page metadata key:
pagelinkwith value<UUID>. .pagelinkfile content: a UUID string.- Cache mapping file in plugin cache folder: maps UUID → folder path.
- Cache file format: JSON (human-readable, easy to debug).
- Cache file name:
pagelink_cache.json.
UUID
- UUID is created only via a toolbar button.
- UUID is created once and stored in metadata.
- UUID is v4 lowercase.
- UUID is not shown directly to the user (except for copy-to-clipboard).
UI/UX Behavior
- Above page content (next to pageid), show link status.
- If UUID exists and folder is linked: show the linked folder name.
- If UUID exists but no folder is linked: show a “not linked yet” status.
- Clicking the status copies the UUID to clipboard for easy
.pagelinkcreation. - Status text: "Not linked: Copy ID"
- Copy action does not show anything. No native toasts available
- Clicking the status copies the UUID to clipboard for easy
- If UUID does not exist: no status is shown.
Linking Rules
- Folder can be moved or renamed; link remains as long as
.pagelinkfile stays in that folder. - Deleting the
.pagelinkfile unlinks the folder. - If multiple folders contain the same UUID:
- Page shows a linked status with the first found folder.
- Triangle warning icon appears next to folder name.
Search Scope
- Searches for
.pagelinkfiles are limited to paths under root aliases defined inpathsin admin/main.php. - New setting
pagelink_search_depthlimits maximum depth under each root path.- Example: depth
2means only folders at most 2 levels deep are searched. - Integer value, default
3. - No negative values allowed.
- Example: depth
Cache Strategy
-
Mapping of UUID → folder path is cached in a mapping file for performance.
-
On page load:
- If page has UUID, check cache for linked folder.
- If cache miss, scan folders (within scope) for
.pagelink. - Update cache with any matches.
-
Cache invalidation strategy:
- No automatic cache rebuilds.
- When encountering stale cache entry (moved/deleted folder) while looking for a pages linked folder, remove from cache and rescan.
-
Cache writes are atomic (write temp + rename) and use
LOCK_EX.
Performance Constraints
- Avoid full-tree scans on every page view.
Security & Safety
- Never scan outside configured root paths.
- ignore symlinks.
- Handle unreadable folders/files gracefully (no fatal errors).
Acceptance Criteria
- Clicking toolbar button sets metadata
pagelinkto a valid UUID. - If a matching
.pagelinkexists in a scoped folder,blobs/*resolves to that folder. - If
.pagelinkis deleted, the link is removed on next lookup and UI reflects “not linked yet”. - Cache prevents repeated scans on consecutive page views.
- Search depth obeys
pagelink_search_depth.
Edge Cases
- Page has UUID but
.pagelinkfile is empty or invalid UUID. - Multiple
.pagelinkfiles with same UUID in different folders. - UUID in metadata is malformed.
- Folder contains
.pagelinkbut no read permissions. - Page is deleted/renamed after UUID creation.
Documentation Updates
- Update README to describe the feature, settings, and manual
.pagelinkworkflow.