Could the browserstorage help avoid users loosing data

It is some disadvantage to living in a +10 DST = +11 timezone because threads I am in can progress a long way. It means a conversation can run down a path that it would not have if I were present in the middle of the night.

As I stated earlier;

In particular you need to change the filter for local storage to ensure specifically $:/config/BrowserStorage/Enabled is saved in local storage.

What I suggest allows this to work without Noteself.

I will endeavour to post an example soon.

On the other response’s in the thread I continue to hold the position this is only a matter of establishing appropriate workflows for students and master alike. I expect its most important to make the students interaction simple and automated, the master can use alternate methods as sophisticated as needed.

I would love access to the code and methods used in the above.

  • I have PHP host and I always wanted to permit “submissions” from otherwise readonly wikis.

Please share and I can evolve the local storage solution I propose on top of it. I currently use Tw-receiver to host wikis on a Php platform.

Note: Whilst reviewing the work on the “File Uploads plugin” there is a suggestion that in the future the wiki will be able to discover files added to the underlying system, and show the external files as tiddlers, that is using your submission system the Master and possibly the Students may be able to see all submissions appear “automagicaly”.

Again with these kind of architectural possibilities, it is only a matter of design on top of tiddlywiki to support the workflows needed. For example giving the master the ability to merge content from the students into the master wiki if desired, to showcase each students contribution.

