Skip to content

docs: add updatelinksonrename example plugin#508

Open
skirmess wants to merge 1 commit into
redimp:mainfrom
skirmess:plugin-updatelinksonrename
Open

docs: add updatelinksonrename example plugin#508
skirmess wants to merge 1 commit into
redimp:mainfrom
skirmess:plugin-updatelinksonrename

Conversation

@skirmess

Copy link
Copy Markdown

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_renamed and rewrites every WikiLink ([[...]]) across the wiki that points to the old page so it points to the new name. Matching uses get_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

  • Only WikiLinks are rewritten — matching what the bundled referencingpages example can discover. Plain Markdown links ([text](/Page)) are intentionally left untouched.
  • Exact match of the renamed page only; child pages and attachment links (Renaming attachments should updated links in pages. #65) are not touched (child pages aren't moved by a rename, so links to them stay valid).
  • A per-rename checkbox (as floated in When a page is renamed, update links to it in other pages' files? #210) isn't exposable via the current plugin API, so an UPDATE_LINKS_ON_RENAME config 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.py covering 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.

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>
@skirmess skirmess mentioned this pull request Jun 16, 2026
@redimp

redimp commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Hey @skirmess, thanks for this PR. Will test, review, and come back to you.

@ribbal

ribbal commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

My thoughts on this is that it should be part of the Otter Wiki core functionality. What do you think @redimp, @skirmess?

Or, am I fundamentally missing something?

I'm sure @skirmess's good work could still be re-used.

@skirmess

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants