소스 검색

Move app to it's own folder since scraper will be added to the repo

Tatiana Inama 6 년 전
부모
커밋
910c51e80c

+ 1 - 1
.gitignore

@@ -1,7 +1,7 @@
 # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
 
 # dependencies
-/node_modules
+node_modules
 /.pnp
 .pnp.js
 

README.md → app/README.md


package-lock.json → app/package-lock.json


package.json → app/package.json


public/favicon.ico → app/public/favicon.ico


public/index.html → app/public/index.html


public/logo192.png → app/public/logo192.png


public/logo512.png → app/public/logo512.png


public/manifest.json → app/public/manifest.json


public/robots.txt → app/public/robots.txt


src/App.css → app/src/App.css


src/App.test.tsx → app/src/App.test.tsx


src/App.tsx → app/src/App.tsx


+ 39 - 39
src/DataParser.ts

@@ -1,40 +1,40 @@
-const month = [ '', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
-
-// enum LOCATION {
-//   River,
-//   RiverClifftop,
-//   RiverMouth,
-//   Pond,
-//   Sea,
-//   Pier
-// };
-export const FishLocationLabel = [
-  'river',
-  'clifftop river',
-  'river mouth',
-  'pond',
-  'sea',
-  'pier'
-];
-
-export const FishSizeLabel = [
-  '',
-  "Tiny",
-  "Small",
-  "Medium",
-  "Large",
-  "Very Large",
-  "Huge",
-  "Long",
-  "Fin"
-];
-
-export const parseMonth = (num: number) => month[num];
-export const parseFishLocation = (num: number) => FishLocationLabel[num];
-export const parseFishSize = (num: number) => FishSizeLabel[num];
-
-export default {
-  parseMonth,
-  parseFishLocation,
-  parseFishSize,
+const month = [ '', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
+
+// enum LOCATION {
+//   River,
+//   RiverClifftop,
+//   RiverMouth,
+//   Pond,
+//   Sea,
+//   Pier
+// };
+export const FishLocationLabel = [
+  'river',
+  'clifftop river',
+  'river mouth',
+  'pond',
+  'sea',
+  'pier'
+];
+
+export const FishSizeLabel = [
+  '',
+  "Tiny",
+  "Small",
+  "Medium",
+  "Large",
+  "Very Large",
+  "Huge",
+  "Long",
+  "Fin"
+];
+
+export const parseMonth = (num: number) => month[num];
+export const parseFishLocation = (num: number) => FishLocationLabel[num];
+export const parseFishSize = (num: number) => FishSizeLabel[num];
+
+export default {
+  parseMonth,
+  parseFishLocation,
+  parseFishSize,
 };

+ 152 - 152
src/Fish.tsx

@@ -1,153 +1,153 @@
-import React, { FunctionComponent, useState } from 'react';
-import { Table, Tag, Button } from 'antd';
-import moment from 'moment';
-import { includes } from 'ramda';
-
-import FISHES from './fish-data.json';
-import { Fish, Month, Time, FishLocation } from './types';
-import { parseMonth, parseFishLocation, FishLocationLabel, parseFishSize } from './DataParser';
-
-type props = {
-};
-
-const FishData = FISHES as unknown as Fish[];
-
-const FishTable: FunctionComponent<props> = () => {
-  const [ data, setData ] = useState<Fish[]>(FishData);
-
-  const isInTimeRange = (rangeTime: Time) => {
-    return rangeTime.some(([from, to]) => moment().isBetween(moment().hour(from).minute(0), moment().hour(to < from ? to + 24 : to).minute(0)));
-  }
-
-  const availableNow = () => {
-    const currentMonth = moment().month() + 1;
-    const xs = data.filter(fish => {
-      return includes(currentMonth, fish.months) && isInTimeRange(fish.time)
-    });
-    setData(xs)
-  }
-
-  const columns = [
-    {
-      title: '',
-      dataIndex: 'image',
-      render: (image: string) => (<img src={image} alt='' className="fish-icon"/>)
-    },
-    {
-      title: 'Name',
-      dataIndex: 'name'
-    },
-    {
-      title: 'Location',
-      dataIndex: 'location',
-      render: (location: FishLocation) => parseFishLocation(location),
-      filters: FishLocationLabel.map((location, id) => ({
-        text: location,
-        value: id
-      })),
-      onFilter: (value: string | number | boolean, fish: Fish) => fish.location === value,
-    },
-    {
-      title: 'Time',
-      dataIndex: 'time',
-      render: (time: Time) => DisplayTime({time})
-    },
-    {
-      title: 'Availability',
-      dataIndex: 'months',
-      render: (months: Month[]) => DisplayMonths({ months })
-    },
-    {
-      title: 'Price',
-      dataIndex: 'price',
-      sorter: {
-        compare: (a: Fish, b: Fish) => a.price - b.price,
-        multiple: 1
-      }
-    },
-    {
-      title: 'Size',
-      dataIndex: 'shadowSize',
-      render: (size: number) => parseFishSize(size)
-    },
-  ];
-
-  return (
-    <>
-    <div>
-      <Button onClick={() => availableNow()}>available now</Button>
-      <Button onClick={() => setData(FishData)}>show all</Button>
-    </div>
-    <Table<Fish>
-      columns={columns}
-      dataSource={data}
-      size="small"
-      pagination={false}
-    >
-    </Table>
-    </>
-
-  )
-}
-
-const showAvailability = (months: Month[]) => {
-  const currentMonth = (moment().get('month') as Month) + 1;
-
-  if (months.length === 12){
-    return {
-      color: 'green',
-      text: 'all year'
-    }
-  }
-  const availableNow = months.findIndex(m => m === currentMonth);
-  
-  if (availableNow === -1) {
-    const availableFrom = months.find(m => m > currentMonth) || 1;
-    return {
-      color: 'red',
-      text: `from ${parseMonth(availableFrom)}`
-    }
-  }
-
-  const nextIteration = (i: number) => (i + 1) % months.length;
-  
-  let i = availableNow;
-  while (true) {
-    const actual = months[i];
-    const next = months[nextIteration(i)];
-    
-    if ( (actual % 12) + 1 !== next) {
-      const lastMonth = actual === currentMonth;
-      return lastMonth ? {
-        color: 'orange',
-        text: 'last month available'
-      } : {
-        color: 'blue',
-        text: `until ${parseMonth(actual)}`
-      }
-    } else {
-      i = nextIteration(i);
-    }
-  }
-}
-
-const DisplayMonths: FunctionComponent<{months: Month[]}> = ({ months }) => {
-  const result = showAvailability(months);
-  return (
-    <Tag color={result.color}>{result.text}</Tag>
-  )
-}
-
-const DisplayTime: FunctionComponent<{time: Time}> = ({ time }) => {
-  return (
-    <div>
-      {
-        time.map(([from, to]) => {
-          return (from === 0 && to === 24) ?
-            'All day' : `${from}hs - ${to}hs`
-        }).join(' & ')
-      }
-    </div>
-  );
-}
+import React, { FunctionComponent, useState } from 'react';
+import { Table, Tag, Button } from 'antd';
+import moment from 'moment';
+import { includes } from 'ramda';
+
+import FISHES from './fish-data.json';
+import { Fish, Month, Time, FishLocation } from './types';
+import { parseMonth, parseFishLocation, FishLocationLabel, parseFishSize } from './DataParser';
+
+type props = {
+};
+
+const FishData = FISHES as unknown as Fish[];
+
+const FishTable: FunctionComponent<props> = () => {
+  const [ data, setData ] = useState<Fish[]>(FishData);
+
+  const isInTimeRange = (rangeTime: Time) => {
+    return rangeTime.some(([from, to]) => moment().isBetween(moment().hour(from).minute(0), moment().hour(to < from ? to + 24 : to).minute(0)));
+  }
+
+  const availableNow = () => {
+    const currentMonth = moment().month() + 1;
+    const xs = data.filter(fish => {
+      return includes(currentMonth, fish.months) && isInTimeRange(fish.time)
+    });
+    setData(xs)
+  }
+
+  const columns = [
+    {
+      title: '',
+      dataIndex: 'image',
+      render: (image: string) => (<img src={image} alt='' className="fish-icon"/>)
+    },
+    {
+      title: 'Name',
+      dataIndex: 'name'
+    },
+    {
+      title: 'Location',
+      dataIndex: 'location',
+      render: (location: FishLocation) => parseFishLocation(location),
+      filters: FishLocationLabel.map((location, id) => ({
+        text: location,
+        value: id
+      })),
+      onFilter: (value: string | number | boolean, fish: Fish) => fish.location === value,
+    },
+    {
+      title: 'Time',
+      dataIndex: 'time',
+      render: (time: Time) => DisplayTime({time})
+    },
+    {
+      title: 'Availability',
+      dataIndex: 'months',
+      render: (months: Month[]) => DisplayMonths({ months })
+    },
+    {
+      title: 'Price',
+      dataIndex: 'price',
+      sorter: {
+        compare: (a: Fish, b: Fish) => a.price - b.price,
+        multiple: 1
+      }
+    },
+    {
+      title: 'Size',
+      dataIndex: 'shadowSize',
+      render: (size: number) => parseFishSize(size)
+    },
+  ];
+
+  return (
+    <>
+    <div>
+      <Button onClick={() => availableNow()}>available now</Button>
+      <Button onClick={() => setData(FishData)}>show all</Button>
+    </div>
+    <Table<Fish>
+      columns={columns}
+      dataSource={data}
+      size="small"
+      pagination={false}
+    >
+    </Table>
+    </>
+
+  )
+}
+
+const showAvailability = (months: Month[]) => {
+  const currentMonth = (moment().get('month') as Month) + 1;
+
+  if (months.length === 12){
+    return {
+      color: 'green',
+      text: 'all year'
+    }
+  }
+  const availableNow = months.findIndex(m => m === currentMonth);
+  
+  if (availableNow === -1) {
+    const availableFrom = months.find(m => m > currentMonth) || 1;
+    return {
+      color: 'red',
+      text: `from ${parseMonth(availableFrom)}`
+    }
+  }
+
+  const nextIteration = (i: number) => (i + 1) % months.length;
+  
+  let i = availableNow;
+  while (true) {
+    const actual = months[i];
+    const next = months[nextIteration(i)];
+    
+    if ( (actual % 12) + 1 !== next) {
+      const lastMonth = actual === currentMonth;
+      return lastMonth ? {
+        color: 'orange',
+        text: 'last month available'
+      } : {
+        color: 'blue',
+        text: `until ${parseMonth(actual)}`
+      }
+    } else {
+      i = nextIteration(i);
+    }
+  }
+}
+
+const DisplayMonths: FunctionComponent<{months: Month[]}> = ({ months }) => {
+  const result = showAvailability(months);
+  return (
+    <Tag color={result.color}>{result.text}</Tag>
+  )
+}
+
+const DisplayTime: FunctionComponent<{time: Time}> = ({ time }) => {
+  return (
+    <div>
+      {
+        time.map(([from, to]) => {
+          return (from === 0 && to === 24) ?
+            'All day' : `${from}hs - ${to}hs`
+        }).join(' & ')
+      }
+    </div>
+  );
+}
 export default FishTable;

+ 8 - 8
src/Insect.tsx

@@ -1,9 +1,9 @@
-import React, { FunctionComponent } from 'react';
-
-const InsectTable: FunctionComponent = () => {
-  return (
-    <div>insect</div>
-  )
-};
-
+import React, { FunctionComponent } from 'react';
+
+const InsectTable: FunctionComponent = () => {
+  return (
+    <div>insect</div>
+  )
+};
+
 export default InsectTable;

src/fish-data.json → app/src/fish-data.json


src/index.css → app/src/index.css


src/index.tsx → app/src/index.tsx


src/logo.svg → app/src/logo.svg


src/react-app-env.d.ts → app/src/react-app-env.d.ts


src/serviceWorker.ts → app/src/serviceWorker.ts


src/setupTests.ts → app/src/setupTests.ts


+ 46 - 46
src/types.ts

@@ -1,47 +1,47 @@
-// Type definitions for [~Critter~]
-// Project: [~critter-crossing~]
-// Definitions by: [~tinama~]
-
-export type Time = [number, number][];
-export type Month = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
-type FishLocationLabel = "River" | "River Clifftop" | "River Mouth" | "Pond" | "Sea" | "Pier";
-export enum FishLocation {
-  River,
-  RiverClifftop,
-  RiverMouth,
-  Pond,
-  Sea,
-  Pier
-}
-enum ShadowSize {
-  Tiny,
-  Small,
-  Medium,
-  Large,
-  VeryLarge,
-  Huge,
-  Long,
-  Fin
-}
-type ShadowSizeLabel = "Tiny" | "Small" | "Medium" | "Large" | "Very Large" | "Huge" | "Long" | "Fin";
-type BugLocation = "Flying" | "Flying by Hybrid Flowers" | "Flying by Light" | "On Trees" | "On the Ground" | "On Flowers" | "On Flowers (White)" | "Shaking Trees" | "Underground" | "On Ponds and Rivers" | "On Tree Stumps" | "On the Ground (rolling snowballs)" | "On Trees (Coconut)" | "Under Trees Disguised as Leafs" | "On rotten food" | "Beach disguised as Shells" | "On Beach Rocks" | "On Trash Items" | "Villager's Heads" | "On Rocks (Rain)" | "Hitting Rocks";
-
-export interface Critter {
-  name: string,
-  image: string,
-  price: number,
-  time: Time,
-  months: Month[],
-}
-
-export interface Fish extends Critter {
-  location: FishLocation,
-  shadowSize: ShadowSize
-}
-
-export interface Bug extends Critter {
-  flickPrice: number,
-  location: BugLocation
-}
-
+// Type definitions for [~Critter~]
+// Project: [~critter-crossing~]
+// Definitions by: [~tinama~]
+
+export type Time = [number, number][];
+export type Month = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
+type FishLocationLabel = "River" | "River Clifftop" | "River Mouth" | "Pond" | "Sea" | "Pier";
+export enum FishLocation {
+  River,
+  RiverClifftop,
+  RiverMouth,
+  Pond,
+  Sea,
+  Pier
+}
+enum ShadowSize {
+  Tiny,
+  Small,
+  Medium,
+  Large,
+  VeryLarge,
+  Huge,
+  Long,
+  Fin
+}
+type ShadowSizeLabel = "Tiny" | "Small" | "Medium" | "Large" | "Very Large" | "Huge" | "Long" | "Fin";
+type BugLocation = "Flying" | "Flying by Hybrid Flowers" | "Flying by Light" | "On Trees" | "On the Ground" | "On Flowers" | "On Flowers (White)" | "Shaking Trees" | "Underground" | "On Ponds and Rivers" | "On Tree Stumps" | "On the Ground (rolling snowballs)" | "On Trees (Coconut)" | "Under Trees Disguised as Leafs" | "On rotten food" | "Beach disguised as Shells" | "On Beach Rocks" | "On Trash Items" | "Villager's Heads" | "On Rocks (Rain)" | "Hitting Rocks";
+
+export interface Critter {
+  name: string,
+  image: string,
+  price: number,
+  time: Time,
+  months: Month[],
+}
+
+export interface Fish extends Critter {
+  location: FishLocation,
+  shadowSize: ShadowSize
+}
+
+export interface Bug extends Critter {
+  flickPrice: number,
+  location: BugLocation
+}
+
 export default Critter;

tsconfig.json → app/tsconfig.json


scrape/bugs.json → scraper/bugs.json


scrape/fish.json → scraper/fish.json


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 126 - 126
scrape/index.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 142 - 142
scrape/index.ts