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

Discover: show full post excerpt in stream #9410

Merged
merged 4 commits into from
Nov 22, 2016

Conversation

bluefuton
Copy link
Contributor

@bluefuton bluefuton commented Nov 16, 2016

For Discover posts, show the entire post.excerpt in the stream.

A normal post (clamped at 3 lines):

screen shot 2016-11-16 at 16 34 44

A Discover pick (shows entire excerpt):

screen shot 2016-11-16 at 16 33 41

Part of #9096.

cc @jancavan for CSS sanity check.

@bluefuton bluefuton added [Feature] Reader The reader site on Calypso. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 16, 2016
@bluefuton bluefuton added this to the Reader Refresh: Containers milestone Nov 16, 2016
@bluefuton bluefuton self-assigned this Nov 16, 2016
@matticbot
Copy link
Contributor

@bluefuton bluefuton added [Status] In Progress and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 16, 2016
@bluefuton
Copy link
Contributor Author

bluefuton commented Nov 16, 2016

  • Use post.excerpt as the basis for Discover excerpts, not post.content

@bluefuton bluefuton mentioned this pull request Nov 16, 2016
8 tasks
@bluefuton bluefuton force-pushed the update/reader/discover-excerpt-show-all-for-picks branch from c6a32ce to 7a0e790 Compare November 17, 2016 02:12
@bluefuton bluefuton added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Nov 17, 2016
@bluefuton bluefuton changed the title Discover: show full post excerpt in stream for picks Discover: show full post excerpt in stream Nov 17, 2016
.reader-post-card.card:not(.is-showing-entire-excerpt) {
.reader-post-card__excerpt {
overflow: hidden;
max-height: 15px * 1.6 * 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

indented too far?

@@ -43,6 +43,10 @@ export default function createBetterExcerpt( post ) {
return post;
}

// Create standard excerpt for Discover
post.excerpt_no_html = formatExcerpt( post.excerpt );
Copy link
Contributor

Choose a reason for hiding this comment

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

i thought the intent was to not mess with the excerpt at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

^ That's correct (not messing with the excerpt).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The excerpt sometimes comes wrapped in a <p>, which is all I'm wanting to strip here.

If we don't remove this wrapping paragraph, we'd have to display the excerpt using dangerouslySetInnerHTML, which feels wrong.

.reader-post-card.card:not(.is-showing-entire-excerpt) {
.reader-post-card__excerpt {
overflow: hidden;
max-height: 15px * 1.6 * 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious what the advantage is of using this since it isn't relative and we end up with a fixed value anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like it just because it's explanatory and less magical. 72px wouldn't tell me why 72.

Copy link
Contributor

Choose a reason for hiding this comment

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

My question then is why 15px? 😄

If we need the context here then maybe we could use some variables?
or maybe a comment with the meaning for each multiplier? like

max-height: 15px * 1.6 * 3; // Some value * what ever 1.6 means * something else 

originalPost: PropTypes.object // used for Discover only
originalPost: PropTypes.object, // used for Discover only
showEntireExcerpt: PropTypes.bool,
excerptAttribute: PropTypes.string
Copy link
Contributor

Choose a reason for hiding this comment

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

If there are only two possible values I wonder if it would be overkill here to make this PropTypes.oneOf( [ 'excerpt_no_html', 'better_excerpt_no_html' ] ). We could even go further and use constants throughout for those values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or perhaps just a boolean useBetterExcerpt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in 88ea09b.

@bluefuton bluefuton force-pushed the update/reader/discover-excerpt-show-all-for-picks branch from 4ebe48e to 88ea09b Compare November 21, 2016 00:42
@@ -22,8 +27,7 @@ export function isDiscoverPost( post ) {
}

export function isDiscoverSitePick( post ) {
const metaData = get( post, 'discover_metadata.discover_fp_post_formats' );
return !! ( metaData && find( metaData, { slug: 'site-pick' } ) );
return hasDiscoverSlug( post, 'site-pick' );
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@samouri
Copy link
Contributor

samouri commented Nov 21, 2016

code LGTM 🚢

Testing done:

  • opened branch in discover and saw that full excerpts were displayed
  • opened regular following stream and confirmed that excerpts were being clipped
  • tested with refresh flag off to see if behavior changed on wordpress.com

@samouri samouri added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 21, 2016
@bluefuton bluefuton merged commit e25ccc3 into master Nov 22, 2016
@bluefuton bluefuton deleted the update/reader/discover-excerpt-show-all-for-picks branch November 22, 2016 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Reader The reader site on Calypso.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants