docs: add updatelinksonrename example plugin#508
Open
skirmess wants to merge 1 commit into
Open
Conversation
Add an example plugin that rewrites WikiLinks pointing to a page when that page is renamed, using the page_renamed hook. Implements the request from discussion redimp#210 / issue redimp#228. Scope is limited to WikiLinks (matching what the referencingpages example can discover); plain Markdown links and attachments (redimp#65) are left untouched. A per-rename checkbox is not exposable via the plugin API, so an UPDATE_LINKS_ON_RENAME config flag (default on) allows opting out without uninstalling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
|
Hey @skirmess, thanks for this PR. Will test, review, and come back to you. |
Contributor
Author
|
Yes, that would probably make sense to have it in core (it's more a bug fix than a new feature). But I'm not a Python dev, I can't even really read it - and I'm not going to use AI to edit someone else's software if I don't understand what the change does. :-) That's why I asked Claude to write a plugin. Because I wanted that feature now. You can implement it in core, with or without using part of this MRs code. Or add the plugin to the repo. Or close the MR. All fine with me. Claude wrote it, I just tested it on my installation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an example plugin under
docs/plugin_examples/that updates WikiLinks when a page is renamed, implementing the request from #210 / #228.What it does
On rename, the plugin hooks into
page_renamedand rewrites every WikiLink ([[...]]) across the wiki that points to the old page so it points to the new name. Matching usesget_filename()(the same resolver Otter Wiki uses), so it is case-, slash- and.md-insensitive, and#anchors and explicit[[title|link]]titles are preserved.Scope / limitations
referencingpagesexample can discover. Plain Markdown links ([text](/Page)) are intentionally left untouched.UPDATE_LINKS_ON_RENAMEconfig flag (default on) lets you disable it without uninstalling — handy when the plugin is baked into a Docker image.Tests
Adds
tests/test_plugin_updatelinksonrename.pycovering the rewrite (anchor + title preserved, unrelated links untouched) and the opt-out flag. I noticed the example plugins currently have no tests, so happy to drop it or move things around if you'd rather keep them test-free.