-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
collision between query parameters and string keys #81
Comments
@samreid @jbphet @jonathanolson Where is this feature (overriding strings via query parameters) currently being used? |
The only use case for overriding strings with query parameter is https://github.com/phetsims/lingo/blob/master/lingo_en.html, you can test it at http://localhost:[your-port-here]/lingo/lingo_en.html |
…, whose value is JSON that is similar to the contents of a strings.json file
Changes: Overriding strings is now done via a single 'strings' query parameter, whose format is JSON that is identical to string.json files. string.js reads the 'strings' query parameter, parses its JSON value, then uses these values to override strings. lingo has been modified to use the 'strings' query parameter. (I also did some misc cleanup and generalization, so that lingo doesn't have a hardcoded URL and can be used with a working copy of energy-skate-park-basics.) Assigning to @samreid to review. |
@jbphet please be aware of these changes when you're working on rosetta. If you're planning to specify translated strings via query parameters, you'll need to do so via this new method. |
Got it, thanks. |
@jonathanolson commented via Skype: I replied: |
….js (to avoid using URI reserved characters)
Concern about URI reserved characters has been addressed by using encodeURIComponent to create the 'strings' parameter value, and decodeURIComponent to the value in strings.js. |
More Skype discussion with @jonathanolson: [1/16/15, 2:23:25 PM] Jonathan Olson: can write it in the issue, but what do people think about: |
I tried prefixing a query parameter in arch (changing it from ?log to ?phet.arch.log) and I quite liked that. Perhaps strings should be similarly prefixed? Something like phet.chipper.strings? Would make searching easier and reduce the risk of other stringy parameter collision in the future. |
I tested latest lingo and checked the format for the query strings and everything looks good. Thanks for updating lingo @pixelzoom! The only outstanding issue I'm aware of is whether we should change ?strings to ?phet.chipper.strings. Let's discuss it. |
I have a slight preference to just use ?strings (things like If we pull in a library that checks query strings for something we're not namespacing, we may regret not changing earlier. |
Good point @jonathanolson. Also, at the OER summit conference, we discovered that iframe embedding is particularly effective for putting sims into other content, even if it means doubly-nested iframes (though not tested on many platforms). So perhaps it is safe to assume PhET gets a frame all to itself and won't collide with other query parameters. |
How does a sim being in an iFrame prevent it from colliding with a query parameter that one of its dependencies uses? |
It doesn't protect it from collisions with PhET Sim dependencies. But it does prevent collision with other 3rd party content that embed PhET simulations as an iframe dependency. Since we get to choose our own dependencies this may be safe enough. EDIT: sims=>3rd party content |
At 1/20/15 dev meeting, we decided to name the query parameter 'strings'. |
While working on phetsims/molecule-polarity#5 and phetsims/molecule-polarity#7, I encountered some odd behavior. Molecule Polarity has 2 global options, presented to the user as 'dipole direction' and 'surface color'. Since all global options should be settable via query parameters, it makes sense that those query parameters should be named 'dipoleDirection' and 'surfaceColor'. It also makes sense that the string used to label these options should have keys 'dipoleDirection' and 'surfaceColor'. But apparently the string.js plugin reads query parameters to override string values. So when I set a query parameter, it's changing the strings that appear in my Options dialog.
I realize why this is being done. But this particular implementation presents the opportunity of unexpected collisions, especially since we can't possibly know all of the string keys that we might pull in from common code. Highly recommended to change this behavior, and override strings in another manner; either by qualifying the query parameter names when overriding strings (e.g., string.KEY=VALUE), or by attaching all overridden strings to 1 query parameter (e.g., strings="KEY=VALUE;...").
The text was updated successfully, but these errors were encountered: