Skip to content

Commit

Permalink
Show standard excerpt for all Discover posts
Browse files Browse the repository at this point in the history
  • Loading branch information
bluefuton committed Nov 17, 2016
1 parent 2fa9032 commit 7a0e790
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
11 changes: 7 additions & 4 deletions client/blocks/reader-post-card/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ export default class RefreshPostCard extends React.Component {
onCommentClick: PropTypes.func,
showPrimaryFollowButton: PropTypes.bool,
originalPost: PropTypes.object, // used for Discover only
showEntireExcerpt: PropTypes.bool
showEntireExcerpt: PropTypes.bool,
excerptAttribute: PropTypes.string
};

static defaultProps = {
onClick: noop,
onCommentClick: noop,
isSelected: false,
showEntireExcerpt: false
showEntireExcerpt: false,
excerptAttribute: 'better_excerpt_no_html'
};

propagateCardClick = () => {
Expand Down Expand Up @@ -98,7 +100,8 @@ export default class RefreshPostCard extends React.Component {
onCommentClick,
showPrimaryFollowButton,
isSelected,
showEntireExcerpt
showEntireExcerpt,
excerptAttribute
} = this.props;
const isPhotoOnly = !! ( post.display_type & DisplayTypes.PHOTO_ONLY );
const isGallery = !! ( post.display_type & DisplayTypes.GALLERY );
Expand Down Expand Up @@ -144,7 +147,7 @@ export default class RefreshPostCard extends React.Component {
<h1 className="reader-post-card__title">
<a className="reader-post-card__title-link" href={ post.URL }>{ title }</a>
</h1>
{ showExcerpt && <div className="reader-post-card__excerpt">{ post.better_excerpt_no_html }</div> }
{ showExcerpt && <div className="reader-post-card__excerpt">{ post[ excerptAttribute ] }</div> }
{ isDailyPostChallengeOrPrompt( post ) && <DailyPostButton post={ post } tagName="span" /> }
{ post &&
<ReaderPostActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default function createBetterExcerpt( post ) {
return post;
}

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

// Create better excerpt from the main post content
post.better_excerpt_no_html = post.better_excerpt = formatExcerpt( post.content );

// also make a shorter excerpt...
Expand Down
4 changes: 0 additions & 4 deletions client/reader/discover/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export function isDiscoverPost( post ) {
return !! ( get( post, 'discover_metadata' ) || get( post, 'site_ID' ) === config( 'discover_blog_id' ) );
}

export function isDiscoverPick( post ) {
return hasDiscoverSlug( post, 'pick' );
}

export function isDiscoverSitePick( post ) {
return hasDiscoverSlug( post, 'site-pick' );
}
Expand Down
5 changes: 3 additions & 2 deletions client/reader/stream/refresh-post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ReaderPostCardAdapter extends React.Component {
site_ID: siteId,
is_external: isExternal
} = this.props.post;
const isDiscoverPick = this.props.post && DiscoverHelper.isDiscoverPick( this.props.post );
const isDiscoverPost = this.props.post && DiscoverHelper.isDiscoverPost( this.props.post );

// only query the site if the feed id is missing. feed queries end up fetching site info
// via a meta query, so we don't need both.
Expand All @@ -49,7 +49,8 @@ class ReaderPostCardAdapter extends React.Component {
onCommentClick={ this.onCommentClick }
isSelected={ this.props.isSelected }
showPrimaryFollowButton={ this.props.showPrimaryFollowButtonOnCards }
showEntireExcerpt={ isDiscoverPick }>
showEntireExcerpt={ isDiscoverPost }
excerptAttribute={ isDiscoverPost ? 'excerpt_no_html' : 'better_excerpt_no_html' }>
{ feedId && <QueryReaderFeed feedId={ feedId } includeMeta={ false } /> }
{ ! isExternal && siteId && <QueryReaderSite siteId={ +siteId } includeMeta={ false } /> }
</ReaderPostCard>
Expand Down

0 comments on commit 7a0e790

Please sign in to comment.