From f47f8350e01e69f305604d88b239d3d17aaa103c Mon Sep 17 00:00:00 2001 From: Jay Collett <486430+jaycollett@users.noreply.github.com> Date: Thu, 29 Jan 2026 11:54:20 -0500 Subject: [PATCH] Add SearXNG as configurable search provider - Add SearXNG entry to searchproviders.yaml - Add searx_url setting for user-configurable instance URL - Modify Search::providerDetails() to inject user's SearXNG URL - Add English translations for new setting and provider SearXNG is a self-hosted metasearch engine, so unlike other providers the URL cannot be hardcoded. This implementation allows users to configure their instance URL in settings, which is then dynamically injected when performing searches. --- app/Search.php | 15 ++++++++++++++- database/seeders/SettingsSeeder.php | 15 +++++++++++++++ lang/en/app.php | 2 ++ storage/app/searchproviders.yaml | 9 +++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/Search.php b/app/Search.php index 5b098f0e5..7e226a8a2 100644 --- a/app/Search.php +++ b/app/Search.php @@ -33,7 +33,20 @@ public static function providerDetails($provider) return false; } - return (object) $providers[$provider] ?? false; + $details = (object) $providers[$provider] ?? false; + + // For SearXNG, use user-configured URL + if ($provider === 'searx') { + $searxUrl = Setting::fetch('searx_url'); + if (!empty($searxUrl)) { + // Ensure URL doesn't have trailing slash + $searxUrl = rtrim($searxUrl, '/'); + $details->url = $searxUrl . '/search'; + $details->autocomplete = $searxUrl . '/autocompleter?format=x-suggestions&q={query}'; + } + } + + return $details; } /** diff --git a/database/seeders/SettingsSeeder.php b/database/seeders/SettingsSeeder.php index 8618c5263..1d95f6e9d 100755 --- a/database/seeders/SettingsSeeder.php +++ b/database/seeders/SettingsSeeder.php @@ -145,6 +145,7 @@ public function run(): void 'qwant' => 'app.options.qwant', 'bing' => 'app.options.bing', 'startpage' => 'app.options.startpage', + 'searx' => 'app.options.searx', ]); if (! $setting = Setting::find(4)) { @@ -349,5 +350,19 @@ public function run(): void $setting->label = 'app.settings.treat_tags_as'; $setting->save(); } + + if (! $setting = Setting::find(15)) { + $setting = new Setting; + $setting->id = 15; + $setting->group_id = 3; + $setting->key = 'searx_url'; + $setting->type = 'text'; + $setting->label = 'app.settings.searx_url'; + $setting->value = ''; + $setting->save(); + } else { + $setting->label = 'app.settings.searx_url'; + $setting->save(); + } } } diff --git a/lang/en/app.php b/lang/en/app.php index 3c31f53d6..c90fc9c76 100644 --- a/lang/en/app.php +++ b/lang/en/app.php @@ -17,6 +17,7 @@ 'settings.window_target.new' => 'Open in a new tab', 'settings.homepage_search' => 'Homepage Search', 'settings.search_provider' => 'Default Search Provider', + 'settings.searx_url' => 'SearXNG Instance URL', 'settings.language' => 'Language', 'settings.reset' => 'Reset back to default', 'settings.remove' => 'Remove', @@ -38,6 +39,7 @@ 'options.bing' => 'Bing', 'options.qwant' => 'Qwant', 'options.startpage' => 'StartPage', + 'options.searx' => 'SearXNG', 'options.yes' => 'Yes', 'options.no' => 'No', 'options.nzbhydra' => 'NZBHydra', diff --git a/storage/app/searchproviders.yaml b/storage/app/searchproviders.yaml index 540367364..a882ebd9d 100644 --- a/storage/app/searchproviders.yaml +++ b/storage/app/searchproviders.yaml @@ -45,3 +45,12 @@ startpage: method: get target: _blank query: query + +searx: + id: searx + url: https://searx.example.com/search + name: SearXNG + method: get + target: _blank + query: q + autocomplete: https://searx.example.com/autocompleter?format=x-suggestions&q={query}