Last modified: 2012-08-29 11:21:13 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T37073, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35073 - Add jquery.jStorage module to MediaWiki core
Add jquery.jStorage module to MediaWiki core
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
unspecified
All All
: Normal enhancement with 1 vote (vote)
: 1.20.0 release
Assigned To: Krinkle
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-08 23:01 UTC by Rainer Rillke @commons.wikimedia
Modified: 2012-08-29 11:21 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Rainer Rillke @commons.wikimedia 2012-03-08 23:01:05 UTC
Storing data at the client side becomes more and more important and I could not find such a module in http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/jquery/, yet.

Use cases on Commons: Collecting nominations for Featured content, saving inputs, ...


If I should do something, just tell me and I try to write a patch. But I read, you will move to Git, soon so I'd better wait and learn something new ;-)

There is one dependency to /resources/jquery/jquery.json.js required.

License: 
jStorage is licensed under MIT-styled license:
http://www.jstorage.info/static/license.txt
Comment 1 Sam Reed (reedy) 2012-03-08 23:03:15 UTC
You don't need to have it in RL to be useable...

Generally we only add modules to core if core is going to use it, or many extensions do...
Comment 2 Daniel Schwen 2012-03-08 23:19:29 UTC
I'm another Javascript extension developer on commons and would find this module very useful to streamline my code that currently relies on cookies to store clientside data. 

This should be a pretty low-maintenance addition, and it would be pretty helpful for script developers. 

What is you suggestion to use it without being in RL? Copying the code verbatim into every gadget page?
Comment 3 Sam Reed (reedy) 2012-03-08 23:20:52 UTC
(In reply to comment #2)
> I'm another Javascript extension developer on commons and would find this
> module very useful to streamline my code that currently relies on cookies to
> store clientside data. 
> 
> This should be a pretty low-maintenance addition, and it would be pretty
> helpful for script developers. 
> 
> What is you suggestion to use it without being in RL? Copying the code verbatim
> into every gadget page?

No, have it on one page and use importScript/similar to have it where you want to use it. Like is done in many places currently...
Comment 4 Daniel Schwen 2012-03-08 23:46:10 UTC
importScript is last century. It loads asynchronously and provides no way of supplying a callback.

Now if mw.loader.using would allow for arbitrary URLs like mw.loader.load does (this is an API inconsistency in my opinion), then we'd be talking.
There are many possible cases, where a script would have check the client-side stored values _before_ any user interaction is made (i.e. to display a customized user interface). 

Am i expected to result to ugly setTimeout loops to check if my required objects are already imported?
Comment 5 Krinkle 2012-03-08 23:48:30 UTC
If you can't use ResourceLoader and need callback:

Use $.getScript( '//url/here', function() { ... called when scrip url is downloaded and executed });

If you can use ResourceLoader (gadget), add it to the MediaWiki namespace and add it as a file or dependency in your gadget. The latter is recommended and will minify and concatenate it before your script.
Comment 6 Krinkle 2012-03-08 23:55:11 UTC
To use a module there is no need to put everything in core. Try it locally first. 

btw, another idea. If you can't use resourceloader, you can also create a gadget called jStorage and add [ResourceLoader] to it. Then you can use 'ext.gadget.jStorage' in either [dependencies=] or mw.loader.using().

Aside: What is jStorage offering that localStorage doesn't offer? (browser support of course, but other than that? You could do feature detection and only serve to modern browsers, support is growing rapidly[1]).

The way to use localStorage is basically the same (jStorage uses localStorage if available).

Marking WONTFIX for now. We can always add it later to core if we need it.


[1]: http://www.html5rocks.com/en/features/storage
Comment 7 Rainer Rillke @commons.wikimedia 2012-03-09 11:52:54 UTC
Huh... you are too fast with closing before I could give you some more arguments:

* This plugIn supports storing XML, and almost any type of javaScript variables.
* This plugIn supports all major browsers that are in use, including Internet Explorer 6 to 8
* If you offer it now, you can avoid causing the next mess. I think it is simply wrong to say "Let's wait until the whole world is using its own implementations and then add support for it and deprecate the whole world."

I understand that you don't want unnecessary maintenance in your core. But storing data on the client side is a *core* requirement if you want to write smart applications. I would even offer to bring the whole code in compliance with your Coding Conventions if you agree to add it.

I know about the ability of importScript, the ugly gadget-(BTW, can I add |rights=nobodyHas to avoid display?), jQuery events and XHR/eval-tricks. Most of them work site-wide. Go to the next site and nothing works or you have to duplicate the code.

I find it a bit unfair that while the UploadWizard-monster is allowed to add dozens of modules (such as arrow-steps, mw.api that adds no benefit over directly using a XHR and do a bit smart error-handling) to core, while you consider the pile of jQuery-effects as more important, you deny this.
Comment 8 Krinkle 2012-03-09 12:11:38 UTC
(In reply to comment #7)
> [you] deny this.

I'm not denying anything. However usually things are used before they are added to core, not the other way around.

Also, modules can be loaded cross-wiki (no need for duplication). This was possible in 1.18 and even more so in 1.19.

I'd say, get it out there. Play with jStorage, see if it fits your need. Give it time to sink in, perhaps other contributors to the script find an alternative library to use or whatever. No need to rush anything.
Comment 9 Rainer Rillke @commons.wikimedia 2012-03-09 12:32:18 UTC
Of course I would accept any other plugIn that covers at least the same functions and browsers. I just have this for 2 months in use and got no complaints, yet.

Keywords: HTML5 local storage, client storage, userData
Comment 10 Rainer Rillke @commons.wikimedia 2012-08-29 10:35:43 UTC
Whahah!

https://gerrit.wikimedia.org/r/#/c/20470/
Comment 11 Rainer Rillke @commons.wikimedia 2012-08-29 10:37:59 UTC
Done in https://gerrit.wikimedia.org/r/#q,I2343744304191d5846cf346e4ac6ca083a6414b3,n,z

Obviously one must be a Hoo man!

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links