mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 04:30:31 +09:00
feat: spectrum
This commit is contained in:
parent
8012634bbc
commit
ec4bbf7dfa
23
api/services/spectrum.js
Normal file
23
api/services/spectrum.js
Normal file
@ -0,0 +1,23 @@
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const { query } = req.query
|
||||
|
||||
if (!query) {
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://spectrum.chat/${encodeURIComponent(query)}`,
|
||||
'GET'
|
||||
)
|
||||
const body = await response.text()
|
||||
const availability = body.includes(
|
||||
'You may be trying to view something that is deleted'
|
||||
)
|
||||
send(res, { availability })
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
}
|
||||
}
|
@ -17,7 +17,8 @@
|
||||
"jsorg": "js.org",
|
||||
"githubSearch": "Github Repository",
|
||||
"appStore": "App Store",
|
||||
"google": "Google Search"
|
||||
"google": "Google Search",
|
||||
"spectrum": "Spectrum"
|
||||
},
|
||||
"countryCode": "us",
|
||||
"try": "Suggested Name"
|
||||
|
@ -17,7 +17,8 @@
|
||||
"jsorg": "js.org",
|
||||
"githubSearch": "Github リポジトリ",
|
||||
"appStore": "App Store",
|
||||
"google": "Google 検索"
|
||||
"google": "Google 検索",
|
||||
"spectrum": "Spectrum"
|
||||
},
|
||||
"countryCode": "jp",
|
||||
"try": "全自動名前考え機"
|
||||
|
@ -12,6 +12,7 @@ import CratesioCard from './components/cards/CratesioCard'
|
||||
import HomebrewCard from './components/cards/HomebrewCard'
|
||||
import LinuxCard from './components/cards/LinuxCard'
|
||||
import TwitterCard from './components/cards/TwitterCard'
|
||||
import SpectrumCard from './components/cards/SpectrumCard'
|
||||
import SlackCard from './components/cards/SlackCard'
|
||||
import S3Card from './components/cards/S3Card'
|
||||
import JsOrgCard from './components/cards/JsOrgCard'
|
||||
@ -101,6 +102,7 @@ export default function App() {
|
||||
<HomebrewCard query={query} />
|
||||
<LinuxCard query={query} />
|
||||
<TwitterCard query={query} />
|
||||
<SpectrumCard query={query} />
|
||||
<SlackCard query={query} />
|
||||
<S3Card query={query} />
|
||||
<JsOrgCard query={query} />
|
||||
|
14
web/src/components/Icons.js
Normal file
14
web/src/components/Icons.js
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react'
|
||||
|
||||
export const SpectrumIcon = () => (
|
||||
<svg
|
||||
width="1em"
|
||||
height="1em"
|
||||
viewBox="0 0 32 32"
|
||||
fill="currentColor"
|
||||
stroke="currentColor"
|
||||
stroke-width="0"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6 14.5C6 15.3284 6.67157 16 7.5 16H9C12.866 16 16 19.134 16 23V24.5C16 25.3284 16.6716 26 17.5 26H24.5C25.3284 26 26 25.3284 26 24.5V23C26 13.6111 18.3889 6 9 6H7.5C6.67157 6 6 6.67157 6 7.5V14.5Z" />
|
||||
</svg>
|
||||
)
|
@ -17,6 +17,7 @@ import {
|
||||
} from 'react-icons/fa'
|
||||
import { IoIosBeer } from 'react-icons/io'
|
||||
import { DiRust } from 'react-icons/di'
|
||||
import { SpectrumIcon } from './Icons'
|
||||
|
||||
import { mobile } from '../util/css'
|
||||
|
||||
@ -57,6 +58,9 @@ export default function Welcome() {
|
||||
<ListItem>
|
||||
<FaTwitter /> {t('providers.twitter')}
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<SpectrumIcon /> {t('providers.spectrum')}
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<FaSlack /> {t('providers.slack')}
|
||||
</ListItem>
|
||||
|
29
web/src/components/cards/SpectrumCard.js
Normal file
29
web/src/components/cards/SpectrumCard.js
Normal file
@ -0,0 +1,29 @@
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Card, Repeater, DedicatedAvailability } from '../Cards'
|
||||
import { SpectrumIcon } from '../Icons'
|
||||
|
||||
export default function SpectrumCard({ query }) {
|
||||
const { t } = useTranslation()
|
||||
const names = [query]
|
||||
|
||||
return (
|
||||
<Card title={t('providers.spectrum')}>
|
||||
<Repeater items={names}>
|
||||
{(name) => (
|
||||
<>
|
||||
<DedicatedAvailability
|
||||
name={name}
|
||||
service="spectrum"
|
||||
message="Create Community"
|
||||
link="https://spectrum.chat/new/community"
|
||||
messageIfTaken="See community in Spectrum"
|
||||
linkIfTaken={`https://spectrum.chat/${name}`}
|
||||
icon={<SpectrumIcon />}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Repeater>
|
||||
</Card>
|
||||
)
|
||||
}
|
@ -12,7 +12,11 @@ i18n
|
||||
.init({
|
||||
backend: {
|
||||
backends: [LocalStorageBackend, XHR],
|
||||
backendOptions: [],
|
||||
backendOptions: [
|
||||
{
|
||||
versions: { en: '1.1', ja: '1.1' },
|
||||
},
|
||||
],
|
||||
},
|
||||
fallbackLng: 'en',
|
||||
debug: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user