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

Improve Digital AMP integration #2678

Merged
merged 1 commit into from Mar 25, 2016
Merged

Improve Digital AMP integration #2678

merged 1 commit into from Mar 25, 2016

Conversation

Re-lM
Copy link
Contributor

@Re-lM Re-lM commented Mar 23, 2016

Initial integration for Improve Digital in AMP.

@dvoytenko
Copy link
Contributor

Thanks, @Re-lM! Could you please run gulp lint locally and fix the errors it prints?


const url = 'https://ad.360yield.com' +
'/adj?' +
'p=' + data.placement +
Copy link
Contributor

Choose a reason for hiding this comment

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

Since all data properties arrive from outside, we have to encode them via encodeURIComponent.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@Re-lM
Copy link
Contributor Author

Re-lM commented Mar 23, 2016

@dvoytenko I updated the files. Can you have a look? Thanks.

@googlebot
Copy link

CLAs look good, thanks!

'&tz=' + new Date().getTimezoneOffset();

if (typeof data.keyvalue !== 'undefined' && data.keyvalue) {
url += '&' + encodeURIComponent(data.keyvalue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really what you want? If data.keyvalue is, for instance, "a=b", they will be encoded in your code as &a%3Db. If it works for your URL, it's certainly fine, but I wanted to make sure.

@dvoytenko
Copy link
Contributor

Looks good. I posted one question about data.keyvalue - I'm not sure it's encoding is correct right now. And could you please squash the commits? It will be ready to be merged then.

@Re-lM
Copy link
Contributor Author

Re-lM commented Mar 24, 2016

@dvoytenko actually I rather not encode the data.keyvalue. Can i?

@@ -0,0 +1,42 @@
/**
* Copyright 2015 The AMP HTML Authors. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2016 here and every other new file

@dvoytenko
Copy link
Contributor

@Re-lM Unfortunately - no encoding is not an option in this case. But encoding this should be rather straightforward. You just need to split data.keyvalue into two parts via =, encode each part and recombine again via =. Or I am missing something?

@Re-lM Re-lM force-pushed the master branch 2 times, most recently from 3765c65 to cff290d Compare March 25, 2016 13:07
@Re-lM
Copy link
Contributor Author

Re-lM commented Mar 25, 2016

@dvoytenko done. Squashed the commits. Oke for merge? Let me know if I need to change something. Thanks.


if (value && value.length > 0) {
const keys = value.split('&');
for (let i = 0;i < keys.length;i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: spaces between components of for, e.g. for (let i = 0; i < keys.length; i++)

@dvoytenko
Copy link
Contributor

@Re-lM Yes, that's right. Just couple more notes and clarifications and please squash again after. Otherwise - it looks all good to be merged. Thanks!

@Re-lM Re-lM force-pushed the master branch 3 times, most recently from 694f397 to 529f5f9 Compare March 25, 2016 21:11
@Re-lM
Copy link
Contributor Author

Re-lM commented Mar 25, 2016

@dvoytenko Adjusted it. Can you review? Squashed the commit.

if (!keys[i]) {continue;}
const segment = keys[i].split('=');
const segment1 = (segment[1] ? encodeURIComponent(segment[1]) : '');
if (keys[i]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you checking keys[i] again here if you already check it above in if (!keys[i]) {continue;}? Did you mean to test if (segment[0]) instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dvoytenko I'm doing another check to see if the second and third or any possibility could be empty. Like keys ["", "", "", "gender=male", "placement=999", "", "", "", "plavement=1"]. Resulting to not have a double && in the URL.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Re-lM I meant that you have these two statements:

if (!keys[i]) {continue;}

and

if (keys[i]) {....}

My point was that with the first if the second is always true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dvoytenko aah see what you mean. You're right. Just tested it and removed it. re-squashed.

fix squase

fix conflict

Improve Digital AMP integration

fix lint issues

update year

update year

Update keyvalue logic

Fix variable

Fix variable

fixing spaces

removing unnecessary code
@dvoytenko
Copy link
Contributor

LGTM

@dvoytenko dvoytenko added the LGTM label Mar 25, 2016
@dvoytenko dvoytenko merged commit c3f9545 into ampproject:master Mar 25, 2016
@Re-lM
Copy link
Contributor Author

Re-lM commented Mar 25, 2016

@dvoytenko Thanks!

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

Successfully merging this pull request may close these issues.

None yet

5 participants