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

✨ implement amp-embedly-card component #14819

Merged
merged 47 commits into from
Jul 16, 2018

Conversation

juanlizarazo
Copy link
Member

PR that implements amp-embedly-card component (feature request #12908) using embedly cards.

@juanlizarazo
Copy link
Member Author

@aghassemi @alanorozco New PR ready for review 😁

@aghassemi
Copy link
Contributor

Thanks @juanlizarazo.

I will defer the full review to @alanorozco

On the API side: Is there a particular reason amp-embedly-key is a separate component? I suggest having a data-key attribute on the <amp-embedly-card> itself for consistency.

@juanlizarazo
Copy link
Member Author

@aghassemi

It was a change requested on the original <amp-embedly>'s PR here.

But maybe it made more sense then as it was required. For the new <amp-embedly-card> the paid api key is optional and it just removes branding.

I'll be happy to remove the additional amp-embdely-key component! Your call @aghassemi and @alanorozco

@aghassemi
Copy link
Contributor

@juanlizarazo I see. I don't have a strong opinion, leaving the final decision to @alanorozco on this.

@@ -0,0 +1 @@
PASS
Copy link
Member

Choose a reason for hiding this comment

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

Since you're submitting validator rules, could you please follow the steps described here to generate test cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!


/** @override */
layoutCallback() {
return getEmbedlyServiceForDoc(this.element).then(service => {
Copy link
Member

Choose a reason for hiding this comment

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

I know I originally suggested a service, but there's be a better way.

  1. Remove the service
  2. Simply query for
document.querySelector('amp-embedly-key').getAttribute('data-key');

The service suggestion was way overdesigned, I apologize.

I also read the other thread regarding the API. Unless you have an objection and after this change, it looks good to me!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Alan, I will be updating this PR tonight :D

@aghassemi
Copy link
Contributor

Keeping this PR open since there is progress.

@juanlizarazo
Copy link
Member Author

@alanorozco

Updated as requested:

  • Removed docservice to set/get embedly api key.
  • Query value attribute on element as recommended.
  • Added validator test cases and updated .out file.

```

Setting a key through the `amp-embedly-key` component is optional. If you are a paid user
this will remove Embedly's branding from the cards.
Copy link
Member

Choose a reason for hiding this comment

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

This tag must only be included once

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

}
}

tags: { # <amp-embedly-key>
Copy link
Member

Choose a reason for hiding this comment

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

Add unique: true

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

requires_extension: "amp-embedly-card"
attrs: {
name: "data-url"
mandatory: true
Copy link
Contributor

Choose a reason for hiding this comment

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

You may want to consider adding some restrictions on the url. e.g. https only. See the UrlSpec for what can be restricted. It can be set as a value_url on the tags spec, e.g.

value_url: {
  allowed_protocol: "https"
  allow_relative: false
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Added!

tags: { # <amp-embedly-card>
html_format: AMP
tag_name: "AMP-EMBEDLY-CARD"
satisfies: "amp-embedly-card"
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't needed (satisfies)

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed

@@ -0,0 +1,69 @@
<!doctype html>
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be in extensions/amp-embedly-card/0.1/tests/ as validator-amp-embedly-card.html and the .out file as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to recommended folder and renamed.

Copy link
Member Author

@juanlizarazo juanlizarazo left a comment

Choose a reason for hiding this comment

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

Updated with recommended changes.

Copy link
Member

@alanorozco alanorozco 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 awesome, really clean and thorough.

@alanorozco
Copy link
Member

@bpaduch For assistance with docs.

@juanlizarazo
Copy link
Member Author

Awesome, thanks!

@alanorozco @bpaduch @aghassemi

For the examples page in examples/amp-embedly-card.amp.html should we remove the used key in <amp-embedly-key> just comment it out and have branded cards there?

As keys are paid, that key eventually will be eventually invalid.

@alanorozco
Copy link
Member

@juanlizarazo

Sure, removing the key sounds good.

</tr>
<tr>
<td width="40%"><strong>Required Script</strong></td>
<td><code>&lt;script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-embedly-card-0.1.js">&lt;/script></code></td>
Copy link

Choose a reason for hiding this comment

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

Change "amp-form" to "amp-embedly-card"

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

<table>
<tr>
<td width="40%"><strong>Description</strong></td>
<td>Provides you with responsive and shareable embeds to drive the reach of your websites, blog posts, and articles. from any URL using <a href="http://docs.embed.ly/docs/cards">Embedly cards</a>.</td>
Copy link

Choose a reason for hiding this comment

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

remove period after articles

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed

*Example: Embedding multiple resources*

If you have a paid plan, use the `amp-embedly-key` component to set your api key.
You just need one per document that includes one or multiple `amp-embedly-card` components:
Copy link

Choose a reason for hiding this comment

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

need "one" what? If it's amp-embedly-key, please specify that.

Like:

You just need one amp-embedly-key per AMP page.

Within the AMP page, you can specify one or multiple amp-embedly-card components:

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

*Example: Embedding multiple resources*

If you have a paid plan, use the `amp-embedly-key` component to set your api key.
You just need one per AMP page.
Copy link

Choose a reason for hiding this comment

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

Clarify what you mean by "one". For example "You just need one amp-embedly-key per AMP page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

</amp-embedly-key>
```

Setting a key through the `amp-embedly-key` component is optional. If you are a paid user, this removes Embedly's branding from the cards.
Copy link

Choose a reason for hiding this comment

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

Would this be clearer:

If you are a paid user, setting the amp-embedly-key removes Embedly's branding from the cards.

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitively, updated.


##### data-card-theme

For dark backgrounds it's better to specify the dark theme.
Copy link

Choose a reason for hiding this comment

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

What are the possible values for this attribute. Should also state what this attribute does, which is "Sets the card theme." then tell them what the default is, and possible values.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated with possible values and default and more info on this attribute.


##### data-card-image

Specifies which image to use in article cards.
Copy link

Choose a reason for hiding this comment

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

What should the value be - a URL, something else? Please advise.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added more info.


##### data-card-controls

Enables share icons. The default value is `1`.
Copy link

Choose a reason for hiding this comment

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

Clarify that by default share icons are enabled. To turn them off, specify '0'.?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to explain these better.


##### data-card-align

Aligns the card. The default value is `"center"`.
Copy link

Choose a reason for hiding this comment

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

What are the other values - please specify.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added possible values.


##### data-card-recommend

Disables Embedly recommendations on video and rich cards. The default value is `1`.
Copy link

Choose a reason for hiding this comment

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

Indicate that by default, recommendations are disabled (assuming "1" means that).

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@codecov-io
Copy link

codecov-io commented Jul 9, 2018

Codecov Report

Merging #14819 into master will decrease coverage by 0.03%.
The diff coverage is 56.36%.

@@            Coverage Diff             @@
##           master   #14819      +/-   ##
==========================================
- Coverage   77.61%   77.58%   -0.04%     
==========================================
  Files         553      557       +4     
  Lines       40337    40392      +55     
==========================================
+ Hits        31309    31339      +30     
- Misses       9028     9053      +25
Flag Coverage Δ
#integration_tests 32.68% <ø> (ø) ⬆️
#unit_tests 77.15% <56.36%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 920e13f...3f18a27. Read the comment docs.

@juanlizarazo
Copy link
Member Author

@bpaduch Updated with requested changes!

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Docs LGTM

@alanorozco alanorozco merged commit ae138bc into ampproject:master Jul 16, 2018
@aghassemi
Copy link
Contributor

Yay! Thanks @juanlizarazo 🎉

@juanlizarazo juanlizarazo deleted the 12908-amp-embedly-card branch July 17, 2018 15:09
Gregable pushed a commit that referenced this pull request Jul 17, 2018
@aghassemi
Copy link
Contributor

@juanlizarazo This is in Dev Channel right now (If you enabled Dev Channel in https://cdn.ampproject.org/experiments.html you can give it a try). Will make it to production over the next couple of days.

@juanlizarazo
Copy link
Member Author

juanlizarazo commented Jul 31, 2018

Just tried it with different embeds. Can't wait!

@gctommy
Copy link

gctommy commented Aug 3, 2018

@aghassemithe documentation should really mentioned that data-url (required) only accepts https protocol, otherwise your page won't validate.

@juanlizarazo
Copy link
Member Author

@gctommy @aghassemi I can create a PR fixing that, I made sure the examples were compliant but I spaced out with the docs.

I will fix a typo as well I saw there too and possibly remove the data-via property as well. I talked to embedly support about it and the sdk doesn't do what it is supposed to. So right now using data-via does nothing.

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

Successfully merging this pull request may close these issues.

7 participants