Import / Delete a Tiddler dynamically

Hello,
I am using the TiddlyWiki as a reference book and I have to use the stand alone version.
My idea is to import (and may be also delete but this is optional) Tiddler only if requested by the user. The chapters of the reference book are not always interesting for all users and so it would be possible to reduce the size of the file.

Is that possible to have

  1. an import function e.g. by pressing a link or a button
    and
  2. a delete function by closing / leaving a tiddler?

Thx in advance for your answers
Stefan

Hello, Stefan, I have two quick thoughts, though I’m sure others have more expertise.

One idea is to have your various “heavy” source materials in a separate TiddlyWiki (ideally an external core TiddlyWiki – or even multiple such files, if dividing the content makes sense). If that extarnal wiki is accessed by opening a tiddler containing an iframe, then none of that additional content will load until that particular iframe tiddler is opened.

Another is that if it’s really about the file size of your main tiddlywiki file (rather than load speed of total solution), then you could try a solution by @saqimtiaz for loading remote tiddlers. (I don’t have quick notes about how to find it here, but I do have a proof-of-concept implementation here. In my version, the remote tiddlers load at startup. I haven’t tried having remote tiddlers load later.)

Here’s another related thread, though I think it’s mostly about how image-loading is handled: Is "content-visibility:auto" relevant to speed up TW?

It may be relevant to know how you’re serving up this solution. You’ve implied that node.js is not an option, but is this reference being delivered and accessed over internet? What exactly is the file-size concern?

If you use nodejs version, you can setup lazy loading.

Otherwise there don’t seem to exist a solution for this. While you can write JS to call $tw.wiki.addTiddler function to add tiddler dynamically. See Using external JS Libraries in TW Plugins - #13 by linonetwo

I read some other discussions here and I think it is possible.
So I found this here (copied and adapted from other threads), but I am unable to give over the file name xxx.tid. :roll_eyes:

<$button actions=<<$action-sendmessage $message="tm-perform-import" $param="$:/Import" $autoOpenOnImport="yes"/>> >
import
</$button>

Hi Springer,

thanks for our answers.
Why I cannot use the node.js is, that finally (in a few weeks) the wiki will used on a Sharepoint (company) server as aspx file. Actually we are testing some sandbox files and the results are GREAT :partying_face: The acceptance by the users is outstanding :star_struck:

Of course it could be possible to spilt the files but this will extend the service expense. One of the ideas here is that we have one production wiki and some development wikis managed by different teams. If the content in one the development wikis is released the tiddler will be exported and stored in a folder. As the editor agreed with the team about the file name the content at the beginning of the process it is easy to manage the the file by replacing the file.

I found some similar discussions here with tm-perform-import but have no final solution found yet.

Hi linonetwo,

I cannot use the node.js version because the final version will be used on n Sharepoint (company) server. :slightly_smiling_face:

Hi Stefan,
Did you have a closer look at: https://tiddlywiki.com/#Alice%20in%20Wonderland tiddler.

It uses the “_canonical_uri” field to “import” a tiddler on demand. You can search tiddlywiki.com for this term to find more info. eg: How to embed PDFs or external images

IMO you should be able to run some tests with that info.

So the whole “hokus pokus” is done to reduce service cost? Can you be more specific, how the service costs are calculated?

1 Like

Hi Mario,

the idea is good but not working for me.

I created a tiddler xxx.tid

caption: Welcome
created: 20230522085558890
creator: Stefan Pazdera
modified: 20230522085628576
modifier: Stefan Pazdera
tags: TableOfContents
title: 0.0.0.0. Welcome 1

\define myActions()
<$action-listops $tiddler="Inhaltsverzeichnis" $tags="+$:/tags/SideBar"/>
<$action-listops $tiddler="TableOfContents" $tags="-$:/tags/SideBar"/>
<$action-setfield $tiddler="$:/language" text="$:/languages/de-DE"/>
<$action-navigate $to="0.0.0.1. Willkommen"/>
\end

<$tiddler tiddler="Inhaltsverzeichnis">
<$button actions=<<myActions>> >
Switch to GERMAN 
</$button>
</$tiddler>

