Jermolene/TiddlyWiki5 — pull request #618 by IreneKnapp (2014-05-17 18:21:01+00:00)
Title: Local storage username

I'm attempting to get TiddlyWiki more useful for multi-person collaboration. As part of that, this patch addresses one of the first things that I noticed when I attempted to share one with someone - which happened to be on TiddlySpot, but it doesn't appear that the breakage was specific to them. Specifically, because our usernames for signing edits were stored in a tiddler, they were saved and synced along with everything else. So we literally couldn't have individual ones!

I noticed that passwords already have the non-syncing property that would be great here, so I looked into how they did it, and generalized the mechanism. I realize it will break compatibility with saver plugins, but I did rename $tw.utils.{get|save}Password to $tw.utils.{get|save}BrowserVariable; I also moved the "password-" portion of the key it's stored under to be specified only in the places where the variable actually holds a password. I somewhat expect that you may want to preserve compatibility by making wrapper functions having the old interface, but since my own tendency is against and it's easy enough, I'll leave that for you. :)

I also forked off widgets/password into widgets/browser-variable - in this case, leaving the old one in place too, since the primary difference is that they use a different type of tag, which still needs to be different and there were too many stylistic decisions to be made in trying to keep them unified.

Finally, I did look at backwards compatibility. This should have it. Passwords are expected in exactly the same place under the patch as before. Usernames have of course moved, but they fall back to the old place for contexts where browser functionality isn't available, in particular for Node.

I guess it would have been possible to extend the browser-variable widget to actually store into the first place available - that is, either into browser local-storage or into a tiddler - leaving the other one alone; that would have provided halfway-decent semantics for the idea that the browser can have tiny pieces of state which override the tiddlers. But I didn't do that; it's both a little annoying to implement, and cognitively complex for users to understand.

Okay! I think that's it! Hopefully you like it. :)