Skip to content

Commit

Permalink
[update] master branch: 3e747d0 to fa4dfd4
Browse files Browse the repository at this point in the history
This branch is 4 commits ahead of upstream searxng/searxng:master (excluding this commit).

Additional commits in this branch:
  - 9a0375b
  - 69e7524
  - ff7270e
  - ea13fbe

Tested: 2024-10-31 @ 09:12:04 CET
Tests:
  - test.yamllint ✅
  - test.black    ✅
  - test.pyright  ✅
  - test.pylint   ✅
  - test.unit     ✅
  - test.robot    ✅
  - test.rst      ✅
Signed-off-by: Léon Tiekötter <leon@tiekoetter.com>
  • Loading branch information
tiekoetter committed Oct 31, 2024
2 parents fa4dfd4 + 9a0375b commit 5f50d2d
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [tiekoettercom]
custom: https://www.tiekoetter.com/donate/
9 changes: 9 additions & 0 deletions searx/engines/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"""

import re
import urllib.parse
import babel

Expand Down Expand Up @@ -186,9 +187,17 @@ def response(resp):

_network.raise_for_httperror(resp)

from searx.preferences import hostname_replace_choice # pylint: disable=import-outside-toplevel

api_result = resp.json()
title = utils.html_to_text(api_result.get('titles', {}).get('display') or api_result.get('title'))
wikipedia_link = api_result['content_urls']['desktop']['page']
if hostname_replace_choice == "on":
wikipedia_link = (
re.sub(r'(.*\.)wikipedia\.org', 'https://wikiless.tiekoetter.com', wikipedia_link)
+ "?lang="
+ api_result['content_urls']['desktop']['page'][8:10]
)

if "list" in display_type or api_result.get('type') != 'standard':
# show item in the result list if 'list' is in the display options or it
Expand Down
5 changes: 5 additions & 0 deletions searx/infopage/de/donate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Spenden

## An Tiekoetter.com spenden

Tiekoetter.com unterstützen: [https://www.tiekoetter.com/spenden](https://www.tiekoetter.com/spenden)
5 changes: 5 additions & 0 deletions searx/infopage/en/donate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Donate

## Donate to Tiekoetter.com

Support Tiekoetter.com: [https://www.tiekoetter.com/en/donate](https://www.tiekoetter.com/en/donate/)
7 changes: 0 additions & 7 deletions searx/network/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,6 @@ def get_network(name=None):
def check_network_configuration():
async def check():
exception_count = 0
for network in NETWORKS.values():
if network.using_tor_proxy:
try:
await network.get_client()
except Exception: # pylint: disable=broad-except
network._logger.exception('Error') # pylint: disable=protected-access
exception_count += 1
return exception_count

future = asyncio.run_coroutine_threadsafe(check(), get_loop())
Expand Down
9 changes: 9 additions & 0 deletions searx/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,17 @@ def parse_encoded_data(self, input_data: str):
dict_data[x] = y[0]
self.parse_dict(dict_data)

hostname_replace_choice = "off"

def parse_dict(self, input_data: Dict[str, str]):
"""parse preferences from request (``flask.request.form``)"""

global hostname_replace_choice # pylint: disable=global-variable-undefined
if 'hostname_replace' in ','.join(self.plugins.enabled):
hostname_replace_choice = "on"
else:
hostname_replace_choice = "off"

for user_setting_name, user_setting in input_data.items():
if user_setting_name in self.key_value_settings:
if self.key_value_settings[user_setting_name].locked:
Expand Down
5 changes: 5 additions & 0 deletions searx/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ general:
contact_url: false
# record stats
enable_metrics: true
legal_name: ""
legal_url:

brand:
new_issue_url: https://github.com/searxng/searxng/issues/new
Expand All @@ -25,6 +27,9 @@ brand:
# links:
# Uptime: https://uptime.searxng.org/history/darmarit-org
# About: "https://searxng.org"
website_name: ""
website_url:
donate_url:

search:
# Filter results. 0: None, 1: Moderate, 2: Strict
Expand Down
7 changes: 5 additions & 2 deletions searx/templates/simple/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="description" content="SearXNG — a privacy-respecting, open metasearch engine">
<meta name="keywords" content="SearXNG, search, search engine, metasearch, meta search">
<meta name="generator" content="searxng/{{ searx_version }}">
<meta name="generator" content="searxng/{{ searx_version_custom }}">
<meta name="referrer" content="no-referrer">
<meta name="robots" content="noarchive">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand Down Expand Up @@ -65,13 +65,16 @@
</main>
<footer>
<p>
{{ _('Powered by') }} <a href="{{ url_for('info', pagename='about') }}">searxng</a> - {{ searx_version }} — {{ _('a privacy-respecting, open metasearch engine') }}<br>
{{ _('Powered by') }} <a href="{{ url_for('info', pagename='about') }}">searxng</a> - {{ searx_version_custom }} — {{ _('a privacy-respecting, open metasearch engine') }}<br>
<a href="{{ searx_git_url }}">{{ _('Source code') }}</a>
| <a href="{{ get_setting('brand.issue_url') }}">{{ _('Issue tracker') }}</a>
{% if enable_metrics %}| <a href="{{ url_for('stats') }}">{{ _('Engine stats') }}</a>{% endif %}
{% if get_setting('brand.public_instances') %}
| <a href="{{ get_setting('brand.public_instances') }}">{{ _('Public instances') }}</a>
{% endif %}
{% if get_setting('brand.website_url') and get_setting('brand.website_name') %} | <a href="{{ get_setting('brand.website_url') }}">{{ get_setting('brand.website_name') }}</a>{% endif %}
{% if get_setting('brand.donate_url') %} | <a href="{{ get_setting('brand.donate_url') }}">{{ _('Donate') }}</a>{% endif %}
{% if get_setting('general.legal_url') and get_setting('general.legal_name') %} | <a href="{{ get_setting('general.legal_url') }}">{{ get_setting('general.legal_name') }}</a>{% endif %}
{% if get_setting('general.privacypolicy_url') %}
| <a href="{{ get_setting('general.privacypolicy_url') }}">{{ _('Privacy policy') }}</a>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/simple/new_issue.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% if searx_git_url and searx_git_url != 'unknow' %}
Repository: {{ searx_git_url }}
Branch: {{ searx_git_branch }}
Version: {{ searx_version }}
Version: {{ searx_version_custom }}
<!-- Check if these values are correct -->

{% else %}
Expand Down
30 changes: 30 additions & 0 deletions searx/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,29 @@ def get_git_version():
return git_version, tag_version, docker_tag


def get_git_version_upstream():
try:
git_commit_date_hash = subprocess_run(r"git show -s --date='format:%-Y.%-m.%-d' --format='%cd+%h' origin/pull")
git_version = git_commit_date_hash
except subprocess.CalledProcessError:
git_commit_date_hash = subprocess_run(r"git show -s --date='format:%-Y.%-m.%-d' --format='%cd+%h'")
git_version = git_commit_date_hash
# add "+dirty" suffix if there are uncommited changes except searx/settings.yml
try:
subprocess_run("git diff --quiet -- . ':!searx/settings.yml' ':!utils/brand.env'")
except subprocess.CalledProcessError as e:
if e.returncode == 1:
git_version += "+dirty"
else:
logger.warning('"%s" returns an unexpected return code %i', e.returncode, e.cmd)
return git_version


def get_git_fork_commit():
git_commit_date_hash = subprocess_run(r"git show -s --format='%h'")
return git_commit_date_hash


try:
vf = importlib.import_module('searx.version_frozen')
VERSION_STRING, VERSION_TAG, DOCKER_TAG, GIT_URL, GIT_BRANCH = (
Expand All @@ -99,6 +122,9 @@ def get_git_version():
logger.error("%s is not found, fallback to the default version", ex.filename)


VERSION_STRING_UPSTREAM = get_git_version_upstream()
FORK_COMMIT = get_git_fork_commit()

logger.info("version: %s", VERSION_STRING)

if __name__ == "__main__":
Expand All @@ -113,6 +139,8 @@ def get_git_version():
VERSION_STRING = "{VERSION_STRING}"
VERSION_TAG = "{VERSION_TAG}"
DOCKER_TAG = "{DOCKER_TAG}"
VERSION_STRING_UPSTREAM = "{VERSION_STRING_UPSTREAM}"
FORK_COMMIT = "{FORK_COMMIT}"
GIT_URL = "{GIT_URL}"
GIT_BRANCH = "{GIT_BRANCH}"
"""
Expand All @@ -126,6 +154,8 @@ def get_git_version():
VERSION_STRING="{VERSION_STRING}"
VERSION_TAG="{VERSION_TAG}"
DOCKER_TAG="{DOCKER_TAG}"
VERSION_STRING_UPSTREAM = "{VERSION_STRING_UPSTREAM}"
FORK_COMMIT = "{FORK_COMMIT}"
GIT_URL="{GIT_URL}"
GIT_BRANCH="{GIT_BRANCH}"
"""
Expand Down
5 changes: 3 additions & 2 deletions searx/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
gen_useragent,
dict_subset,
)
from searx.version import VERSION_STRING, GIT_URL, GIT_BRANCH
from searx.version import VERSION_STRING, VERSION_STRING_UPSTREAM, FORK_COMMIT, GIT_URL, GIT_BRANCH
from searx.query import RawTextQuery
from searx.plugins import Plugin, plugins, initialize as plugin_initialize
from searx.plugins.oa_doi_rewrite import get_doi_resolver
Expand Down Expand Up @@ -420,6 +420,7 @@ def render(template_name: str, **kwargs):
kwargs['search_formats'] = [x for x in settings['search']['formats'] if x != 'html']
kwargs['instance_name'] = get_setting('general.instance_name')
kwargs['searx_version'] = VERSION_STRING
kwargs['searx_version_custom'] = str(VERSION_STRING_UPSTREAM) + " (" + str(FORK_COMMIT) + ")"
kwargs['searx_git_url'] = GIT_URL
kwargs['enable_metrics'] = get_setting('general.enable_metrics')
kwargs['get_setting'] = get_setting
Expand Down Expand Up @@ -1309,7 +1310,7 @@ def config():
'autocomplete': settings['search']['autocomplete'],
'safe_search': settings['search']['safe_search'],
'default_theme': settings['ui']['default_theme'],
'version': VERSION_STRING,
'version': str(VERSION_STRING_UPSTREAM) + " (" + str(FORK_COMMIT) + ")",
'brand': {
'PRIVACYPOLICY_URL': get_setting('general.privacypolicy_url'),
'CONTACT_URL': get_setting('general.contact_url'),
Expand Down
5 changes: 5 additions & 0 deletions tests/robot/settings_robot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
general:
debug: false
instance_name: "searx_test"
legal_name: "test_legal"
legal_url: http://example.org/legal

brand:
git_url: https://github.com/searxng/searxng
Expand All @@ -10,6 +12,9 @@ brand:
docs_url: https://docs.searxng.org
public_instances: https://searx.space
wiki_url: https://github.com/searxng/searxng/wiki
website_name: "test_website1"
website_url: http://example.org/website1
donate_url: http://example.org/website2

search:
language: "all"
Expand Down

0 comments on commit 5f50d2d

Please sign in to comment.