WidgetMessage: tm-perform-import deletes import tiddler?

33 views
Skip to first unread message

TonyM

unread,
Jul 24, 2019, 10:57:01 PM7/24/19
to TiddlyWikiDev
Folks,

I am building a way to import into a permanent json tiddler, and subsequently extract the tiddlers.

I am building the extract process now and went to use the WidgetMessage: tm-perform-import

It seems that this message automatically deletes the source tiddler. Is there any way to override this behaviour?

Alternatively I could clone this to a new widget eg tm-perform-extract that does not delete the source tiddler.

Thank in Advance
Tony

Jeremy Ruston

unread,
Jul 25, 2019, 7:51:42 AM7/25/19
to TiddlyWikiDev
Hi Tony

I am building a way to import into a permanent json tiddler, and subsequently extract the tiddlers.

This is really part of the discussion about unrolling some internal logic so that it is expressed in wikitext, and can be more easily customised.


I am building the extract process now and went to use the WidgetMessage: tm-perform-import

For this kind of thing you may find looking at the code helpful. If you search for “tm-perform-import” across the repo, there’s a single match in a JS file:


The reference to “handlePerformImportEvent” ends up here:


It’s important to understand that the $:/Import tiddler must conform to the format of a plugin, it’s not a generic JSON tiddler. It’s a temporary holding cell for incoming tiddlers. Note that it holds the tiddlers that are to be imported, not the original data that was dropped.

With that out of the way, the actions of handlePerformImportEvent are:

* Import those tiddlers where field named “selection-“ plus the title of the tiddler does not contain the string “unchecked”. So the field “selection-HelloThere” is used to hold the status of the checkbox next to the tiddler “HelloThere”.
* Replace the $:/Import tiddler with a report of which tiddlers were imported
* Navigate to $:/Import
* Trigger an autosave event

It seems that this message automatically deletes the source tiddler. Is there any way to override this behaviour?

Not at present, but we could conceivably add parameters to the message that allow finer control over the actions performed.

Alternatively I could clone this to a new widget eg tm-perform-extract that does not delete the source tiddler.

As ever, you’d be best making a plan that doesn’t require core modifications up front. In this case, that means making a plugin that does the new stuff, if necessary copying and pasting code from the core.

Best wishes

Jeremy





Thank in Advance
Tony

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/a4ed7117-404e-4566-b34f-0ecefbdc9dd7%40googlegroups.com.

TonyM

unread,
Jul 25, 2019, 8:31:16 PM7/25/19
to TiddlyWikiDev
Jeremy,

Thanks. Yes I did find tm-perform-import and the code. 


This is really part of the discussion about unrolling some internal logic so that it is expressed in wikitext, and can be more easily customised.


Totally agree and this is why I raised it at this point in time.

 It’s important to understand that the $:/Import tiddler must conform to the format of a plugin, it’s not a generic JSON tiddler. It’s a temporary holding cell for incoming tiddlers. Note that it holds the tiddlers that are to be imported, not the original data that was dropped.

I see this but I not so sure I understand the implications "conform to the format of a plugin" other than it has a plugin type.
 
With that out of the way, the actions of handlePerformImportEvent are:

1. Import those tiddlers where field named “selection-“ plus the title of the tiddler does not contain the string “unchecked”. So the field “selection-HelloThere” is used to hold the status of the checkbox next to the tiddler “HelloThere”.
2. Replace the $:/Import tiddler with a report of which tiddlers were imported
3. Navigate to $:/Import
4. Trigger an autosave event

It seems that handlePerformImportEvent is doing a lot and perhaps it could be opened up a bit. I have bypassed Step 2 by providing a button that allows $:/import to be copied to a json tiddler before it is replaced. 
It seems that this message automatically deletes the source tiddler. Is there any way to override this behaviour?
Not at present, but we could conceivably add parameters to the message that allow finer control over the actions performed.

Perhaps this could stay as is and we provide an other message(s) that opens the hackability of the import process, features can already be added to the existing import mechanism with an additional view template item as I have done, or modifying the existing import view template. The need for more hackability exists to do things like;
  • Silent Import on StartActions
  • Click to import from URL with or without selection
  • Import filename text, json, tid file to a tiddler as the tiddlers body or other field - without extracting tiddlers.
 
As ever, you’d be best making a plan that doesn’t require core modifications up front. In this case, that means making a plugin that does the new stuff, if necessary copying and pasting code from the core.

I was only trying to do this as a Proof of Concept, but my script kiddy hack failed.

Thanks for your considered response.
Tony
 
Reply all
Reply to author
Forward
0 new messages