<commit_before>import React from 'react'

export default class Document extends React.Component {

  componentWillMount() {
    let docUrl = this.props.docUrl
    let split = docUrl.split('/')
    let docId = split.pop()

    this.baseUrl = split.join('/')

    if(window.HOOVER_HYDRATE_DOC) {
      this.setState({doc: window.HOOVER_HYDRATE_DOC, loaded: true})
    }
    else {
      $.get(`${docUrl}/json`, (doc) => {
        this.setState({doc: doc, loaded: true})
      })
    }
  }

  render() {
    let state = this.state || {}
    let doc = state.doc || {}
    let loaded = state.loaded
    let data = doc.content
    let files = doc.children || []
    let headerLinks = []

    if(!loaded) return <DocumentLoading />

    if(this.props.fullPage) {
      if(doc.parent_id) {
        headerLinks.push({
          href: `${this.props.collectionBaseUrl}${doc.parent_id}`,
          text: "Up",
          icon: 'fa fa-level-up',
        })
      }
    }
    else {
      headerLinks.push({
        href: `${this.props.docUrl}`,
        text: "Open in new tab",
        icon: 'fa fa-external-link-square',
        target: '_blank',
      })
    }

    if(data.filetype != 'folder') {
      headerLinks.push({
        href: `${this.props.docUrl}/raw/${data.filename}`,
        text: `Original file`,
        icon: 'fa fa-cloud-download',<commit_msg>open original file in new tab if `fullPage`<commit_after>import React from 'react'

export default class Document extends React.Component {

  componentWillMount() {
    let docUrl = this.props.docUrl
    let split = docUrl.split('/')
    let docId = split.pop()

    this.baseUrl = split.join('/')

    if(window.HOOVER_HYDRATE_DOC) {
      this.setState({doc: window.HOOVER_HYDRATE_DOC, loaded: true})
    }
    else {
      $.get(`${docUrl}/json`, (doc) => {
        this.setState({doc: doc, loaded: true})
      })
    }
  }

  render() {
    let state = this.state || {}
    let doc = state.doc || {}
    let loaded = state.loaded
    let data = doc.content
    let files = doc.children || []
    let headerLinks = []

    if(!loaded) return <DocumentLoading />

    if(this.props.fullPage) {
      if(doc.parent_id) {
        headerLinks.push({
          href: `${this.props.collectionBaseUrl}${doc.parent_id}`,
          text: "Up",
          icon: 'fa fa-level-up',
        })
      }
    }
    else {
      headerLinks.push({
        href: `${this.props.docUrl}`,
        text: "Open in new tab",
        icon: 'fa fa-external-link-square',
        target: '_blank',
      })
    }

    if(data.filetype != 'folder') {
      headerLinks.push({
        href: `${this.props.docUrl}/raw/${data.filename}`,
        text: `Original file`,
        icon: 'fa fa-cloud-download',
        target: this.props.fullPage ? null : '_blank',
{'fraction_non_alphanumeric': 0.15727109515260324, 'fraction_numerical': 0.0, 'mean_word_length': 2.1876430205949657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '865672', 'n_tokens_mistral': 909, 'n_tokens_neox': 898, 'n_words': 190}