Skip to content

Setting up code for AmpStoryEmbed viewer#26276

Merged
Enriqe merged 4 commits intoampproject:masterfrom
Enriqe:story-embed1
Jan 10, 2020
Merged

Setting up code for AmpStoryEmbed viewer#26276
Enriqe merged 4 commits intoampproject:masterfrom
Enriqe:story-embed1

Conversation

@Enriqe
Copy link
Copy Markdown
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.

@Enriqe Enriqe requested review from gmajoulet and newmuis January 9, 2020 16:13
@amp-owners-bot amp-owners-bot bot requested a review from jridgewell January 9, 2020 16:13
},
},
'amp-story-embed.js': {
'amp-story-embed-manager.js': {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Copy link
Copy Markdown
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

@Enriqe
Copy link
Copy Markdown
Contributor Author

Enriqe commented Jan 9, 2020

/to @jridgewell for OWNERS approval

Copy link
Copy Markdown
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
Copy Markdown
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.

6 participants