<commit_before>import React, { Component, PropTypes } from 'react';
import localforage from 'localforage';
import debounce from 'lodash.debounce';
import uuid from 'node-uuid';

import Header from './Header';
import Editor from './Editor';
import Footer from './Footer';

const { string } = PropTypes;


export default class App extends Component {
  constructor(props, context) {
    super(props, context);

    localforage.config({
      name: 'monod'
    });

    this.state = {
      document: {
        uuid: uuid.v1(),
        content: DEFAULT_CONTENT
      },
      secret: 'foo'
    };

    this.updateContent = debounce(this.updateContent, 1000);
  }

  componentDidMount() {
    const id = window.location.pathname.slice(1);
    const secret = window.location.hash.slice(1);

    localforage
      .getItem(id)
      .then((document) => {
        if (null !== document) {
          this.setState({
            document: document,
            secret: secret
          });
        }
      });
  }

  componentDidUpdate() {
    window.history.pushState({}, '', '/' + this.state.document.uuid);
  }

  updateContent(content) {
    if (DEFAULT_CONTENT === content) {
      return;
    }

    this.setState({
      document: {
        uuid: this.state.document.uuid,
        content: content
      },
      secret: this.state.secret
    });

    localforage.setItem(
      this.state.document.uuid,
      this.state.document
    );
  }

  render() {
    return (
      <div className="layout">
        <Header />
        <Editor
          content={this.state.document.content}
          onContentUpdate={this.updateContent.bind(this)}
        />
        <Footer version={this.props.version} />
      </div>
    );
  }
}

App.propTypes = {
  version: string.isRequired
};

const DEFAULT_CONTENT = [
  'Introducing Monod',
  '=================',
  '',
  '> **TL;DR** This editor is the first experiment we wanted to tackle at **Le lab**. This _week #1 release_ is a pure client-side application written with [React](https://facebook.github.io/react/) by the good folks at [TailorDev](https://tailordev.fr)!',
  '',
  'Read more about how and why we built Monod at: https://tailordev.fr/blog/.',
  '',
  'See, we have code & Emoji support, yay! :clap:',
  '',
  '``` python',
  'def hello():',
  '    print("Have fun with Monod!")',
  '```',
  '',
  '*Play with this page and [send us feedback](mailto:<EMAIL>?subject=About Monod). We would :heart: to hear from you!*'
].join('\n');
<commit_msg>Generate v4 (random) ids<commit_after>import React, { Component, PropTypes } from 'react';
import localforage from 'localforage';
import debounce from 'lodash.debounce';
import uuid from 'uuid';

import Header from './Header';
import Editor from './Editor';
import Footer from './Footer';

const { string } = PropTypes;


export default class App extends Component {
  constructor(props, context) {
    super(props, context);

    localforage.config({
      name: 'monod'
    });

    this.state = {
      document: {
        uuid: uuid.v4(),
        content: DEFAULT_CONTENT
      },
      secret: 'foo'
    };

    this.updateContent = debounce(this.updateContent, 1000);
  }

  componentDidMount() {
    const id = window.location.pathname.slice(1);
    const secret = window.location.hash.slice(1);

    localforage
      .getItem(id)
      .then((document) => {
        if (null !== document) {
          this.setState({
            document: document,
            secret: secret
          });
        }
      });
  }

  componentDidUpdate() {
    window.history.pushState({}, '', '/' + this.state.document.uuid);
  }

  updateContent(content) {
    if (DEFAULT_CONTENT === content) {
      return;
    }

    this.setState({
      document: {
        uuid: this.state.document.uuid,
        content: content
      },
      secret: this.state.secret
    });

    localforage.setItem(
      this.state.document.uuid,
      this.state.document
    );
  }

  render() {
    return (
      <div className="layout">
        <Header />
        <Editor
          content={this.state.document.content}
          onContentUpdate={this.updateContent.bind(this)}
        />
        <Footer version={this.props.version} />
      </div>
    );
  }
}

App.propTypes = {
  version: string.isRequired
};

const DEFAULT_CONTENT = [
  'Introducing Monod',
  '=================',
  '',
  '> **TL;DR** This editor is the first experiment we wanted to tackle at **Le lab**. This _week #1 release_ is a pure client-side application written with [React](https://facebook.github.io/react/) by the good folks at [TailorDev](https://tailordev.fr)!',
  '',
  'Read more about how and why we built Monod at: https://tailordev.fr/blog/.',
  '',
  'See, we have code & Emoji support, yay! :clap:',
  '',
  '``` python',
  'def hello():',
  '    print("Have fun with Monod!")',
  '```',
  '',
  '*Play with this page and [send us feedback](mailto:<EMAIL>?subject=About Monod). We would :heart: to hear from you!*'
].join('\n');

{'fraction_non_alphanumeric': 0.1566626650660264, 'fraction_numerical': 0.003401360544217687, 'mean_word_length': 2.5580071174377226, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 6, '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': '4588065', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1552, 'n_words': 377}