Skip to content

Commit 4650cbc

Browse files
committed
init
0 parents  commit 4650cbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+102946
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode
2+
node_modules

ac/build.js

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
const { readFileSync, writeFileSync } = require('fs')
2+
const { head } = require('axios')
3+
const { map: conc } = require('bluebird')
4+
const { find, map, toPairs, sortBy } = require('lodash')
5+
6+
const error = s => {
7+
throw new Error(s)
8+
}
9+
10+
const sources = [
11+
/^https:\/\/www.(pixiv).net\/artworks\/\d+$/,
12+
/^https:\/\/seiga.(nicovideo).jp\/seiga\/im\d+$/,
13+
/^https:\/\/(danbooru).donmai.us\/posts\/\d+$/,
14+
/^https:\/\/(twitter).com\/i\/web\/status\/\d+$/,
15+
/^https:\/\/twitter.com\/(.+?)\/status\/\d+$/,
16+
]
17+
18+
const getSourceType = url => find(map(sources, pattern => (url.match(pattern) || [])[1])) || error(url)
19+
20+
const getSource = url => ({ type: getSourceType(url), url })
21+
22+
const getFile = (rarity, name) =>
23+
`${rarity}_${name
24+
.toLowerCase()
25+
.replace(/'/g, '')
26+
.replace(/\s/g, '_')}`
27+
28+
const getImage = (rarity, name) => `https://amusementclub.nyc3.cdn.digitaloceanspaces.com/cards/kancolle/${getFile(rarity, name)}.jpg`
29+
30+
const data = readFileSync('data.csv')
31+
.toString()
32+
.split('\n')
33+
.map(e =>
34+
e
35+
.split(',')
36+
.map(e => e.trim())
37+
.map(e => +e || e),
38+
)
39+
.filter(e => e && typeof e[0] === 'number')
40+
.map(([rarity, ship, name, source], key) => ({
41+
key,
42+
rarity,
43+
ship: ship ? ship.split('/').sort() : [],
44+
name,
45+
source: getSource(source),
46+
file: getFile(rarity, name),
47+
image: getImage(rarity, name),
48+
}))
49+
.sort((a, b) => (a.rarity === b.rarity ? a.name.localeCompare(b.name) : b.rarity - a.rarity))
50+
51+
const popularity = {}
52+
53+
for (const e of data) {
54+
for (const ship of e.ship) {
55+
popularity[ship] = popularity[ship] || 0
56+
++popularity[ship]
57+
}
58+
}
59+
60+
const checkLink = async (url, file) => {
61+
const { status } = await head(`${process.env.proxy || ''}${url}`, { validateStatus: false })
62+
if (status !== 200) {
63+
console.log(`${file} - ${url}${status !== 404 ? ` (${status})` : ''}`)
64+
}
65+
return status
66+
}
67+
68+
const main = async () => {
69+
if (process.argv.includes('--check-source') || process.argv.includes('--check-wiki')) {
70+
await conc(
71+
data,
72+
async e => {
73+
e.source.status = await checkLink(e.source.url, e.file)
74+
if (process.argv.includes('--check-wiki')) {
75+
await conc(e.ship, ship => checkLink(`https://kancolle.fandom.com/wiki/${ship.replace(/ /g, '_')}`, e.file))
76+
}
77+
},
78+
{ concurrency: 10 },
79+
)
80+
}
81+
82+
const wiki = `{|class="wikitable sortable"
83+
!Rarity!!Ship!!Name!!Source!!Image
84+
${data
85+
.map(
86+
e => `|-
87+
|${e.rarity}||${e.ship.map(e => `[[${e}]]`).join('<br>')}||${e.name}||[${e.source.url} ${
88+
e.source.type
89+
}]||<span class="external-image" data-width="200">[${e.image}]</span>`,
90+
)
91+
.join('\n')}
92+
|}
93+
`
94+
95+
const csv = `rarity, ship, name, source, image
96+
${data.map(e => `${e.rarity}, ${e.ship ? e.ship.join('/') : ''}, ${e.name}, ${e.source.url}, ${e.image}`).join('\n')}
97+
`
98+
99+
const dataTs = `const data = ${JSON.stringify(data, null, 2)}
100+
101+
export default data
102+
`
103+
104+
const popularityTs = `const data = ${JSON.stringify(sortBy(toPairs(popularity), e => -e[1]).map(([ship, count]) => ({ ship, count })), null, 2)}
105+
106+
export default data
107+
`
108+
109+
writeFileSync('data.wiki', wiki)
110+
writeFileSync('data.csv', csv)
111+
writeFileSync('src/data.ts', dataTs)
112+
writeFileSync('src/popularity.ts', popularityTs)
113+
}
114+
115+
main()

ac/data.csv

+261
Large diffs are not rendered by default.

ac/data.wiki

+523
Large diffs are not rendered by default.

ac/package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"start": "react-scripts start",
5+
"build": "react-scripts build",
6+
"test": "react-scripts test",
7+
"eject": "react-scripts eject"
8+
},
9+
"devDependencies": {
10+
"@types/jest": "24.0.19",
11+
"@types/node": "12.11.1",
12+
"@types/react": "16.9.9",
13+
"@types/react-dom": "16.9.2",
14+
"antd": "^3.24.1",
15+
"axios": "^0.19.0",
16+
"bluebird": "^3.7.1",
17+
"eslint-plugin-react-hooks": "^2.1.2",
18+
"lodash": "^4.17.15",
19+
"react": "^16.10.2",
20+
"react-dom": "^16.10.2",
21+
"react-scripts": "3.2.0",
22+
"typescript": "3.6.4"
23+
},
24+
"eslintConfig": {
25+
"extends": "react-app"
26+
},
27+
"browserslist": {
28+
"production": [
29+
">0.2%",
30+
"not dead",
31+
"not op_mini all"
32+
],
33+
"development": [
34+
"last 1 chrome version",
35+
"last 1 firefox version",
36+
"last 1 safari version"
37+
]
38+
}
39+
}

ac/public/favicon.ico

21.9 KB
Binary file not shown.

ac/public/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<link rel="apple-touch-icon" href="logo192.png" />
9+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
10+
<title>Amusement Club KanColle Cards</title>
11+
</head>
12+
<body>
13+
<noscript>You need to enable JavaScript to run this app.</noscript>
14+
<div id="root"></div>
15+
</body>
16+
</html>

ac/public/logo192.png

8.38 KB
Loading

ac/public/logo512.png

22.4 KB
Loading

ac/public/manifest.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "Amusement Club KanColle Cards",
3+
"name": "Amusement Club KanColle Cards",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

ac/public/robots.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *

ac/src/App.css

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@import '~antd/dist/antd.css';
2+
3+
.App {
4+
text-align: center;
5+
}
6+
7+
.App-logo {
8+
height: 40vmin;
9+
}
10+
11+
.App-header {
12+
background-color: #282c34;
13+
min-height: 100vh;
14+
display: flex;
15+
flex-direction: column;
16+
align-items: center;
17+
justify-content: center;
18+
font-size: calc(10px + 2vmin);
19+
color: white;
20+
}
21+
22+
.App-link {
23+
color: #09d3ac;
24+
}

ac/src/App.test.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import App from './App'
4+
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div')
7+
ReactDOM.render(<App />, div)
8+
ReactDOM.unmountComponentAtNode(div)
9+
})

0 commit comments

Comments
 (0)