diff --git a/degoog-extensions.code-workspace b/degoog-extensions.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/degoog-extensions.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/engines/gitea-searchengine/README.md b/engines/gitea-searchengine/README.md new file mode 100644 index 0000000..ce47d97 --- /dev/null +++ b/engines/gitea-searchengine/README.md @@ -0,0 +1,11 @@ +# gitea-searchengine + +A custom search engine for degoog. + +## Usage + + + +## Configuration + + diff --git a/engines/gitea-searchengine/author.json b/engines/gitea-searchengine/author.json new file mode 100644 index 0000000..5cfd6c1 --- /dev/null +++ b/engines/gitea-searchengine/author.json @@ -0,0 +1,4 @@ +{ + "name": "Kenneth van Ewijk", + "url": "https://gitea.furb.it/kennyboy55" +} diff --git a/engines/gitea-searchengine/index.ts b/engines/gitea-searchengine/index.ts new file mode 100644 index 0000000..339feb5 --- /dev/null +++ b/engines/gitea-searchengine/index.ts @@ -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 [] + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3089e7b --- /dev/null +++ b/package.json @@ -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": [] +}