Skip to content

Commit f47f835

Browse files
committed
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.
1 parent 7861ae1 commit f47f835

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

app/Search.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,20 @@ public static function providerDetails($provider)
3333
return false;
3434
}
3535

36-
return (object) $providers[$provider] ?? false;
36+
$details = (object) $providers[$provider] ?? false;
37+
38+
// For SearXNG, use user-configured URL
39+
if ($provider === 'searx') {
40+
$searxUrl = Setting::fetch('searx_url');
41+
if (!empty($searxUrl)) {
42+
// Ensure URL doesn't have trailing slash
43+
$searxUrl = rtrim($searxUrl, '/');
44+
$details->url = $searxUrl . '/search';
45+
$details->autocomplete = $searxUrl . '/autocompleter?format=x-suggestions&q={query}';
46+
}
47+
}
48+
49+
return $details;
3750
}
3851

3952
/**

database/seeders/SettingsSeeder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function run(): void
145145
'qwant' => 'app.options.qwant',
146146
'bing' => 'app.options.bing',
147147
'startpage' => 'app.options.startpage',
148+
'searx' => 'app.options.searx',
148149
]);
149150

150151
if (! $setting = Setting::find(4)) {
@@ -349,5 +350,19 @@ public function run(): void
349350
$setting->label = 'app.settings.treat_tags_as';
350351
$setting->save();
351352
}
353+
354+
if (! $setting = Setting::find(15)) {
355+
$setting = new Setting;
356+
$setting->id = 15;
357+
$setting->group_id = 3;
358+
$setting->key = 'searx_url';
359+
$setting->type = 'text';
360+
$setting->label = 'app.settings.searx_url';
361+
$setting->value = '';
362+
$setting->save();
363+
} else {
364+
$setting->label = 'app.settings.searx_url';
365+
$setting->save();
366+
}
352367
}
353368
}

lang/en/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
'settings.window_target.new' => 'Open in a new tab',
1818
'settings.homepage_search' => 'Homepage Search',
1919
'settings.search_provider' => 'Default Search Provider',
20+
'settings.searx_url' => 'SearXNG Instance URL',
2021
'settings.language' => 'Language',
2122
'settings.reset' => 'Reset back to default',
2223
'settings.remove' => 'Remove',
@@ -38,6 +39,7 @@
3839
'options.bing' => 'Bing',
3940
'options.qwant' => 'Qwant',
4041
'options.startpage' => 'StartPage',
42+
'options.searx' => 'SearXNG',
4143
'options.yes' => 'Yes',
4244
'options.no' => 'No',
4345
'options.nzbhydra' => 'NZBHydra',

storage/app/searchproviders.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,12 @@ startpage:
4545
method: get
4646
target: _blank
4747
query: query
48+
49+
searx:
50+
id: searx
51+
url: https://searx.example.com/search
52+
name: SearXNG
53+
method: get
54+
target: _blank
55+
query: q
56+
autocomplete: https://searx.example.com/autocompleter?format=x-suggestions&q={query}

0 commit comments

Comments
 (0)