Could you explain more? I tried at @JanJo’s link (Stickies — a heavyweight mod of stobot's lightweight todo system) and it looks like the filter does nothing to exclude “$:/config/BrowserStorage/Enabled” and I don’t see that tiddler getting saved.

And I looked at the code and it looks like that tiddler is explicitly excluded from being saved to local storage:

var ENABLED_TITLE = "$:/config/BrowserStorage/Enabled"

[...snip...]

      $tw.utils.each(filteredChanges,function(title) {
        // Don't try to save changes to our enabled status
        // (If it were enabled in the file but disabled in local storage then we might 
        // not realise that distributing a copy of the file would have local storage enabled
        // for other users)
        if(title === ENABLED_TITLE) {
          return;
        }
        // Save the tiddler
        saveTiddlerToLocalStorage(title,{
          logger: logger,
          prefix: prefix
        });
      });

@btheado thanks for showing this code, I was confident I had it working in the past. A recent test was fooled by the fact on activating this, the local storage always worked on the next reload.

I have managed to edit the Plugin tiddler to comment out the “offending code”.

			// if(title === ENABLED_TITLE) {
				// return;
			// }
  • It was easier to do this than look at overriding it elsewhere, and which may not work, and this is in $:/plugins/tiddlywiki/browser-storage/startup.js a javascript tiddler with module-type=startup
  • Now it remembers the Local storage state across subsequent reloads.

Unless there is another work around we will need to use a hacked plugin or have the plugin updated. I think there was the design decision that works against us, the plugin could have an additional override configuration with the current behaviour the default, or turn if off for our desired behaviour.

Here is a live demo Wiki with Browser Storage — needs activation

Here is a package of tiddlers required including a hack of the local storage plugin. local-storage-package.json (14.7 KB)

Still to be done, stop the dirty indicator being “thrown”.

Develop the changes only backup and restore process.

Hello Tony,
So I am going to eat a humble pie.
Cool it seems this is what is needed and what I thought to be impossible with the plugin.

Now I have to check the behaviour and see how to delete Tiddlers from there and turn it off.

I will do my part and post and explain php-upload … but in another thread and with a little preparation.
As I say this always has to be a little custom-tailored to fit into your folder-logic and carefully done because php lives on your server and has superpower there.

@JanJo we are all on different journeys and pass different locations, all that is important to share what we learn.

Do keep in mind in my demo I have hacked the plugin. There may be other ways but “A bird in the hand is worth two in the bushes”.

Do tell me what you mean here.

It all depends on if you are referring to Local Storage or file/host storage, but there are no complications I am aware of with tiddler deletion.

I look forward to the PHP upload info, your effort will be returned I am sure because I have a lot to add to a system with this functionality.

I expected this, but perhaps can build some generic solutions once I know how.

Best wishes

I moved my exlpanation how to upload a tiddler with the PHP to a new thread, because it is off-topic here.

Though I am still impressed of what is already possible with Tony's solution, getting rid of unwanted tiddler could be made more comfortable than it is with that solution.

So let us continue the productive research and discussion in this thread!

Next Question: Is there a method

  • to load tiddlers from the browserstorage not after startup but on click
  • to select and delete single tiddlers from the storage
1 Like

I made a mod of the plugin which gives you a button to control the browserstorage and reload.
Thank you @TW_Tones , thank you @EricShulman who helped me on the filter. $ _plugins_mod_browser-storage.json (20.1 KB)

Or even better check it here: browserstorage test — testing browserstorage scenarios because I will be doing the updates there.

I would call this user-browser-storage for the aim is to smoothen the experience for user’s who cannot save the wiki to a server. So it is turned off by default.

But stop! This is not the end of the journey! I would like to modify the dirtyindicator to prevent from warning when leaving and reloading if the browserstorage is avtive.
Any ideas how this can be achieved and integrated to the plugin?

Jumping in here, without having followed the intricacies in this thread, to say that if this ends up in a plugin or solution of general interest for the community then I hope you share it officially. From interpreting/assuming the meaning of the headline, I think everyone would be interested with a good broswerstorage data backup. (But I see mentions of PHP when scanning the conversation so IF “advanced things like that” is involved then it is probably not of general interest, in the same sense.)

I believe I have a few lead’s to achieve this, I just need to test them because there could be unwanted effects; as in the issue;

“Explicitly excluded from being saved to local storage”

It could be as simple as setting
$:/config/SaverFilter to something like “-[all[]]” to stop the dirty indicator. How ever we must check to ensure the local storage and regular save mechanisms are not affected.

  • We may use it like $:/config/BrowserStorage/Enabled where we only keep the overriden value in local storage.

If $:/config/SaverFilter works as described/implied on tiddlywiki.com we have the answer, if not we may need another hack and to update the documentation. See “1.” in https://tiddlywiki.com/#SavingMechanism

1 Like

I think this is also hard-coded into the javascript. The tiddler $:/plugins/tiddlywiki/browser-storage/rawmarkup.js has this code:

    // Make sure that all the tiddlers we've loaded are marked as dirty at startup
    Array.prototype.push.apply($tw.boot.preloadDirty,log);

Where log contains the list of tiddlers which were loaded from local storage.

You could try commenting out that line and see if it helps. I didn’t test it.

Hi @btheado,
Thank you!
I do not know whether this does what I want to happen:
I guess this sets the Tiddlers imported form the browserstorage to a clean state.
I want to deavtivate completely the “you have unsaved changes” message if browserstorage is on…

Hi Mat, hie everybody… I will do so after getting some positive feedback on the usability.

In effect as I said it is a user-fallback-saving-solution, and for users it is now easier to choose what to add, what to keep and what to get rid of off in the browserstorage.

If you are the admin who saves to the server you still should be carefull activating this because of the risc of nagging ghosttiddlers of previous versions, when you were at a different computer meanwhile.

Folks and @JanJo I have returned from time in the bush and hope to progress this a little further. One reason is to package and document a firm solution to avoid difficulties when revisited in the future.

Some notes;

  • Separately from local storage it is important to note tiddlywiki is retained in browser memory just by loading it once, you can go offline and it will still be there, your changes will be retained.
    • For example load a node wiki (without external or skinny tiddlers and loose connection with the server
    • This will not necessarily retain anything if you close the tab and of course you can’t save.
  • I have some dirty indicator tools, one allows a bookmarklet to reset the indicator. This could easily be made an action widget by a javascript plugin author.
  • I can confirm setting $:/config/SaverFilter to “-[all[]]” will stop the dirty indicator being thrown, and local storage will still save changes. I am yet to confirm when we need to do this without forcing a reload but if the aforementioned action widget was available not reload is needed.
    • The wiki owner with save privilege’s will need to reset this to commit protect from loss.
  • It would be wise to load the wiki in a tab with a target name, and bookmark this such that subsequent opening of the site will always open in the save tab.

Additional features

  • Suitable backup and restore changes tool for read only users
    • This includes how to support users if they load a site they did have backups for, but it is lost. We need to prompt them to look for a backup to restore from if it exists, to support this I believe a smart bookmarklet can be used and store the backup location.
  • Suitable “send changes” tool so a local storage only user can send changes for inclusion in the underlying main wiki (Mediated or automatic).
    • Imagine if the changes can be saved to a username folder and the master user can see/import them.

Reset dirty indicator below, create bookmark and put the following in the URL

javascript:(function(){ $tw.saverHandler.numChanges = 0; $tw.saverHandler.updateDirtyStatus(); })();

Hi Tony! Yes that is the aim. I have a workflow for this which I am just testing with a course. It still needs too many clicks. When intensive collaboration startet it was hard to keep an overview over the contents of the folder.
I have been searching for a while for a demo that @saqimtiaz posted on a WebDAV solution which was much more elegant, but I cannot find it anymore.

@JanJo I have continued in creative mode and have being exploring opportunities to help with this form of collaborative tiddlywiki use. I have a number of leads that could make this easy, and reliable for naive users.

This gets somewhat complex very quickly because tiddlywiki presents a lot of opportunities, and of course understanding what users can do or understand, is a dark art rather than a science. Even more so when you include consideration of different browsers, their features/settings and the Operating system.

I am confident there is sufficient opportunity to solve this, for example I have found a way to convert a tiddlywiki found at a URL to generate a unique filename for saving changes. We can add user name into this, to handle a full class of submissions, but then we need to “enforce” the provision of user name.

Do let me know where too many clicks are needed, I imagine I can simplify the process with some of the tricks I have acquired.

Hi Tony, the problem is formulated in this thread.

I just had a look at my import php which has quite a lot of other functions integrated. I think I will build a different approach from scratch that works with dragging.

1 Like

@JanJo I can’t answer that question however can you not go back one level and have the wiki text trigger the http request and then handled the data?

Setup
call httprequest
handle retrieved data

Sounds really interesting, keep up the good work.

Hi @TW_Tones , okay…
If you are willing to go that way
here is the next step of the journey in the php-tutorial:

1 Like

A Trick I have being using is to add an action to the download button that I make, that copies the full path and filename into the clipboard. Once my save as dialogue is presented (Windows 11) ctrl-v pastes the full path and filename and I hit save, it can be done similarly to open a file.

As long as we know the full path and filename (stored in tiddlywiki) we can introduce more interactivity with the local machine.

I wonder if we had an agreed file path eg; \tiddlywiki that we use by default?