<commit_before>import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import { Meteor } from 'meteor/meteor';
import marked from 'marked';

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

  deleteThisPost() {
    Meteor.call('posts.remove', this.props.post._id);
  }
  
  toggleIsPublic() {
    Meteor.call('posts.setIsPublic', this.props.post._id, !this.props.post.isPublic);
  }
  
  changeToEditMode() {
    this.setState({edit: true});
  }
  
  updateThisPost() {
    const newTitle = ReactDOM.findDOMNode(this.refs.newTitleInput).value.trim();
    const newContent = ReactDOM.findDOMNode(this.refs.newContentInput).value.trim();
    Meteor.call('posts.update', this.props.post._id, newTitle, newContent);
  }
  
  handleChange(event) {
    this.setState({value: event.target.value});
  }
  
  rawMarkup() {
    return { __html: marked(this.props.post.content, {sanitize: true}) };
  }

  render() {
    return (
        <li className="list-group-item">
          { !this.state.edit ?
            <div>
              { (Meteor.userId() === this.props.post.ownerId) ?
                <div className="pull-right">
                  <button type="button" className="btn btn-link gray" onClick={this.changeToEditMode.bind(this)}>
                    <span className="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                  </button>
                  <button type="button" className="btn btn-link gray" onClick={this.deleteThisPost.bind(this)}>
                    <span className="glyphicon glyphicon-trash" aria-hidden="true"></span>
                  </button>
                  <label className="checkbox-inline">
                    <input
                      type="checkbox"
                      readOnly
                      checked={this.props.post.isPublic}
                      onClick={this.toggleIsPublic.bind(this)}/><small>make public</small>
                  </label>
                </div> : ''
              }
              <h2>
                {this.props.post.title} <small>(by {this.props.post.ownerName})</small>
              </h2>
              <p dangerouslySetInnerHTML={this.rawMarkup()}/>
            </div> :<commit_msg>post content hidden, shows on click on title<commit_after>import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import { Meteor } from 'meteor/meteor';
import marked from 'marked';

export default class Post extends Component {
  
  constructor(props) {
    super(props);
    this.state = {
      edit: false,
      contentHidden: true,
    };
  }

  deleteThisPost() {
    Meteor.call('posts.remove', this.props.post._id);
  }
  
  toggleIsPublic() {
    Meteor.call('posts.setIsPublic', this.props.post._id, !this.props.post.isPublic);
  }
  
  changeToEditMode() {
    this.setState({edit: true});
  }
  
  updateThisPost() {
    const newTitle = ReactDOM.findDOMNode(this.refs.newTitleInput).value.trim();
    const newContent = ReactDOM.findDOMNode(this.refs.newContentInput).value.trim();
    Meteor.call('posts.update', this.props.post._id, newTitle, newContent);
  }
  
  handleChange(event) {
    this.setState({value: event.target.value});
  }
  
  rawMarkup() {
    return { __html: marked(this.props.post.content, {sanitize: true}) };
  }
  
  toggleIsContentHidden() {
    this.setState({contentHidden: !this.state.contentHidden});
  }

  render() {
    return (
        <li className="list-group-item">
          { !this.state.edit ?
            <div>
              { (Meteor.userId() === this.props.post.ownerId) ?
                <div className="pull-right">
                  <button type="button" className="btn btn-link gray" onClick={this.changeToEditMode.bind(this)}>
                    <span className="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                  </button>
                  <button type="button" className="btn btn-link gray" onClick={this.deleteThisPost.bind(this)}>
                    <span className="glyphicon glyphicon-trash" aria-hidden="true"></span>
                  </button>
                  <label className="checkbox-inline">
                    <input
                      type="checkbox"
                      readOnly
                      checked={this.props.post.isPublic}
                      onClick={this.toggleIsPublic.bind(this)}/><small>make public</small>
                  </label>
                </div> : ''
              }
              <h2 onClick={this.toggleIsContentHidden.bind(this)}>
                {this.props.post.title} <small>(by {this.props.post.ownerName})</small>
              </h2>
              { !this.state.contentHidden ?
                <p dangerouslySetInnerHTML={this.rawMarkup()}/> : ''
              }
            </div> :
{'fraction_non_alphanumeric': 0.14215182061304257, 'fraction_numerical': 0.0008228759514503189, 'mean_word_length': 2.0928753180661577, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, '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': '765732', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1401, 'n_words': 232}