Is there any solution to do extra operation on tiddler import?

68 views
Skip to first unread message

Mohammad

unread,
Jan 4, 2019, 3:37:56 AM1/4/19
to TiddlyWiki
Is there any solution to do extra operation on tiddler import?

Assume you have imported several tiddlers by drag and drop or using sidebar/tools/import button and before clicking on the Import button on $:/import you want to add a tag e.g. "sandbox"
to be able undo the import operation later on.

How can I do this?


--Mohammad

TonyM

unread,
Jan 4, 2019, 5:16:18 AM1/4/19
to TiddlyWiki
Mohammad,

There is a way I discovered, but I have not completed the solution I am building.

If you import some tiddlers, even a json file you will see that the $:/Import tiddler is created. Editing this it looks like a json tiddler, not only with a list of tiddlers, but containing the data to create such tiddlers once the import button is pressed.

The import buttons are made visible in the View template if the following filter is true ""[all[current]field:plugin-type[import]]" as can be seen in

 $:/core/ui/ViewTemplate/import tagged with $:/tags/ViewTemplate Which show the buttons above and below {{||$:/core/ui/ImportListing}}


$:/core/ui/ImportListing renders the table of tiddlers contained there in the $:/Import


On completion of the import $:/Import text is replaced with a list of the imported tiddlers.

Thus you can over ride the Shadow Tiddler $:/core/ui/ViewTemplate/import to add to the import page view and/or $:/core/ui/ImportListing for header and footer, even row column updates to the import process.

In my planned design 
  • I will use a tag to identify Import Columns which will appear on the Import view by editing $:/core/ui/ImportListing allowing additional columns to be added both for more info on potential imports and selections
  • I hope also allow filtering of the potential import items by values contained withing the potential import tiddlers.
This should send you on your way, but perhaps we can compare notes.

Regards
Tony

Mohammad

unread,
Jan 4, 2019, 5:25:50 AM1/4/19
to TiddlyWiki
Hi Tony!
 Good hints! Let me have a look at those core tiddlers. I think I may create a duplicate and work on them.
BTW, I think this feature is good to be incorporated in core: i.e having options to tag, even add suffix or prefix to the name of imported tiddler and like that.

Cheers
Mohammad

TonyM

unread,
Jan 4, 2019, 5:49:39 AM1/4/19
to TiddlyWiki
Totally agree, that is why I have started researching it.

Another feature would be recording the source in the imported tiddlers, ensuring no overwrites, only prefix when needed etc...Allow import versions and more.

Regards
Tony

Jed Carty

unread,
Jan 4, 2019, 6:39:46 AM1/4/19
to TiddlyWiki
I have something like this implemented for the server images plugin. It hooks into the import mechanism and makes changes to the tiddler. For that it saves the image on a server but having it change the tiddler title or make other modifications to fields should be relatively straight forward. The relevant bits of code are here: https://github.com/OokTech/TW5-ServerImages/blob/master/ServerImages.js

You would have to have some way to determine how to define the prefix because the import doesn't get much information about the source of the tiddlers.

TonyM

unread,
Jan 4, 2019, 7:10:25 AM1/4/19
to TiddlyWiki
Jed,

Of course if the tiddlers contained a source field with a value you could use that. I have started using bundlename.bundle tiddlers containing a source field and including that in exported bundles.

Regards
Tony

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages