Skip to content

Commit 98e2c67

Browse files
committed
Update
1 parent 3e6865e commit 98e2c67

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

_do.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TARGET_CPU = {
3232
MIRROR_HOST => "broadwell",
3333
}
3434

35-
ALPINE_VERSION = "3.22.1"
35+
ALPINE_VERSION = "3.22.2"
3636
AQUATIC_VERSION = "0.9.0"
3737
BROWSER_DETECTOR_VERSION = "4.1.0"
3838
HLS_VERSION = "1.5.15"

searxng.html

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,23 @@
9191
};
9292

9393
const detectLanguage = (query, params) => {
94-
const en = 'en';
9594
const allowedLanguages = params.get('languages');
96-
const only = allowedLanguages ? allowedLanguages.split(',') : LANGUAGES;
97-
console.log('allowed languages', only);
98-
if (only.length <= 1) return en;
95+
const languagesRaw = allowedLanguages ? allowedLanguages.split(',') : LANGUAGES;
9996

100-
const all = detectAll(query, { only });
101-
console.log('detected languages', all);
97+
const all = 'all';
98+
const only = languagesRaw.filter(i => i !== all);
99+
console.log('allowed languages', languagesRaw);
100+
if (only.length === 0) return all;
101+
if (languagesRaw.length === 1) return only[0];
102102

103-
const detected = all
103+
const detected = detectAll(query, { only });
104+
console.log('detected languages', detected);
105+
106+
const ranked = detected
104107
.filter(i => i.accuracy > 0.01)
105108
.sort((a, b) => b.accuracy - a.accuracy);
106-
if (detected.length === 0) return en;
107109

108-
return detected[0].lang;
110+
return ranked[0]?.lang || (languagesRaw.length > only.length ? all : only[0]);
109111
};
110112

111113
const shuffle = xs => {
@@ -133,6 +135,7 @@
133135
.forEach(([k, v]) => newParams.set(k, v));
134136

135137
const query = queryFromForm || params.get('q') || '';
138+
console.log(`query "${query}"`);
136139
newParams.set('language', detectLanguage(query, params));
137140
newParams.set('q', query);
138141
newParams.set('safesearch', params.get('safesearch') || '0');
@@ -218,13 +221,13 @@
218221
<hr>
219222
<p>Examples for <strong>browser search engine settings</strong> (<code>about:preferences#search</code> or <code>chrome://settings/search</code>):</p>
220223
<ul>
221-
<li><code>${pageUrl}#q=%s&languages=en,fr,ru</code></li>
222-
<li><code>${pageUrl}#q=%s&fast=1&image_proxy=False&categories=images&languages=en,fr,ru&get=1</code></li>
224+
<li><code>${pageUrl}#q=%s&languages=all,en,fr,ru</code></li>
225+
<li><code>${pageUrl}#q=%s&fast=1&image_proxy=False&categories=images,videos&languages=all,en,fr,ru&get=1</code></li>
223226
</ul>
224227
<p>Supports the following parameters (provided as an anchor for privacy):</p>
225228
<ul>
226229
<li>normal SearXNG GET/POST <a rel="noopener" target="_blank" href="https://docs.searxng.org/dev/search_api.html">parameters</a> (<code>safesearch=0</code> and <code>image_proxy=True</code> are set by default)</li>
227-
<li><code>languages</code> limit query-based language detection; comma-separated, default is <code>${LANGUAGES.join(',')}</code></li>
230+
<li><code>languages</code> limit query-based language detection, fallbacks to the first language in the list when not detected (use <code>all</code> to fallback to SearXNG-based language detection instead); comma-separated, default is <code>${LANGUAGES.join(',')}</code></li>
228231
<li><code>get</code> pass parameters to the instance using GET method; default is <code>0</code></li>
229232
<li><code>timeout</code> in milliseconds until attempting the next instance; default is <code>${TIMEOUT}</code></li>
230233
<li><code>attempts</code> how many instances to try; default is <code>${ATTEMPTS}</code></li>
@@ -234,7 +237,7 @@
234237
<p>For local use (doesn't require any server): <code>wget ${pageUrl} -O searxng.html</code></p>
235238
<p>Additionally can be combined with the Violentmonkey userscripts:</p>
236239
<ul>
237-
<li><a rel="noopener" target="_blank" href="https://userscripts.codonaft.com/redirect-searxng-on-failure.js">redirect-searxng-on-failure.js</a> — turn search failures into redirects</li>
240+
<li><a rel="noopener" target="_blank" href="https://userscripts.codonaft.com/redirect-searxng-on-failure.js">redirect-searxng-on-failure.js</a> — turn search failures into the redirects</li>
238241
<li><a rel="noopener" target="_blank" href="https://userscripts.codonaft.com/force-searxng-parameters.js">force-searxng-parameters.js</a> — always enable image proxy and disable SafeSearch</li>
239242
</ul>
240243
<hr>

0 commit comments

Comments
 (0)