This wiki is based on the ~OpenSource project [[TiddlyWiki|https://tiddlywiki.com/]].

and a My Alice Tiddler:

Unfortunatly this message appear:

Trying to load external content from 0.0.0.0. Welcome 1.tid

If this message doesn't disappear, either the tiddler content type doesn't match the type of the external content, or you may be using a browser that doesn't support external content for wikis loaded as standalone files. See https://tiddlywiki.com/#ExternalText

Than I changed the xxx.tid to a html version (I do not bring the html code here it is to long) and I also changed the content-type field to “html”.

The good thing is, it will be shown correct. But the button is not working (also links to other tiddlers) :frowning:
I am still looking to solve it via $:/Import as described above but still unable to handover the information to use xxx.tid.

<$button actions=<<$action-sendmessage $message="tm-perform-import" $param="$:/Import" $autoOpenOnImport="yes"/>> >
import
</$button>

Hi Mario,

the expence is mainly calculated by working time of the editor to manage the content.
We don’t want to have moderated workshops to have the content availabe. The teams needs to be indepentent as much as possible.

tm-perform-import is a command that expects the content to be already loaded from the server to the client. It does not activate any “read from server” action.

Since you wrote, that an xxx.html file could be loaded into TW I do suspect there is a permission problem.

IMO this attempt tm-xxx-import will be “blocked” by the same mechanism that prevents the _canonical_uri from loading a .tid file. I don’t know for sure, but I think the sharepoint server just “blocks the xxx.tid” GET command. I can not test atm, since I don’t have a sharepoint account atm.


I suppose, you do not want to open a browser “load file dialogue”. right?

Hi Mario,
you are 100% right I cannot have a dialog.

I found this discussion : Choose a default directory with the <$browse> widget - Discussion - Talk TW (tiddlywiki.org)

I copied this source to a sandbox Tiddler:

\define rename-import(new-name)
<$action-sendmessage $message="tm-perform-import" $param="$:/Import"/>

<$action-sendmessage $message="tm-rename-tiddler" from={{{[[$:/Import]links[]first[]]}}} to=$new-name$/>

<$action-setfield $tiddler=$new-name$ tags=[[Image]]/>
\end

\define image-block(image-name)
<$navigator>
<$browse />
</$navigator>

<$list filter="[[$:/Import]plugin-type[import]]">
<$button actions=<<rename-import $image-name$>>>
import
</$button>
</$list>

Image name : [[$image-name$]]
{{$image-name$}}
\end

<<image-block "plop">>

If I select my xxx.tid and press the import button than I got (more or less) in the “plop” Tiddler my xxx.tid imported.
Now my question is (sorry I am not a developer for web based content) is :

> What I have to add/remove/change in this code to import xxx.tid without having a dialog before pressing the “Import” button?

Exported in what format? If it is .json, maybe you can serve them using a static server, and fetch them, then pass the json to $tw.wiki.addTiddler. This can be done in a html wiki. And this process can be written as a JS tiddlywiki plugin.

And this reminds me of TiddlyWeb service, that loads user note from a server.

If your company needs consultant, perhaps you can set a contract with What is Jeremy’s business model? ?

And what does

manage the the file by replacing the file.

mean?

Hi linonetwo,

Tiddlywiki, among other wiki solutions, is currently undergoing an evaluation to see if the requirements that are needed are met.
Only when TiddlyWiki proves viable will the company even consider investing in any way.
There are still major hurdles in terms of maintenance and service costs. In particular because the use of many TiddlyWikis is possible.

To answer your question:
If I have a button (or something similar) what is importing the external file “./team_1/xxx.tid” once implemented, than I can change the “xxx.tid” without changing the origin Wiki file.
Why? The Wiki is based in a folder with limited access rights only the editors can make changes. The folder team_1 (and other) can have access rights for different teams. Therfore no additional service is required by the editor.
And, secondally, the Wiki file keeps smallm due to the fact that the, espected huge files from the teams, will be imported only by request.

Stefan

1 Like
  • I have implemented TiddlyWiki for a client in SharePoint and would be happy to assist.
  • I suspect there are other ways to tackle the workflow you are seeking be it manual or partially automated, however I don’t understand the business requirements enough to explore all the possibilities.

I am guessing, based on limited information, but my suspicion is you can leverage existing mechanisms, such as the Import mechanism or drag and drop in including to or from an iframe, but with custom interventions to make it easier for non tiddlywiki enthusiasts.

Continuing the discussion from Import / Delete a Tiddler dynamically:

I made some progress to import a tiddler by pressing a button and also identified the last hurdle to overcome.

This code is working fine, and after the selction and pressing the import button the tiddler will be opened:

<$navigator>
<$browse/>
</$navigator>

<$button>

<$list filter="[[$:/Import]plugin-type[import]]">
<$action-sendmessage $message="tm-perform-import" $param="$:/Import"/>
<$action-navigate $to={{{[[$:/Import]links[]first[]]}}}/>
</$list>

Import
</$button>

I know also that the BrowseWidget is passing the files will in the JavaScript object event.target.files.

Is it possible bypass the dialog and to fill the object event.target.files directly?

Any experiances here?

A short answer;

  • There are limitations to stop security breaches allowing files to be opened or imported without the use of an interactive dialogue.
  • My work around is to store the full path and filename and on click, copy this to the clipboard, then in the open (or save dialogue) ctrl-V to paste the full path and filename then open/save.

I think it will help if you understand that $Navigator didn’t just provide a file selection dialog. After you select the file, $Navigator actually imports the selected file into an intermediate format in the tiddler “$:/Import” (with field “Plugin-type”=“import”) which can be used for import preview. You can verify this by editing the tiddler “$:/Import” after you have selected the file and BEFORE you press your “Import” button.

The tm message “tm-perform-import” didn’t trigger the importing of the selected file, it triggers the conversion of those already imported intermediate tiddlers in “$:/Import” into actual tiddlers.

So the dialog and file importing goes together in $Navigator. It is implemented that way in the underlying js/browser.

Hi https://talk.tiddlywiki.org/u/jacng,

So far understood.
What I don‘t understand is why it is not possible to load a defined tiddler by pressing a button.
Why the user has to perform a dialog and selection process before?

Stefan

It’s because of user awareness. Browser want to make sure, that users are aware what’s going on so they can decide what happens with their data. … The behaviour is primarily controlled by internal browser privacy and security protection mechanisms.

SharePoint has a REST API, that can be used to load files without those dialogues. I think it should be possible to use a _canonical_uri configuration, that would allow us to load .tid files. … But there is still a chance that access to .tid files is blocked on the server level. … Reading and understanding the docs and some experiments will be needed.

At the moment TW uses an internal function that is activated if a _canonical_uri is detected. IMO this function will need to be adjusted to know how to access the SharePoint API.