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

Setting up code for AmpStoryEmbed viewer #26276

Merged
merged 4 commits into from Jan 10, 2020
Merged

Conversation

Enriqe
Copy link
Contributor

@Enriqe Enriqe commented Jan 9, 2020

Issue tracker #26308
Partial for #24539

Picking up work from #25006 by @newmuis

In preparation of having a pure JS library and an AMP extension of the viewer, this PR sets up the structure for managing the logic of both.

Given that our priority is the JS library for non-AMP pages, let's focus on this one first and then create the AMP extension which will use this new class.

@@ -144,13 +144,13 @@ exports.jsBundles = {
includePolyfills: false,
},
},
'amp-story-embed.js': {
'amp-story-embed-manager.js': {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's motivating the name change? This is still the JavaScript file for the <amp-story-embed> component. This new name implies that it manages amp-story-embeds, which it does not, except for the few lines of code at the end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this change I think made sense in the context of #25006, but not here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we might want to keep it for when we introduce the AMP extension, to differentiate it and avoid renaming the import script?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When publishers use this, do we want them to import
https://cdn.ampproject.org/v0/amp-story-embed-0.1.js for the AMP version
and https://cdn.ampproject.org/v0/amp-story-embed-manager-0.1.js for the pure-JS version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I'm going to is.. if they are both called amp-story-embed.js won't they override each other under https://cdn.ampproject.org/v0/? or will they be in separate directories?

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't you last bit of code using if (!isAMP) meant to keep the same API so the same script works on both AMP and non AMP?

Even without this, the file name should reflect the name of the class it contains. And here, the class should really be AmpStoryEmbed

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed with Gabriel here.

I think we should just drop the AMP/non-AMP split entirely and not implement this until we have an AMP version in hand.

What I'm going to is.. if they are both called amp-story-embed.js won't they override each other under https://cdn.ampproject.org/v0/? or will they be in separate directories?

They're different URLs. This is https://cdn.ampproject.org/amp-story-embed-v0.js, whereas the AMP extension would be https://cdn.ampproject.org/v0/amp-story-embed-0.1.js. At some point, if we have a binary that serves a version that can serve both AMP and non-AMP, we can alias these URLs to that binary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice, thanks for clarifying

src/amp-story-embed-manager.js Outdated Show resolved Hide resolved
src/amp-story-embed-manager.js Outdated Show resolved Hide resolved
src/amp-story-embed-manager.js Outdated Show resolved Hide resolved
src/amp-story-embed-manager.js Outdated Show resolved Hide resolved
src/amp-story-embed-manager.js Outdated Show resolved Hide resolved
Copy link
Contributor Author

@Enriqe Enriqe left a comment

Choose a reason for hiding this comment

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

PTAL

src/amp-story-embed-manager.js Outdated Show resolved Hide resolved
src/amp-story-embed-manager.js Outdated Show resolved Hide resolved
src/amp-story-embed.js Outdated Show resolved Hide resolved
src/amp-story-embed.js Outdated Show resolved Hide resolved
src/amp-story-embed.js Outdated Show resolved Hide resolved
src/amp-story-embed.js Outdated Show resolved Hide resolved
@Enriqe
Copy link
Contributor Author

Enriqe commented Jan 9, 2020

/to @jridgewell for OWNERS approval

src/amp-story-embed.js Outdated Show resolved Hide resolved
Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Why isn't @ampproject/wg-stories an owner of src/amp-story-embed.js?

@Enriqe
Copy link
Contributor Author

Enriqe commented Jan 10, 2020

Good question, I'll send a PR. Thanks all for the review :)

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

6 participants