<commit_before>/* eslint react/prop-types: 0 */
import ReactDOMServer from 'react-dom/server'

import {copy} from 'copy-paste'

import {getSponsorsForDate} from '../sponsors'

import * as utils from '<utils>/utils'
import episodeList from './utils/episode-list'
import inquirer from 'inquirer'

import LinksPicksTips from './components/links-picks-tips'
import ShowDescription from './components/show-description'
import People from './components/people'

inquirer.prompt([
  episodeList,
]).then(({episode}) => {
  const showSponsors = getSponsorsForDate(episode.date)

  const string = ReactDOMServer.renderToStaticMarkup(
    <EpisodeDescription
      episode={episode}
      sponsors={showSponsors}
    />
  )

  copy(string, err => {
    if (err) {
      throw err
    }
    console.log(`Podcast description for "${episode.title}" copied to your clipboard`)
  })
})


function EpisodeDescription({episode, sponsors}) {
  const {
    date,
    titleHTML,
    descriptionHTML,
    guests,
    host,
    panelists,
  } = episode
  const panelistsAndHost = utils.sortPeople([...panelists, host])
  const showAttendees = [...utils.sortPeople(guests), ...panelistsAndHost]
  const combinedSponsors = [sponsors.premierSponsor, ...sponsors.goldSponsors, ...sponsors.silverSponsors]
  return (
    <div>
      <div>
        <Title
          date={date}
          titleHTML={titleHTML}
          guests={guests}
        />
      </div>

      <div>
        <strong>Description:</strong>
        <div dangerouslySetInnerHTML={descriptionHTML} />
      </div>

      <div>
        <strong>Show sponsors:</strong>
        <ul>
          {
            combinedSponsors.map(({name, link, tagline}, i) => (
              <li key={i}>
                <a href={link}>{name}</a> - {tagline}
              </li>
            ))
          }
        </ul>
      </div>

      <div>
        <strong>Links, Picks, and Tips:</strong>
        {
          showAttendees.map((a, i) => <LinksPicksTips key={i} {...a} />)
        }
      </div>

      <div>
        <strong>About JavaScript Air:</strong>
        <div>
          <ShowDescription />
        </div>
      </div>

    </div>
  )
}

function Title({date, titleHTML, guests}) {
  return (
    <span>
      <a href={`http://javascriptair.com/episodes/${date}`} dangerouslySetInnerHTML={titleHTML} />
      {' with '}
      <People people={guests} />
    </span>
  )
}<commit_msg>Update episode description generator<commit_after>/* eslint react/prop-types: 0 */
import ReactDOMServer from 'react-dom/server'

import {copy} from 'copy-paste'

import {getSponsorsForDate} from '../sponsors'

import * as utils from '<utils>/utils'
import episodeList from './utils/episode-list'
import inquirer from 'inquirer'

import LinksPicksTips from './components/links-picks-tips'
import ShowDescription from './components/show-description'

inquirer.prompt([
  episodeList,
]).then(({episode}) => {
  const showSponsors = getSponsorsForDate(episode.date)

  const string = ReactDOMServer.renderToStaticMarkup(
    <EpisodeDescription
      episode={episode}
      sponsors={showSponsors}
    />
  )

  copy(string, err => {
    if (err) {
      throw err
    }
    console.log(`Podcast description for "${episode.title}" copied to your clipboard`)
  })
})


function EpisodeDescription({episode, sponsors}) {
  const {
    date,
    titleHTML,
    descriptionHTML,
    guests,
    host,
    panelists,
    screenshot,
  } = episode
  const panelistsAndHost = utils.sortPeople([...panelists, host])
  const showAttendees = [...utils.sortPeople(guests), ...panelistsAndHost]
  const combinedSponsors = [sponsors.premierSponsor, ...sponsors.goldSponsors, ...sponsors.silverSponsors]
  return (
    <div>
      <div>
        <Title
          date={date}
          screenshot={screenshot}
          titleHTML={titleHTML}
          guests={guests}
        />
      </div>

      <div>
        <strong>Description:</strong>
        <div dangerouslySetInnerHTML={descriptionHTML} />
      </div>

      <div>
        <strong>Show sponsors:</strong>
        <ul>
          {
            combinedSponsors.map(({name, link, tagline}, i) => (
              <li key={i}>
                <a href={link}>{name}</a> - {tagline}
              </li>
            ))
          }
        </ul>
      </div>

      <div>
        <strong>Links, Picks, and Tips:</strong>
        {
          showAttendees.map((a, i) => <LinksPicksTips key={i} {...a} />)
        }
      </div>

      <div>
        <strong>About JavaScript Air:</strong>
        <div>
          <ShowDescription />
        </div>
      </div>

    </div>
  )
}

function Title({date, screenshot, titleHTML, guests}) {
  return (
    <div>
      <h1>
        <a href={`http://javascriptair.com/episodes/${date}`} dangerouslySetInnerHTML={titleHTML} />
        {' with '}
        <People people={guests} />
      </h1>
      <div>
        <img
          src={screenshot}
          style={{maxWidth: '100%'}}
          alt="Episode Screenshot"
        />
      </div>
    </div>
  )
}


function Person({twitter, name}) {
  return <a href={`https://twitter.com/${twitter}`}>{name}</a>
}

function People({people}) {
  return (
    <span>
      {
        utils.displayListify(
        people.map(({twitter, name}, i) => (
          <Person
            key={i}
            twitter={twitter}
            name={name}
          />
        )))
      }
    </span>
  )
}
{'fraction_non_alphanumeric': 0.1503870254330999, 'fraction_numerical': 0.0012900847769996315, 'mean_word_length': 2.182991202346041, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 98, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2540755', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1727, 'n_words': 337}