Skip to content

Commit

Permalink
[update] master branch: fd1422a to dbe94f1
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:
  - be6ddb2
  - b595d9b
  - 7f2fea2
  - 2878623

Tested: 2023-10-29 @ 00:10:24 CEST
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 28, 2023
2 parents dbe94f1 + be6ddb2 commit 0a2a3ff
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 13 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 @@ -55,6 +55,7 @@
"""

import re
import urllib.parse
import babel

Expand Down Expand Up @@ -187,9 +188,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
9 changes: 9 additions & 0 deletions searx/infopage/de/donate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Spenden

## An Tiekoetter.com spenden

Tiekoetter.com unterstützen: [https://www.tiekoetter.com/spenden](https://www.tiekoetter.com/spenden)

## An SearXNG.org spenden

Sie können das SearXNG Projekt unterstützen indem Sie auf die Spendenseite klicken: [https://docs.searxng.org/donate.html](https://docs.searxng.org/donate.html)
9 changes: 9 additions & 0 deletions searx/infopage/en/donate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Donate

## Donate to Tiekoetter.com

Support Tiekoetter.com: [https://www.tiekoetter.com/en/donate](https://www.tiekoetter.com/en/donate/)

## Donate to SearXNG.org

You can support the SearXNG project by clicking on the donation page: [https://docs.searxng.org/donate.html](https://docs.searxng.org/donate.html)
7 changes: 0 additions & 7 deletions searx/network/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,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 @@ -507,8 +507,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,13 +12,18 @@ general:
contact_url: false
# record stats
enable_metrics: true
legal_name: ""
legal_url:

brand:
new_issue_url: https://github.com/searxng/searxng/issues/new
docs_url: https://docs.searxng.org/
public_instances: https://searx.space
wiki_url: https://github.com/searxng/searxng/wiki
issue_url: https://github.com/searxng/searxng/issues
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 @@ -64,13 +64,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 @@ -77,6 +77,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 @@ -100,6 +123,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.botdetection import link_token
Expand Down Expand Up @@ -418,6 +418,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 @@ -1279,7 +1280,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
2 changes: 1 addition & 1 deletion utils/brand.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export SEARXNG_URL=''
export SEARXNG_PORT='8888'
export SEARXNG_BIND_ADDRESS='127.0.0.1'
export GIT_URL='https://github.com/searxng/searxng'
export GIT_URL='https://github.com/tiekoetter/searxng'
export GIT_BRANCH='master'

0 comments on commit 0a2a3ff

Please sign in to comment.