[tools/docs:tweak] use duckduckgo favicon service
This commit is contained in:
parent
38f152aac9
commit
db518e266f
|
@ -41,11 +41,10 @@ completions.al = {
|
||||||
|
|
||||||
// Arch Linux AUR
|
// Arch Linux AUR
|
||||||
completions.au = {
|
completions.au = {
|
||||||
alias: "au",
|
alias: "au",
|
||||||
name: "AUR",
|
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=",
|
||||||
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=",
|
||||||
compl: "https://aur.archlinux.org/rpc?type=suggest&arg=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.au.callback = (response) => {
|
completions.au.callback = (response) => {
|
||||||
|
@ -127,7 +126,6 @@ completions.at.callback = (response) => {
|
||||||
completions.cs = {
|
completions.cs = {
|
||||||
alias: "cs",
|
alias: "cs",
|
||||||
name: "chromestore",
|
name: "chromestore",
|
||||||
favicon: "https://www.google.com/images/icons/product/chrome_web_store-32.png",
|
|
||||||
search: "https://chrome.google.com/webstore/search/",
|
search: "https://chrome.google.com/webstore/search/",
|
||||||
compl: googleCxURL("cs"),
|
compl: googleCxURL("cs"),
|
||||||
callback: googleCxCallback,
|
callback: googleCxCallback,
|
||||||
|
@ -291,11 +289,10 @@ completions.do.callback = (response) => Object.entries(JSON.parse(response.text)
|
||||||
|
|
||||||
// Vim Wiki
|
// Vim Wiki
|
||||||
completions.vw = {
|
completions.vw = {
|
||||||
alias: "vw",
|
alias: "vw",
|
||||||
name: "vimwiki",
|
name: "vimwiki",
|
||||||
favicon: "https://vignette.wikia.nocookie.net/vim/images/6/64/Favicon.ico",
|
search: "https://vim.fandom.com/wiki/Special:Search?query=",
|
||||||
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=",
|
||||||
compl: "https://vim.fandom.com/api.php?action=opensearch&format=json&formatversion=2&namespace=0&limit=10&suggest=true&search=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.vw.callback = (response) => JSON.parse(response.text)[1]
|
completions.vw.callback = (response) => JSON.parse(response.text)[1]
|
||||||
|
@ -890,11 +887,10 @@ completions.gd.callback = (response) => JSON.parse(response.text).results.map((s
|
||||||
|
|
||||||
// Gowalker
|
// Gowalker
|
||||||
completions.gw = {
|
completions.gw = {
|
||||||
alias: "gw",
|
alias: "gw",
|
||||||
name: "gowalker",
|
name: "gowalker",
|
||||||
favicon: "https://gowalker.org/img/favicon.png",
|
search: "https://gowalker.org/search?auto_redirect=true&q=",
|
||||||
search: "https://gowalker.org/search?auto_redirect=true&q=",
|
compl: "https://gowalker.org/search/json?q=",
|
||||||
compl: "https://gowalker.org/search/json?q=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.gw.callback = (response) => JSON.parse(response.text).results.map((s) => {
|
completions.gw.callback = (response) => JSON.parse(response.text).results.map((s) => {
|
||||||
|
@ -910,11 +906,10 @@ completions.gw.callback = (response) => JSON.parse(response.text).results.map((s
|
||||||
|
|
||||||
// Go-Search
|
// Go-Search
|
||||||
completions.gs = {
|
completions.gs = {
|
||||||
alias: "gs",
|
alias: "gs",
|
||||||
name: "go-search",
|
name: "go-search",
|
||||||
favicon: "https://go-search.org/images/logo-16.png",
|
search: "http://go-search.org/search?q=",
|
||||||
search: "http://go-search.org/search?q=",
|
compl: "http://go-search.org/api?action=search&q=",
|
||||||
compl: "http://go-search.org/api?action=search&q=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.gs.callback = (response) => JSON.parse(response.text).hits
|
completions.gs.callback = (response) => JSON.parse(response.text).hits
|
||||||
|
@ -924,11 +919,10 @@ completions.gs.callback = (response) => JSON.parse(response.text).hits
|
||||||
|
|
||||||
// Hackage
|
// Hackage
|
||||||
completions.ha = {
|
completions.ha = {
|
||||||
alias: "ha",
|
alias: "ha",
|
||||||
name: "hackage",
|
name: "hackage",
|
||||||
favicon: "https://hackage.haskell.org/static/favicon.png",
|
search: "https://hackage.haskell.org/packages/search?terms=",
|
||||||
search: "https://hackage.haskell.org/packages/search?terms=",
|
compl: "https://hackage.haskell.org/packages/search.json?terms=",
|
||||||
compl: "https://hackage.haskell.org/packages/search.json?terms=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.ha.callback = (response) => JSON.parse(response.text)
|
completions.ha.callback = (response) => JSON.parse(response.text)
|
||||||
|
@ -936,12 +930,11 @@ completions.ha.callback = (response) => JSON.parse(response.text)
|
||||||
|
|
||||||
// Hoogle
|
// Hoogle
|
||||||
completions.ho = {
|
completions.ho = {
|
||||||
alias: "ho",
|
alias: "ho",
|
||||||
name: "hoogle",
|
name: "hoogle",
|
||||||
favicon: "https://www.haskell.org/img/favicon.ico",
|
search: `https://www.haskell.org/hoogle/?hoogle=${
|
||||||
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
|
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=${
|
compl: `https://www.haskell.org/hoogle/?mode=json&hoogle=${
|
||||||
encodeURIComponent("+platform +xmonad +xmonad-contrib ")}`,
|
encodeURIComponent("+platform +xmonad +xmonad-contrib ")}`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,22 +943,20 @@ completions.ho.callback = (response) => JSON.parse(response.text).results
|
||||||
|
|
||||||
// Haskell Wiki
|
// Haskell Wiki
|
||||||
completions.hw = {
|
completions.hw = {
|
||||||
alias: "hw",
|
alias: "hw",
|
||||||
name: "haskellwiki",
|
name: "haskellwiki",
|
||||||
favicon: "https://www.haskell.org/img/favicon.ico",
|
search: "https://wiki.haskell.org/index.php?go=go&search=",
|
||||||
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=",
|
||||||
compl: "https://wiki.haskell.org/api.php?action=opensearch&format=json&formatversion=2&namespace=0&limit=10&suggest=true&search=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.hw.callback = (response) => JSON.parse(response.text)[1]
|
completions.hw.callback = (response) => JSON.parse(response.text)[1]
|
||||||
|
|
||||||
// Hayoo
|
// Hayoo
|
||||||
completions.hy = {
|
completions.hy = {
|
||||||
alias: "hy",
|
alias: "hy",
|
||||||
name: "hayoo",
|
name: "hayoo",
|
||||||
favicon: "https://www.haskell.org/img/favicon.ico",
|
search: "http://hayoo.fh-wedel.de/?query=",
|
||||||
search: "http://hayoo.fh-wedel.de/?query=",
|
compl: "http://hayoo.fh-wedel.de/json?query=",
|
||||||
compl: "http://hayoo.fh-wedel.de/json?query=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.hy.callback = (response) => JSON.parse(response.text).result
|
completions.hy.callback = (response) => JSON.parse(response.text).result
|
||||||
|
@ -1025,11 +1016,10 @@ completions.md.callback = (response) => {
|
||||||
|
|
||||||
// NPM registry search
|
// NPM registry search
|
||||||
completions.np = {
|
completions.np = {
|
||||||
alias: "np",
|
alias: "np",
|
||||||
name: "npm",
|
name: "npm",
|
||||||
favicon: "https://static.npmjs.com/da3ab40fb0861d15c83854c29f5f2962.png",
|
search: "https://www.npmjs.com/search?q=",
|
||||||
search: "https://www.npmjs.com/search?q=",
|
compl: "https://api.npms.io/v2/search/suggestions?size=20&q=",
|
||||||
compl: "https://api.npms.io/v2/search/suggestions?size=20&q=",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions.np.callback = (response) => JSON.parse(response.text)
|
completions.np.callback = (response) => JSON.parse(response.text)
|
||||||
|
|
|
@ -235,7 +235,6 @@ task("docs", parallel(async () => {
|
||||||
const getFavicon = async ({ domain, favicon }, timeout = 5000) => {
|
const getFavicon = async ({ domain, favicon }, timeout = 5000) => {
|
||||||
const url = favicon
|
const url = favicon
|
||||||
let data
|
let data
|
||||||
let ext = path.extname(new URL(favicon).pathname)
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url, { timeout })
|
const res = await fetch(url, { timeout })
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
@ -244,7 +243,6 @@ const getFavicon = async ({ domain, favicon }, timeout = 5000) => {
|
||||||
data = await res.buffer()
|
data = await res.buffer()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
process.stdout.write(`no favicon found for ${url}: ${e}\n`)
|
process.stdout.write(`no favicon found for ${url}: ${e}\n`)
|
||||||
ext = ".ico"
|
|
||||||
// transparent pixel
|
// transparent pixel
|
||||||
data = Buffer.from(
|
data = Buffer.from(
|
||||||
"AAABAAEAAQEAAAEAIAAwAAAAFgAAACgAAAABAAAAAgAAAAEAIAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA==",
|
"AAABAAEAAQEAAAEAIAAwAAAAFgAAACgAAAABAAAAAgAAAAEAIAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA==",
|
||||||
|
@ -253,7 +251,7 @@ const getFavicon = async ({ domain, favicon }, timeout = 5000) => {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
domain,
|
domain,
|
||||||
name: `${domain}${ext}`,
|
name: `${domain}.ico`,
|
||||||
source: data,
|
source: data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,7 +264,7 @@ task("favicons", series("clean-favicons", async () => {
|
||||||
Object.entries(compl)
|
Object.entries(compl)
|
||||||
.map(([, v]) => ({
|
.map(([, v]) => ({
|
||||||
domain: new URL(v.domain ? `https://${v.domain}` : v.search).hostname,
|
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
|
// site-specific keybindings
|
||||||
|
@ -274,7 +272,7 @@ task("favicons", series("clean-favicons", async () => {
|
||||||
.filter((k) => k !== "global")
|
.filter((k) => k !== "global")
|
||||||
.map((k) => ({
|
.map((k) => ({
|
||||||
domain: 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
|
).filter((e, i, arr) => i === arr.indexOf(e)) // Keep only first occurrence of each element
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue