mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 04:30:31 +09:00
feat: add linux card
This commit is contained in:
parent
cd5ed81052
commit
ee6ceead02
21
api/services/debian.js
Normal file
21
api/services/debian.js
Normal file
@ -0,0 +1,21 @@
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://packages.debian.org/buster/${encodeURIComponent(name)}`,
|
||||
'GET'
|
||||
)
|
||||
const body = await response.text()
|
||||
const availability = body.includes('No such package')
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
}
|
||||
}
|
22
api/services/launchpad.js
Normal file
22
api/services/launchpad.js
Normal file
@ -0,0 +1,22 @@
|
||||
const { send, sendError, fetch } = require('../util/http')
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const name = req.query.name
|
||||
|
||||
if (!name) {
|
||||
return sendError(res, new Error('no query given'))
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://api.launchpad.net/devel/ubuntu/+source/${encodeURIComponent(
|
||||
name
|
||||
)}`,
|
||||
'GET'
|
||||
)
|
||||
const availability = response.status !== 200
|
||||
send(res, availability)
|
||||
} catch (err) {
|
||||
sendError(res, err)
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"title": "その名前、もう使われてる?",
|
||||
"title": "その名前、もう取られてる?",
|
||||
"description": "namæ をつかって、思いついた「名前」が被っていないか調べよう。",
|
||||
"placeholder": "検索",
|
||||
"providers": {
|
||||
@ -13,7 +13,8 @@
|
||||
"jsorg": "js.org",
|
||||
"s3": "AWS S3",
|
||||
"twitter": "Twitter",
|
||||
"slack": "Slack"
|
||||
"slack": "Slack",
|
||||
"linux": "Linux"
|
||||
},
|
||||
"try": "これはどう?"
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import PypiCard from './components/cards/PypiCard'
|
||||
import S3Card from './components/cards/S3Card'
|
||||
import CratesioCard from './components/cards/CratesioCard'
|
||||
import RubyGemsCard from './components/cards/RubyGemsCard'
|
||||
import LinuxCard from './components/cards/LinuxCard'
|
||||
|
||||
import { EventReporter } from './components/Analytics'
|
||||
import Welcome from './components/Welcome'
|
||||
@ -100,6 +101,7 @@ export default function App() {
|
||||
<TwitterCard name={query} />
|
||||
<SlackCard name={query} />
|
||||
<S3Card name={query} />
|
||||
<LinuxCard name={query} />
|
||||
</Cards>
|
||||
<EventReporter query={query} />
|
||||
</SearchResult>
|
||||
|
34
web/src/components/cards/LinuxCard.js
Normal file
34
web/src/components/cards/LinuxCard.js
Normal file
@ -0,0 +1,34 @@
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { DiUbuntu } from 'react-icons/di'
|
||||
import { DiDebian } from 'react-icons/di'
|
||||
import { Card } from '../Cards'
|
||||
import { DedicatedAvailability } from '../Cards'
|
||||
|
||||
export default function LinuxCard({ name }) {
|
||||
const { t } = useTranslation()
|
||||
const lowerCase = name.toLowerCase()
|
||||
|
||||
return (
|
||||
<Card title={t('providers.linux')} nameList={[lowerCase]}>
|
||||
{(name) => (
|
||||
<>
|
||||
<DedicatedAvailability
|
||||
name={name}
|
||||
service="launchpad"
|
||||
link={`https://launchpad.net/ubuntu/+source/${name}`}
|
||||
prefix="launchpad:"
|
||||
icon={<DiUbuntu />}
|
||||
/>
|
||||
<DedicatedAvailability
|
||||
name={name}
|
||||
service="debian"
|
||||
link={`https://packages.debian.org/buster/${name}`}
|
||||
prefix="debian:"
|
||||
icon={<DiDebian />}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Card>
|
||||
)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user