Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency superagent to v7 - autoclosed #262

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/netlify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
name: Build and Deploy to Netlify
on:
push:
branchs:
- master
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
build:
runs-on: ubuntu-18.04
Expand All @@ -22,14 +28,13 @@ jobs:
uses: nwtgck/[email protected]
with:
publish-dir: './out'
production-branch: master
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
deploy-message: 'Deploy from GitHub Actions'
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.19.0
14.19.3
37 changes: 21 additions & 16 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
/* eslint-disable import/no-extraneous-dependencies */
const withImages = require('next-images')
const withPWA = require('next-pwa')

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})

module.exports = withBundleAnalyzer(
withImages({
webpack(config) {
config.module.rules.push({
test: /\.(png|jpeg|jpg|gif|svg)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
},
const config = {
pwa: {
dest: 'public',
disable: process.env.NODE_ENV === 'development',
},
webpack(config) {
config.module.rules.push({
test: /\.(png|jpeg|jpg|gif|svg)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
},
})
return config
},
})
)
},
})
return config
},
}

module.exports = withPWA(withBundleAnalyzer(withImages(config)))
34 changes: 18 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"version": "0.1.0",
"dependencies": {
"2ch-trip": "1.0.1",
"@emotion/react": "11.7.1",
"@emotion/styled": "11.6.0",
"@emotion/react": "11.9.3",
"@emotion/styled": "11.9.3",
"@mui/material": "5.4.3",
"@mui/styled-engine-sc": "5.4.2",
"@next/bundle-analyzer": "11.1.4",
"axios": "0.26.0",
"axios": "0.27.2",
"bluebird": "3.7.2",
"copy-to-clipboard": "3.3.1",
"decimal.js": "10.3.1",
"emoji-toolkit": "6.6.0",
"history": "5.3.0",
Expand All @@ -18,41 +19,42 @@
"lint-staged": "11.2.6",
"lodash": "4.17.21",
"next": "11.1.4",
"next-pwa": "5.5.4",
"noise": "0.0.0",
"noisejs": "2.1.0",
"prettier": "2.5.1",
"prettier": "2.6.2",
"react": "17.0.2",
"react-dev-utils": "11.0.4",
"react-dom": "17.0.2",
"react-google-charts": "3.0.15",
"react-router-dom": "5.3.0",
"react-svg": "14.1.12",
"react-use": "17.3.2",
"styled-components": "5.3.3",
"superagent": "6.1.0",
"react-router-dom": "5.3.3",
"react-svg": "14.1.19",
"react-use": "17.4.0",
"styled-components": "5.3.5",
"superagent": "7.1.6",
"tiny-segmenter": "0.2.0",
"tone": "14.7.77",
"use-seconds": "1.6.0",
"zdog": "1.1.3"
},
"devDependencies": {
"@types/bluebird": "3.5.36",
"@types/lodash": "4.14.179",
"@types/node": "16.11.26",
"@types/react": "17.0.39",
"@types/react-dom": "17.0.11",
"@types/lodash": "4.14.182",
"@types/node": "16.11.41",
"@types/react": "17.0.47",
"@types/react-dom": "17.0.17",
"@types/react-helmet": "6.1.5",
"@types/react-router-dom": "5.3.3",
"@types/styled-components": "5.1.23",
"@types/styled-components": "5.1.25",
"@zeit/next-source-maps": "0.0.3",
"babel-plugin-styled-components": "1.13.3",
"eslint": "8.8.0",
"eslint-config-next": "11.1.4",
"eslint-config-nzap": "5.0.0",
"next-images": "1.8.4",
"typescript": "4.5.5",
"typescript": "4.7.3",
"url-loader": "4.1.1",
"webpack": "5.69.1"
"webpack": "5.73.0"
},
"homepage": "https://hello.vipper.dev",
"lint-staged": {
Expand Down
Binary file added public/fixurl-res/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions public/fixurl-res/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"short_name": "fixurl",
"name": "fixurl",
"icons": [
{
"src": "/fixurl-res/icon.png",
"sizes": "256x256",
"type": "image/png"
}
],
"start_url": "/tool/fixurl",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff",
"share_target": {
"action": "/tool/fixurl",
"method": "GET",
"params": {
"text": "text"
}
}
}
2 changes: 2 additions & 0 deletions src/components/menuGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const menuGroups: MenuGroup[] = [
{ path: '/tool/words-regex', name: '正規表現メーカー' },
{ path: '/tool/ruru', name: 'るるさん' },
{ path: '/tool/uraru', name: 'yuuaarueru' },
{ path: '/tool/column', name: '2列テキストツール' },
{ path: '/tool/pastable-url', name: 'レスできるURL生成' },
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const App = ({ Component, pageProps }: AppProps) => (
/>
<link rel="shortcut icon" href="/favicon.png" key="shortcutIcon" />
<meta name="theme-color" content="#000" key="themeColor" />
<link rel="manifest" href="/manifest.json" />
{/* <link rel="manifest" href="/manifest.json" /> */}
<link
href="https://fonts.googleapis.com/css?family=Nova+Mono"
rel="stylesheet"
Expand Down
118 changes: 118 additions & 0 deletions src/pages/tool/column.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { Container, Grid, Slider, TextField, Typography } from '@mui/material'
import { groupBy, range, rangeRight } from 'lodash'
import { useState } from 'react'
import { useLocalStorage } from 'react-use'
import styled from 'styled-components'
import Layout from '../../components/Layout'

const charLen = (c: string) => (c.match(/[\x01-\x7E\uFF65-\uFF9F]/) ? 2 : 1)

const textLen = (s: string) =>
s
.split('')
.map(charLen)
.reduce((a, b) => a + b, 0)
const columnText = (text: string, col: number): string => {
const lines = Object.entries(text.split('\n')).map(([line, text]) => ({
line: Number(line),
text,
}))
const rows = Object.entries(
groupBy(lines, ({ line }) => Math.floor(line / col))
).map(([col, words]) => ({ col, words }))

// TODO order: ↓→↓、→↓→

const lens = range(rows[0].words.length).map((ci) =>
rows
.map(({ words }) => textLen(words[ci]?.text || ''))
.reduce((a, b) => Math.max(a, b), 0)
)
console.log(lens)

const results = Object.values(rows).map(({ words }) => {
return words
.map(({ text }, i) => {
return text + '.'.repeat((lens[i] + 2 - textLen(text)) / 2)
})
.join('')
})

return results.join('\n')
}

function Ruru() {
const [text, setText] = useLocalStorage<string>(
'column-text',
'あい\nうえお\nかき\nくけこ\nさし\nすせそ'
)
const [col, setCol] = useState<number>(2)

const onChange = (v) => setText(v.currentTarget.value)
if (text === undefined) return null
const cn = text.split('').length
const result = columnText(text, col)

return (
<Layout title="2列テキストツール">
<Container maxWidth="md">
<Style>
<Typography variant="h4">2列テキストツール</Typography>
<Slider
style={{ width: '300px' }}
defaultValue={col}
aria-labelledby="discrete-slider"
valueLabelDisplay="auto"
marks={range(2, 5 + 1).map((v) => ({ value: v, label: `${v}列` }))}
onChange={(_e, v) => {
if (typeof v === 'number') setCol(v)
}}
min={2}
max={5}
/>
<Grid container spacing={{ xs: 1, md: 2 }}>
<Grid item xs={10} sm={6} md={6}>
<TextField
label="リスト"
multiline
defaultValue={text}
variant="outlined"
onChange={onChange}
/>
</Grid>
<Grid item xs={10} sm={6} md={6}>
<div className="result">
<code>
<pre>{result}</pre>
</code>
</div>
</Grid>
</Grid>
</Style>
</Container>
</Layout>
)
}

const Style = styled.div`
span {
/* border: solid 1px;
padding: 4px;
margin: 4px; */
}
.result {
font-family: 'MS Pゴシック', 'MS PGothic', sans-serif;
flex-wrap: wrap;
gap: 1rem;
font-size: 0.6rem;
> div {
border: solid 1px gray;
padding: 0.5rem;
}
pre {
background: #ddd;
}
}
`

export default Ruru
81 changes: 81 additions & 0 deletions src/pages/tool/fixurl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// eslint-disable-next-line
import { Box, Card, Container, Typography } from '@mui/material'
import { range, uniq } from 'lodash'
import Head from 'next/head'
import { useRouter } from 'next/router'

const deleteChars = '●△○◎◯■□◆'
const ignoreRe = new RegExp(`[${deleteChars}]`, 'g')
const urlRe =
/(https?:\/\/)?[-_a-zA-Z0-9]+([.][-_a-zA-Z0-9]+){1,}([\/][-_a-zA-Z0-9;\/?:\@&=+\$,%#]*)?/g
function parseUrl(s: string | string[] | undefined, shift = 0) {
if (typeof s !== 'string') return null

const lines = s.replace(ignoreRe, '').split('\n')
range(shift).forEach(() => lines.shift())

const texts = range(lines.length - 1).map((i) => lines[i] + lines[i + 1])
console.log(texts)

return uniq(
[...texts, ...lines]
.map((text) => {
const m = text.matchAll(urlRe)
return [...m].map((v) => v[0])
})
.flat()
.map((v) => (v.startsWith('http') ? v : [`https://${v}`, `http://${v}`]))
.flat()
)
}

function FixurlApp() {
const { query } = useRouter()
console.log(query)
const urls = parseUrl(query.text)

return (
<Container>
<Typography variant="h5">URL修正</Typography>
<Typography>共有ボタンから使ってください{`(?q=text)`}</Typography>
<Typography>詳細: 改行と{deleteChars}を消す</Typography>

<Box m={1} p={1} component={Card}>
<Typography>元テキスト</Typography>
{query.text}
</Box>
<Box m={1} p={1} component={Card}>
<Typography>URL</Typography>
{!urls && 'なし'}
{urls?.map((url, i) => (
<Typography key={i}>
<a href={url}>{url}</a>
</Typography>
))}
</Box>
</Container>
)
}

const title = 'fixurl'

function Fixurl() {
return (
<div>
<Head>
<title>{title}</title>
<link
rel="shortcut icon"
href="/fixurl-res/icon.png"
key="shortcutIcon"
/>
<link rel="manifest" href="/fixurl-res/manifest.json" />
<meta name="theme-color" content="#000" key="themeColor" />
<meta property="og:title" content={title} />
</Head>
<FixurlApp />
</div>
)
}

export default Fixurl
Loading