Skip to content
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

Url params 🎉 #276

Merged
merged 8 commits into from
Jun 3, 2018
Merged

Url params 🎉 #276

merged 8 commits into from
Jun 3, 2018

Conversation

tech4GT
Copy link
Member

@tech4GT tech4GT commented Jun 2, 2018

fixes #250 and #127

tech4GT added 2 commits June 2, 2018 13:39
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@ghost ghost assigned tech4GT Jun 2, 2018
@ghost ghost added the in-progress label Jun 2, 2018
@tech4GT
Copy link
Member Author

tech4GT commented Jun 2, 2018

@jywarren One issue I am facing right now is that importimage takes a function which also has commas and () should I handle it differently, or is there a better approach??

@tech4GT
Copy link
Member Author

tech4GT commented Jun 2, 2018

Oh I found one more logical error, now reworking .toJson()

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Jun 2, 2018

@jywarren everything is working now!!!

@jywarren
Copy link
Member

jywarren commented Jun 2, 2018 via email

@tech4GT
Copy link
Member Author

tech4GT commented Jun 2, 2018

@jyywarren yes i did😁

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really nice. How did the function-with-commas question get resolved -- what happens?

Awesome work, Varun!

_sequencer.addSteps(step);
var stepsFromHash = _sequencer.toJson(hash);
stepsFromHash.forEach(function eachStep(stepObj) {
_sequencer.addSteps(stepObj.name,stepObj.options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, this would eventually be replaced by importString or what were we going to call it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren yeah We can call it importString()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren actually I split on '),' !!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I wonder if this could still be triggered by incorrect parsing with a specifically crafted function.

Maybe we should forbid functions unless it's a full json string? Or could we url-encode the function like with %20-like encoding? But that would be quite unreadable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren this won't fail until the function is incorrect!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case even if we encode it won't make sense since it would not be valid

});
_sequencer.run();
}
setUrlHashParameter("steps", sequencer.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome :-)

.run(null);

// add to URL hash too
setUrlHashParameter("steps", _sequencer.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we're sure this'll overwrite the previous one? Great.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah!!

return steps.map(stepToJson);
}
// Converts one stringified step into JSON
function stepToJson(str){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe stepStringToJson()? for extra clarity

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And can we write a test for this function? Thank you!!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren yeah I'l add the tests now!!

tech4GT added 2 commits June 3, 2018 00:37
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Jun 2, 2018

@jywarren I think this is ready!!

@tech4GT
Copy link
Member Author

tech4GT commented Jun 3, 2018

Oh yeah sure!!

tech4GT added 2 commits June 3, 2018 09:22
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Jun 3, 2018

Oh my bad!! I'm sorry @jywarren I forgot to push the commit that fixed the comma problem😅

@tech4GT
Copy link
Member Author

tech4GT commented Jun 3, 2018

@jywarren now this is done with the updated test, please have a look!! I tried it in the browser, looking very cool!!!

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost there -- very exciting! Just made a suggestion with these encode/decode functions that'll make things simpler.

Thanks Varun!!!

for(let input in inputs) inputs[input] = step.options[input] || inputs[input].default;
for(let input in inputs) {
inputs[input] = step.options[input] || inputs[input].default;
inputs[input] = inputs[input].toString().replace(',',',%20');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this -- encodeURIComponent() -- this is available in node too. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

@@ -232,9 +235,12 @@ ImageSequencer = function ImageSequencer(options) {
str.substr(0,str.indexOf('(')),
str.substr(str.indexOf('(')+1)
]

str[1] = str[1].split('%20').join(' ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this then be decodeURIComponent() to reconstruct it? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent

I had mistakenly put %20 which is the code for a space, not a comma. I think commas are %2C but these converter functions should deal with it.

@@ -232,9 +235,12 @@ ImageSequencer = function ImageSequencer(options) {
str.substr(0,str.indexOf('(')),
str.substr(str.indexOf('(')+1)
]

str[1] = str[1].split('%20').join(' ');
str[1] = str[1].split(', ').join('|');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are you replacing commas with | pipes? I think the encode/decode should make that unnecessary, right?

@tech4GT
Copy link
Member Author

tech4GT commented Jun 3, 2018

@jywarren Actually yeah I think this can simplify things a little, I'll try this out

@jywarren
Copy link
Member

jywarren commented Jun 3, 2018 via email

@tech4GT
Copy link
Member Author

tech4GT commented Jun 3, 2018

@jywarren this is somewhat messing with the functionality

@tech4GT
Copy link
Member Author

tech4GT commented Jun 3, 2018

I would have to figure this out from scratch i guess

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Jun 3, 2018

@jywarren Done!!

@jywarren jywarren merged commit 871453b into publiclab:master Jun 3, 2018
@ghost ghost removed the in-progress label Jun 3, 2018
@jywarren
Copy link
Member

jywarren commented Jun 3, 2018

AMAZING!!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants