<commit_before>import React from 'react';
import { Link, browserHistory } from 'react-router';
import FalcorController from 'lib/falcor/FalcorController';
import SearchBar from 'components/admin/SearchBar';
import List from 'components/admin/List';
import moment from 'moment';

// material-ui
import ListItem from 'material-ui/List/ListItem';
import CircularProgress from 'material-ui/CircularProgress';
import Paper from 'material-ui/Paper';
import Divider from 'material-ui/Divider';
import { darkBlack } from 'material-ui/styles/colors';
import RaisedButton from 'material-ui/RaisedButton';

const styles = {
  paper: {
    height: '100%',
    width: '100%',
    marginTop: 20,
    marginBottom: 20,
    textAlign: 'left',
    display: 'inline-block',
  },
  tabs: {
    paddingLeft: 30,
    paddingRight: 30,
    paddingBottom: 15,
  },
  buttons: {
    margin: 12,
    marginBottom: 24,
  },
};

const NUM_ARTICLES_IN_PAGE = 50;

export default class ArticleListController extends FalcorController {
  constructor(props) {
    super(props);
    this.getNewPagePath = this.getNewPagePath.bind(this);
    this.clickSearchSuggestion = this.clickSearchSuggestion.bind(this);
    this.createListElement = this.createListElement.bind(this);
  }

  static getFalcorPathSets(params) {
    return [
      [
        'articles', 'byPage',
        NUM_ARTICLES_IN_PAGE,
        parseInt(params.page, 10),
        { length: NUM_ARTICLES_IN_PAGE },
        ['title', 'slug', 'teaser', 'published_at'],
      ],
      ['articles', 'length'],
    ];
  }

  getNewPagePath(delta) {
    let path = this.props.location.pathname;
    path = path.split('/');
    path[3] = (parseInt(path[3], 10) + delta).toString();
    return path.join('/');
  }

  clickSearchSuggestion(article) {
    const page = this.props.params.page;
    const path = `/articles/page/${page}/slug/${article.slug}`;
    browserHistory.push(path);
  }

  createListElement(article) {
    const page = this.props.params.page;
    return (
      <Link to={`/articles/page/${page}/slug/${article.slug}`} key={article.slug}>
        <ListItem
          primaryText={article.title}
          secondaryText={
            <p>
              <span style={{ color: darkBlack }}>
                {moment(article.published_at).format('MMM DD, YYYY')}
              </span> {" -- "}
              {article.teaser}
            </p>
          }
          secondaryTextLines={2}
        />
      </Link>
    );
  }<commit_msg>Fix articleList unpublished view<commit_after>import React from 'react';
import { Link, browserHistory } from 'react-router';
import FalcorController from 'lib/falcor/FalcorController';
import SearchBar from 'components/admin/SearchBar';
import List from 'components/admin/List';
import moment from 'moment';

// material-ui
import ListItem from 'material-ui/List/ListItem';
import CircularProgress from 'material-ui/CircularProgress';
import Paper from 'material-ui/Paper';
import Divider from 'material-ui/Divider';
import { darkBlack } from 'material-ui/styles/colors';
import RaisedButton from 'material-ui/RaisedButton';

const styles = {
  paper: {
    height: '100%',
    width: '100%',
    marginTop: 20,
    marginBottom: 20,
    textAlign: 'left',
    display: 'inline-block',
  },
  tabs: {
    paddingLeft: 30,
    paddingRight: 30,
    paddingBottom: 15,
  },
  buttons: {
    margin: 12,
    marginBottom: 24,
  },
};

const NUM_ARTICLES_IN_PAGE = 50;

export default class ArticleListController extends FalcorController {
  constructor(props) {
    super(props);
    this.getNewPagePath = this.getNewPagePath.bind(this);
    this.clickSearchSuggestion = this.clickSearchSuggestion.bind(this);
    this.createListElement = this.createListElement.bind(this);
  }

  static getFalcorPathSets(params) {
    return [
      [
        'articles', 'byPage',
        NUM_ARTICLES_IN_PAGE,
        parseInt(params.page, 10),
        { length: NUM_ARTICLES_IN_PAGE },
        ['title', 'slug', 'teaser', 'published_at'],
      ],
      ['articles', 'length'],
    ];
  }

  getNewPagePath(delta) {
    let path = this.props.location.pathname;
    path = path.split('/');
    path[3] = (parseInt(path[3], 10) + delta).toString();
    return path.join('/');
  }

  clickSearchSuggestion(article) {
    const page = this.props.params.page;
    const path = `/articles/page/${page}/slug/${article.slug}`;
    browserHistory.push(path);
  }

  createListElement(article) {
    const page = this.props.params.page;
    let publishedDate;
    if (article.published_at) {
      publishedDate = moment(article.published_at).format('MMM DD, YYYY');
    } else {
      publishedDate = 'Unpublished';
    }
    return (
      <Link to={`/articles/page/${page}/slug/${article.slug}`} key={article.slug}>
        <ListItem
          primaryText={article.title}
          secondaryText={
            <p>
              <span style={{ color: darkBlack }}>
                {publishedDate}
              </span> {" -- "}
              {article.teaser}
            </p>
          }
          secondaryTextLines={2}
        />
      </Link>
    );
  }
{'fraction_non_alphanumeric': 0.14036463438541463, 'fraction_numerical': 0.011370319545187219, 'mean_word_length': 2.888719512195122, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6263191', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1594, 'n_words': 320}