[tools/docs:tweak] use duckduckgo favicon service

This commit is contained in:
Maddison Hellstrom 2020-07-02 06:16:59 -07:00
parent 38f152aac9
commit db518e266f
2 changed files with 39 additions and 51 deletions

View File

@ -43,7 +43,6 @@ completions.al = {
completions.au = {
alias: "au",
name: "AUR",
favicon: "https://aur.archlinux.org/images/favicon.ico",
search: "https://aur.archlinux.org/packages/?O=0&SeB=nd&outdated=&SB=v&SO=d&PP=100&do_Search=Go&K=",
compl: "https://aur.archlinux.org/rpc?type=suggest&arg=",
}
@ -127,7 +126,6 @@ completions.at.callback = (response) => {
completions.cs = {
alias: "cs",
name: "chromestore",
favicon: "https://www.google.com/images/icons/product/chrome_web_store-32.png",
search: "https://chrome.google.com/webstore/search/",
compl: googleCxURL("cs"),
callback: googleCxCallback,
@ -293,7 +291,6 @@ completions.do.callback = (response) => Object.entries(JSON.parse(response.text)
completions.vw = {
alias: "vw",
name: "vimwiki",
favicon: "https://vignette.wikia.nocookie.net/vim/images/6/64/Favicon.ico",
search: "https://vim.fandom.com/wiki/Special:Search?query=",
compl: "https://vim.fandom.com/api.php?action=opensearch&format=json&formatversion=2&namespace=0&limit=10&suggest=true&search=",
}
@ -892,7 +889,6 @@ completions.gd.callback = (response) => JSON.parse(response.text).results.map((s
completions.gw = {
alias: "gw",
name: "gowalker",
favicon: "https://gowalker.org/img/favicon.png",
search: "https://gowalker.org/search?auto_redirect=true&q=",
compl: "https://gowalker.org/search/json?q=",
}
@ -912,7 +908,6 @@ completions.gw.callback = (response) => JSON.parse(response.text).results.map((s
completions.gs = {
alias: "gs",
name: "go-search",
favicon: "https://go-search.org/images/logo-16.png",
search: "http://go-search.org/search?q=",
compl: "http://go-search.org/api?action=search&q=",
}
@ -926,7 +921,6 @@ completions.gs.callback = (response) => JSON.parse(response.text).hits
completions.ha = {
alias: "ha",
name: "hackage",
favicon: "https://hackage.haskell.org/static/favicon.png",
search: "https://hackage.haskell.org/packages/search?terms=",
compl: "https://hackage.haskell.org/packages/search.json?terms=",
}
@ -938,7 +932,6 @@ completions.ha.callback = (response) => JSON.parse(response.text)
completions.ho = {
alias: "ho",
name: "hoogle",
favicon: "https://www.haskell.org/img/favicon.ico",
search: `https://www.haskell.org/hoogle/?hoogle=${
encodeURIComponent("+platform +xmonad +xmonad-contrib ")}`, // This tells Hoogle to include these modules in the search - encodeURIComponent is only used for better readability
compl: `https://www.haskell.org/hoogle/?mode=json&hoogle=${
@ -952,7 +945,6 @@ completions.ho.callback = (response) => JSON.parse(response.text).results
completions.hw = {
alias: "hw",
name: "haskellwiki",
favicon: "https://www.haskell.org/img/favicon.ico",
search: "https://wiki.haskell.org/index.php?go=go&search=",
compl: "https://wiki.haskell.org/api.php?action=opensearch&format=json&formatversion=2&namespace=0&limit=10&suggest=true&search=",
}
@ -963,7 +955,6 @@ completions.hw.callback = (response) => JSON.parse(response.text)[1]
completions.hy = {
alias: "hy",
name: "hayoo",
favicon: "https://www.haskell.org/img/favicon.ico",
search: "http://hayoo.fh-wedel.de/?query=",
compl: "http://hayoo.fh-wedel.de/json?query=",
}
@ -1027,7 +1018,6 @@ completions.md.callback = (response) => {
completions.np = {
alias: "np",
name: "npm",
favicon: "https://static.npmjs.com/da3ab40fb0861d15c83854c29f5f2962.png",
search: "https://www.npmjs.com/search?q=",
compl: "https://api.npms.io/v2/search/suggestions?size=20&q=",
}

View File

@ -235,7 +235,6 @@ task("docs", parallel(async () => {
const getFavicon = async ({ domain, favicon }, timeout = 5000) => {
const url = favicon
let data
let ext = path.extname(new URL(favicon).pathname)
try {
const res = await fetch(url, { timeout })
if (!res.ok) {
@ -244,7 +243,6 @@ const getFavicon = async ({ domain, favicon }, timeout = 5000) => {
data = await res.buffer()
} catch (e) {
process.stdout.write(`no favicon found for ${url}: ${e}\n`)
ext = ".ico"
// transparent pixel
data = Buffer.from(
"AAABAAEAAQEAAAEAIAAwAAAAFgAAACgAAAABAAAAAgAAAAEAIAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA==",
@ -253,7 +251,7 @@ const getFavicon = async ({ domain, favicon }, timeout = 5000) => {
}
return {
domain,
name: `${domain}${ext}`,
name: `${domain}.ico`,
source: data,
}
}
@ -266,7 +264,7 @@ task("favicons", series("clean-favicons", async () => {
Object.entries(compl)
.map(([, v]) => ({
domain: new URL(v.domain ? `https://${v.domain}` : v.search).hostname,
favicon: v.favicon ? v.favicon : `${new URL(v.domain ? `https://${v.domain}` : v.search).origin}/favicon.ico`,
favicon: `https://icons.duckduckgo.com/ip3/${new URL(v.domain ? `https://${v.domain}` : v.search).hostname}.ico`,
})),
// site-specific keybindings
@ -274,7 +272,7 @@ task("favicons", series("clean-favicons", async () => {
.filter((k) => k !== "global")
.map((k) => ({
domain: k,
favicon: `${new URL(`https://${k}`).origin}/favicon.ico`,
favicon: `https://icons.duckduckgo.com/ip3/${new URL(`https://${k}`).hostname}.ico`,
})),
).filter((e, i, arr) => i === arr.indexOf(e)) // Keep only first occurrence of each element