Could the browserstorage help avoid users loosing data

This are completely different systems. Noteself uses a library called pouchdb, which uses the browsers Indexed DB.

The local-storage plugin uses the browser local-storage, which is a different thing.


I think the problem with your test version is, that it looses the “Use browser local storage” config setting after a reload. You may try to delete $:/config/BrowserStorage/Enabled tiddler from your file prior to upload it to the server. So the setting can be saved into the local storage.

This is just a guess, since I didn’t play with the plugin for a long time.

1 Like

This is what I say: If I delete $:/config/BrowserStorage/Enabled browserstorage is active and can cause the confusion described above…

Yea, In the mean time I did test it. … The workflow would need to be changed.

From my point of view, the local-storage edition is more like a proof of concept. From my previous tests I also think that the sync mechanism doesn’t work as expected. …

I’m creating a version atm, that is hosted on github and should save back to github using the github saver. … So I can test it a bit better.


Edit:

That’s still the case. … IMO not necessarily a bug, but an extreme inconvenience resulting from the existing “sync” mechanism, that deletes existing tiddlers from the local store.

1 Like

How do the students “post” changes to your server?

I think the local-storage plugin could solve this problem.

That’s right. The local-storage is bound to the machine and probably the user account if they have different log-ins on shared PCs.

That’s a new workflow.

Yes. But I think the plugin would need to be changed, to make it more configurable.

At the moment it does it’s thing and that’s it.

1 Like

Hi Mario,
thanks for your interest and expertise.
Students can post .jsons and .jpgs via custom tailored forms that post to a php backend.
My import works via an Iframe that lists the posts.

1 Like

So in your case it would be needed, that tiddlers are removed from the local-store as soon as they “successfully saved” the xxx-tiddlers.json file. …

At the moment they are removed when the wiki is reloaded in the browser tab and the wiki contains the tiddlers that are also part of the local-store.

I personally would create 2 buttons

  • Save tiddlers from store
  • Remove “saved” tiddlers from store

So there is a possibility to check the json file if everything is OK before the content is removed. … On the other hand, if everything works reliably it can be 1 button, that activates both actions.

Just some thoughts.

It is very good to think of version-control-mechanisms -because this has been the starting-point for the whole debate.
It would be great to have control over the browser-storage.
Deleting the Tiddler after posting it is not really necessary, i.m.o. - I would rather tag it after uploading.
User-created Tiddlers and links in my wiki get the username as a suffix to be safe when importing them to my master-wiki.
Anyhow, it would be great to be able to create a sort of filter / standard-scheme which tiddler wins in case of a conflict between browser-storage and reload.

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