Is there a trick to trigger an action directly after a file-import with the browse widget?
For example, if I import a media file, can I directly write the title of the newly created tiddler to a tiddler that shows this file in a special template?
Or Tag the newly created tiddler in a special way?
P.S.:Since I saw in the answers that there is no direct way I renamed the thread "feature request"
Currently, there’s no automatic post-import processing. However, it is possible to manually invoke some custom wikitext scripting after files have been imported:
Put the following in a tiddler (e.g., “AfterImportActions”)
<!-- GET A LIST OF IMPORTED TIDDLERS BY PARSING THE "AFTER IMPORT" CONTENTS OF $:/Import -->
<$set name=tids filter="[[$:/Import]get[text]splitregexp[\n]removeprefix[#]enlist-input[]]">
<!-- SHOW A BUTTON TO TRIGGER CUSTOM ACTIONS ON ALL IMPORTED TIDDLERS -->
<$button> do After Import actions
<!-- FOR EACH IMPORTED TIDDLER -->
<$list filter="[enlist<tids>]" variable="tid">
<!-- CUSTOM ACTION EXAMPLE: "If tiddler type is an image, add image tag"
<$list filter="[<tid>is[image]]">
<$action-listops $tiddler=<<tid>> $field="tags" $subfilter="image"/>
</$list>
<!-- END OF CUSTOM ACTIONS -->
</$list>
</$button>
[[$:/Import]links[]] works quite well to extract the titles of imported tiddler after an import. You can add a custom view template to the $:/Import tiddler that displays the button after the import.
Thank you Eric, I also thought on ways to do this with a second click. Or with a third click and a scroll if you count the necessary action with the importpanel.
I will ask whether this is worth a feature-request to add a “silentimport” and an “actions” attribute to the browse widget…
Simply tag any action tiddler with $:/tags/ImportAction. The plugin hooks into the import process (via a startup module) and executes your actions on the newly imported tiddlers.
Great minds think a like, I was working on something similar to allow more advanced installation scripts such as running a monkey patch rather than replace core tiddlers.
I made a simple run once or run many times on import, basically a trigger but on import or install I think it is best practice to prompt the user.
I find bookmarklets are a good way to do a silent install, but they should prompt before triggering actions.