[docs] link instance-specific pages via searx.space

Fixes #659.
This commit is contained in:
Martin Fischer 2022-01-31 18:07:48 +01:00
parent a13d8955bf
commit e629c9ccc4
3 changed files with 32 additions and 4 deletions

View file

@ -69,7 +69,7 @@ jinja_filters = {
def process_link(href):
if href.startswith('/'):
return '../go-to-instance.html'
return '../go-to-instance.html#' + href
else:
return href

21
docs/go-to-instance.html Normal file
View file

@ -0,0 +1,21 @@
<noscript>This requires JavaScript.</noscript>
<ul id=links></ul>
<script>
(async function() {
const links = document.getElementById('links');
let res = await fetch('https://searx.space/data/instances.json');
let instances = await res.json();
for (const [url, info] of Object.entries(instances.instances)) {
if (info.error)
continue;
if (url.startsWith('https://')) {
const li = document.createElement('li');
const a = document.createElement('a');
a.href = url + location.hash.substr(2);
a.textContent = url + location.hash.substr(2);
li.appendChild(a);
links.appendChild(li);
}
}
})();
</script>

View file

@ -1,7 +1,14 @@
:orphan:
=======================
We cannot link there :(
=======================
=================
Go to instance...
=================
The link you followed depends on the instance.
We don't know which instance you're using.
For your convenience the instances from
`searx.space <https://searx.space/>`_ are linked below:
.. raw:: html
:file: go-to-instance.html