<commit_before>import React, { PropTypes as T } from "react";
import { Table, Grid, Icon } from "semantic-ui-react";

import NextLink from "next/link";

// Convert simple links to next style href + as
// TODO: Actually finish implementing this...
const Link = ({ to, children }) =>
  <NextLink href={to} as={to}>
    <a>
      {children}
    </a>
  </NextLink>;

const DirectoryListing = props => {
  const base = props.basepath || "/";
  return (
    <Grid>
      <Grid.Column>
        <Table basic="very" padded>
          <Table.Header>
            <Table.Row />
          </Table.Header>
          <Table.Body>
            {props.contents.map((row, index) => {
              const fullPath = `${base}/${row.path}`;
              if (!row.type) {
                return null;
              }
              switch (row.type) {
                case "notebook":
                  return (
                    <Table.Row key={index}>
                      <Table.Cell>
                        <Link to={fullPath}>
                          <Icon name="book" color="grey" />
                          {row.name}
                        </Link>
                      </Table.Cell>
                      <Table.Cell collapsing textAlign="right" />
                    </Table.Row>
                  );
                case "directory":
                  return (
                    <Table.Row key={index}>
                      <Table.Cell collapsing>
                        <Link to={fullPath}>
                          <Icon name="folder" color="blue" />
                          {row.name}
                        </Link>
                      </Table.Cell>
                      <Table.Cell collapsing textAlign="right" />
                    </Table.Row>
                  );
                case "file":
                  return (
                    <Table.Row key={index}>
                      <Table.Cell collapsing>
                        <Link to={fullPath}>
                          <Icon name="file" color="grey" />
                          {row.name}
                        </Link>
                      </Table.Cell>
                      <Table.Cell collapsing textAlign="right" />
                    </Table.Row>
                  );
                default:
                  return null;
              }
            })}
          </Table.Body>
        </Table>
      </Grid.Column>
    </Grid>
  );
};<commit_msg>complete the internal implementation of Link<commit_after>import React, { PropTypes as T } from "react";
import { Table, Grid, Icon } from "semantic-ui-react";

import NextLink from "next/link";

// Convert simple links to next style href + as
// TODO: Actually finish implementing this...
const Link = ({ to, children, basepath }) =>
  <NextLink
    href={{ pathname: "/view", query: { viewPath: to } }}
    as={basepath + "/" + to}
  >
    <a>
      {children}
    </a>
  </NextLink>;

const DirectoryListing = props => {
  const base = props.basepath || "/";
  return (
    <Grid>
      <Grid.Column>
        <Table basic="very" padded>
          <Table.Header>
            <Table.Row />
          </Table.Header>
          <Table.Body>
            {props.contents.map((row, index) => {
              if (!row.type) {
                return null;
              }
              switch (row.type) {
                case "notebook":
                  return (
                    <Table.Row key={index}>
                      <Table.Cell>
                        <Link to={row.path} basepath={base}>
                          <Icon name="book" color="grey" />
                          {row.name}
                        </Link>
                      </Table.Cell>
                      <Table.Cell collapsing textAlign="right" />
                    </Table.Row>
                  );
                case "directory":
                  return (
                    <Table.Row key={index}>
                      <Table.Cell collapsing>
                        <Link to={row.path} basepath={base}>
                          <Icon name="folder" color="blue" />
                          {row.name}
                        </Link>
                      </Table.Cell>
                      <Table.Cell collapsing textAlign="right" />
                    </Table.Row>
                  );
                case "file":
                  return (
                    <Table.Row key={index}>
                      <Table.Cell collapsing>
                        <Link to={row.path} basepath={base}>
                          <Icon name="file" color="grey" />
                          {row.name}
                        </Link>
                      </Table.Cell>
                      <Table.Cell collapsing textAlign="right" />
                    </Table.Row>
                  );
                default:
                  return null;
              }
            })}
          </Table.Body>
        </Table>
      </Grid.Column>
    </Grid>
  );
};
{'fraction_non_alphanumeric': 0.12462372065021071, 'fraction_numerical': 0.0, 'mean_word_length': 0.9483971853010165, 'pattern_counts': {'":': 6, '<': 81, '<?xml version=': 0, '>': 87, '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': '2766185', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1188, 'n_words': 274}