From a2c01e251ca3f3e05659b809c5035a595b6b1db7 Mon Sep 17 00:00:00 2001 From: Offray Date: Thu, 4 Apr 2024 12:08:06 -0500 Subject: [PATCH] Renaming external media links. --- repository/TiddlyWiki/Tiddler.class.st | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/repository/TiddlyWiki/Tiddler.class.st b/repository/TiddlyWiki/Tiddler.class.st index c8d7fce..0ce89a9 100644 --- a/repository/TiddlyWiki/Tiddler.class.st +++ b/repository/TiddlyWiki/Tiddler.class.st @@ -482,6 +482,23 @@ Tiddler >> removeTag: aTag [ ^ self ] +{ #category : #accessing } +Tiddler >> renameExternalMediaLinksInto: relativePath [ + "This first implementation only renames external media links in custom fields. + Further development should offer the possibility to rename also the external media + appearing in the tiddler's text." + self customFieldsWithMediaLinks keysAndValuesDo: [:customField :oldLink | | link name | + link := oldLink asUrl. + link hasScheme ifFalse: [^ self ]. + name := link segments last copyWithoutAll: '-'. + name := name asDashedLowercase. + name := (relativePath, '/', NanoID generate, '--', name). + self customFields + at: customField, '--original' put: oldLink; + at: customField put: name +]. +] + { #category : #accessing } Tiddler >> revision [ ^ revision