Skip to content

Commit

Permalink
Merge pull request #790 from busyorg/nd/short-video-posts
Browse files Browse the repository at this point in the history
Display embed and text for short posts
  • Loading branch information
Sekhmet committed Oct 13, 2017
2 parents f6dd207 + c505654 commit 4f9bfad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/components/Story/StoryHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const isPostWithEmbedBeforeFirstHalf = tagPositions => postWithAnEmbed(tagPositi

export {
getPositions,
postWithAnEmbed,
isPostStartsWithAPicture,
isPostStartsWithAnEmbed,
isPostWithPictureBeforeFirstHalf,
Expand Down
21 changes: 12 additions & 9 deletions src/components/Story/StoryPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { jsonParse } from '../../helpers/formatter';
import { image } from '../../vendor/steemitLinks';
import {
getPositions,
postWithAnEmbed,
isPostStartsWithAPicture,
isPostStartsWithAnEmbed,
isPostWithPictureBeforeFirstHalf,
Expand Down Expand Up @@ -37,7 +38,9 @@ const StoryPreview = ({ post }) => {
embeds[0] = {
type: 'video',
provider_name: 'DTube',
embed: `<video controls="true" autoplay="true" src="https://ipfs.io/ipfs/${video.content.videohash}" poster="https://ipfs.io/ipfs/${video.info.snaphash}"><track kind="captions" /></video>`,
embed: `<video controls="true" autoplay="true" src="https://ipfs.io/ipfs/${video.content
.videohash}" poster="https://ipfs.io/ipfs/${video.info
.snaphash}"><track kind="captions" /></video>`,
thumbnail: getProxyImageURL(`https://ipfs.io/ipfs/${video.info.snaphash}`, 'preview'),
};
}
Expand All @@ -47,10 +50,11 @@ const StoryPreview = ({ post }) => {

embed: () => embeds && embeds[0] && <PostFeedEmbed key="embed" embed={embeds[0]} />,

image: () =>
(<div key={imagePath} className="Story__content__img-container">
image: () => (
<div key={imagePath} className="Story__content__img-container">
<img alt="post" src={imagePath} />
</div>),
</div>
),
};

const htmlBody = getHtml(post.body, {}, 'text');
Expand All @@ -60,6 +64,9 @@ const StoryPreview = ({ post }) => {
if (hasVideo) {
bodyData.push(preview.embed());
bodyData.push(preview.text());
} else if (htmlBody.length <= 1500 && postWithAnEmbed(tagPositions, 100)) {
bodyData.push(preview.embed());
bodyData.push(preview.text());
} else if (isPostStartsWithAPicture(tagPositions)) {
bodyData.push(preview.image());
bodyData.push(preview.text());
Expand All @@ -76,11 +83,7 @@ const StoryPreview = ({ post }) => {
bodyData.push(preview.text());
}

return (
<div>
{bodyData}
</div>
);
return <div>{bodyData}</div>;
};

StoryPreview.propTypes = {
Expand Down
16 changes: 8 additions & 8 deletions src/stories/__snapshots__/stories.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2651,14 +2651,6 @@ exports[`Storyshots Story Inline story with embed 1`] = `
onClick={[Function]}
>
<div>
<div
className="Story__content__body"
dangerouslySetInnerHTML={
Object {
"__html": "Lots of good stuff for STEEM as he talks about Community Tokens / User Issued Tokens &amp; B2B Solutions, the Linear Reward Curve and many …",
}
}
/>
<div
className="PostFeedEmbed"
onClick={[Function]}
Expand All @@ -2677,6 +2669,14 @@ exports[`Storyshots Story Inline story with embed 1`] = `
src="https://i.ytimg.com/vi/YxFzGoDoLwU/hqdefault.jpg"
/>
</div>
<div
className="Story__content__body"
dangerouslySetInnerHTML={
Object {
"__html": "Lots of good stuff for STEEM as he talks about Community Tokens / User Issued Tokens &amp; B2B Solutions, the Linear Reward Curve and many …",
}
}
/>
</div>
</a>
</div>
Expand Down

0 comments on commit 4f9bfad

Please sign in to comment.