Scaffolding from degoog-cli
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# gitea-searchengine
|
||||
|
||||
A custom search engine for degoog.
|
||||
|
||||
## Usage
|
||||
|
||||
<!-- explain how to use this extension -->
|
||||
|
||||
## Configuration
|
||||
|
||||
<!-- list any settings this extension requires -->
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Kenneth van Ewijk",
|
||||
"url": "https://gitea.furb.it/kennyboy55"
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
export const name = "gitea-searchengine"
|
||||
export const type = "web" // web | images | videos | news | custom
|
||||
export const bangShortcut = "gitea-searchengine"
|
||||
|
||||
// settingsSchema example:
|
||||
// export const settingsSchema = [
|
||||
// { key: "apiKey", label: "API Key", type: "password", required: true },
|
||||
// ]
|
||||
//
|
||||
// export const configure = (settings) => {
|
||||
// // called after settings save and on server restart
|
||||
// }
|
||||
|
||||
export const executeSearch = async (
|
||||
query: string,
|
||||
page = 1,
|
||||
timeFilter: string,
|
||||
context: {
|
||||
lang: string
|
||||
fetch: typeof fetch
|
||||
signProxyUrl: (url: string) => string
|
||||
buildAcceptLanguage: () => string
|
||||
dateFrom?: string
|
||||
dateTo?: string
|
||||
sentinel?: (
|
||||
response: { ok: boolean; status: number },
|
||||
engineName?: string
|
||||
) => void
|
||||
engineError?: (
|
||||
status: string,
|
||||
message: string,
|
||||
opts?: { httpStatus?: number; engine?: string }
|
||||
) => Error
|
||||
}
|
||||
) => {
|
||||
const results: Array<{
|
||||
title: string
|
||||
url: string
|
||||
snippet: string
|
||||
source: string
|
||||
thumbnail?: string
|
||||
}> = []
|
||||
|
||||
try {
|
||||
const doFetch = context?.fetch ?? fetch
|
||||
const response = await doFetch(`https://api.example.com/search?q=${encodeURIComponent(query)}`)
|
||||
context?.sentinel?.(response, name)
|
||||
const data = await response.json()
|
||||
// TODO: map data into results
|
||||
return results
|
||||
} catch (e: any) {
|
||||
if (e?.name === "SentinelBreach") throw e
|
||||
return []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "degoog-extensions",
|
||||
"description": "degoog-extensions extensions for degoog",
|
||||
"author": "Kenneth van Ewijk",
|
||||
"plugins": [],
|
||||
"themes": [],
|
||||
"engines": [
|
||||
{
|
||||
"path": "engines/gitea-searchengine",
|
||||
"name": "gitea-searchengine",
|
||||
"description": "",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
],
|
||||
"transports": [],
|
||||
"autocomplete": []
|
||||
}
|
||||
Reference in New Issue
Block a user