<commit_before>import React, { Component } from 'react';
import { has } from 'lodash/object';
import moment from 'moment';
import { Link } from 'react-router';
import steemembed from 'steemembed';
import BodyShort from './body-short';
import Mentions from './mentions';
import Flag from './flag';
import Comments from '../comments/Comments';
import PostActionButtons from './PostActionButtons';
import Icon from '../widgets/Icon';

const colorCode = { green: 'rgba(39, 208, 169, 0.4)', red: 'rgba(249, 43, 97, 0.2)' };
const classCode = { green: 'grid-row-green', red: 'grid-row-red' };

const getJsonMetaData = (props) => {
  let jsonMetaData;
  try {
    jsonMetaData = JSON.parse(props.post.json_metadata);
  } catch (e) {
    jsonMetaData = {};
  }
  return jsonMetaData;
};


export default class PostFeed extends Component {
  constructor(props) {
    super(props);
    this.state = {
      showComments: false,
    };
  }

  handleShowCommentsRequest = () => {
    this.setState({ showComments: true });
  };

  render() {
    const { post, onCommentRequest, bookmarks, toggleBookmark, notify } = this.props;
    const postPath = `/${post.parent_permlink}/@${post.author}/${post.permlink}`;

    let color = '';
    color = (post.net_votes > 0) && 'green';
    color = (post.net_votes < 0) && 'red';

    const netVotesBar = Math.abs(40 / 1000 * post.net_votes);
    const netVotesStyle = (color)
      ? { height: '4px', boxShadow: `inset ${netVotesBar}em 0 0 ${colorCode[color]}` }
      : {};

    const jsonMetaData = getJsonMetaData(this.props);

    const className = (color) ? `grid-row ${classCode[color]}` : 'grid-row';

    const imageName = has(jsonMetaData, 'image[0]') ? jsonMetaData.image[0] : '';
    const imagePath = imageName
      ? `https://img1.steemit.com/600x400/${imageName}`
      : '';

    const embeds = steemembed.getAll(post.body);

    return (
      <div className={className}>
        { post.first_reblogged_by &&
          <div className="cell cell-top">
            <ul>
              <li>
                <Icon name="repeat" s />
                { ' Reblogged by ' }
                <Link to={`/@${post.first_reblogged_by}`}>@{post.first_reblogged_by}</Link>
              </li>
            </ul>
          </div>
        }

        <div className="cell cell-top">
          <ul>
            <li>
              <Link to={`/@${post.author}`}>
                <span className="avatar avatar-xs">
                  <img src={`https://img.busy6.com/@${post.author}`} role="presentation" width="24" height="24" />
                </span>
                { ` @${post.author}` }
              </Link>

              { post.parent_author &&
                <span className="hidden-xs">
                      { ' replied ' }
                  <Link to={`/@${post.parent_author}`}>
                    @{post.parent_author}
                  </Link>
                  &#8217;s&nbsp;
                  <Link to={`/${post.category}/@${post.parent_author}/${post.parent_permlink}`}>
                    post.
                  </Link>
                </span>
              }

            </li>
            <li className="pull-right">
              { `${moment(post.created).fromNow()} ` }

              <a onClick={() => toggleBookmark(post.id)}>
                <Icon
                  small
                  name={bookmarks[post.id] ? 'bookmark' : 'bookmark_border'}
                />

              </a>
            </li>
          </ul>
        </div>

        { (imageName && !has(embeds, '[0].embed')) &&
          <div className="thumbs">
            <Link to={postPath}>
              <img src={imagePath} />
            </Link>
          </div>
        }

        { has(embeds, '[0].embed') &&
          <div className="thumbs" dangerouslySetInnerHTML={{ __html: embeds[0].embed }} />
        }

        <div className="cell cell-body">
          <h2>
            <Flag title={post.title} body={post.body} className="prs" />
            <Link to={postPath}>{post.title}</Link>
          </h2>

          <Mentions jsonMetaData={jsonMetaData} />

          <p>
            <BodyShort body={post.body} />
          </p>
        </div>

        <div style={netVotesStyle} />

        <div className="cell cell-bottom">
          <PostActionButtons
            post={post}
            notify={notify}
            onCommentRequest={onCommentRequest}
            onShowCommentsRequest={this.handleShowCommentsRequest}
          />
        </div>

        { this.state.showComments &&
          <Comments postId={post.id} />
        }

      </div>
    );
  }
}
<commit_msg>Use react intl for show date from now instead of moment<commit_after>import React, { Component } from 'react';
import { FormattedRelative } from 'react-intl';
import { has } from 'lodash/object';
import { Link } from 'react-router';
import steemembed from 'steemembed';
import BodyShort from './body-short';
import Mentions from './mentions';
import Flag from './flag';
import Comments from '../comments/Comments';
import PostActionButtons from './PostActionButtons';
import Icon from '../widgets/Icon';

const colorCode = { green: 'rgba(39, 208, 169, 0.4)', red: 'rgba(249, 43, 97, 0.2)' };
const classCode = { green: 'grid-row-green', red: 'grid-row-red' };

const getJsonMetaData = (props) => {
  let jsonMetaData;
  try {
    jsonMetaData = JSON.parse(props.post.json_metadata);
  } catch (e) {
    jsonMetaData = {};
  }
  return jsonMetaData;
};


export default class PostFeed extends Component {
  constructor(props) {
    super(props);
    this.state = {
      showComments: false,
    };
  }

  handleShowCommentsRequest = () => {
    this.setState({ showComments: true });
  };

  render() {
    const { post, onCommentRequest, bookmarks, toggleBookmark, notify } = this.props;
    const postPath = `/${post.parent_permlink}/@${post.author}/${post.permlink}`;

    let color = '';
    color = (post.net_votes > 0) && 'green';
    color = (post.net_votes < 0) && 'red';

    const netVotesBar = Math.abs(40 / 1000 * post.net_votes);
    const netVotesStyle = (color)
      ? { height: '4px', boxShadow: `inset ${netVotesBar}em 0 0 ${colorCode[color]}` }
      : {};

    const jsonMetaData = getJsonMetaData(this.props);

    const className = (color) ? `grid-row ${classCode[color]}` : 'grid-row';

    const imageName = has(jsonMetaData, 'image[0]') ? jsonMetaData.image[0] : '';
    const imagePath = imageName
      ? `https://img1.steemit.com/600x400/${imageName}`
      : '';

    const embeds = steemembed.getAll(post.body);

    return (
      <div className={className}>
        { post.first_reblogged_by &&
          <div className="cell cell-top">
            <ul>
              <li>
                <Icon name="repeat" s />
                { ' Reblogged by ' }
                <Link to={`/@${post.first_reblogged_by}`}>@{post.first_reblogged_by}</Link>
              </li>
            </ul>
          </div>
        }

        <div className="cell cell-top">
          <ul>
            <li>
              <Link to={`/@${post.author}`}>
                <span className="avatar avatar-xs">
                  <img src={`https://img.busy6.com/@${post.author}`} role="presentation" width="24" height="24" />
                </span>
                { ` @${post.author}` }
              </Link>

              { post.parent_author &&
                <span className="hidden-xs">
                      { ' replied ' }
                  <Link to={`/@${post.parent_author}`}>
                    @{post.parent_author}
                  </Link>
                  &#8217;s&nbsp;
                  <Link to={`/${post.category}/@${post.parent_author}/${post.parent_permlink}`}>
                    post.
                  </Link>
                </span>
              }

            </li>
            <li className="pull-right">
              <FormattedRelative value={post.created} />{' '}
              <a onClick={() => toggleBookmark(post.id)}>
                <Icon
                  small
                  name={bookmarks[post.id] ? 'bookmark' : 'bookmark_border'}
                />
              </a>
            </li>
          </ul>
        </div>

        { (imageName && !has(embeds, '[0].embed')) &&
          <div className="thumbs">
            <Link to={postPath}>
              <img src={imagePath} />
            </Link>
          </div>
        }

        { has(embeds, '[0].embed') &&
          <div className="thumbs" dangerouslySetInnerHTML={{ __html: embeds[0].embed }} />
        }

        <div className="cell cell-body">
          <h2>
            <Flag title={post.title} body={post.body} className="prs" />
            <Link to={postPath}>{post.title}</Link>
          </h2>

          <Mentions jsonMetaData={jsonMetaData} />

          <p>
            <BodyShort body={post.body} />
          </p>
        </div>

        <div style={netVotesStyle} />

        <div className="cell cell-bottom">
          <PostActionButtons
            post={post}
            notify={notify}
            onCommentRequest={onCommentRequest}
            onShowCommentsRequest={this.handleShowCommentsRequest}
          />
        </div>

        { this.state.showComments &&
          <Comments postId={post.id} />
        }

      </div>
    );
  }
}

{'fraction_non_alphanumeric': 0.1605988797931926, 'fraction_numerical': 0.011417492460146488, 'mean_word_length': 1.810230024213075, 'pattern_counts': {'":': 0, '<': 116, '<?xml version=': 0, '>': 122, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3786853', 'n_tokens_mistral': 2904, 'n_tokens_neox': 2771, 'n_words': 545}