forked from Icycoide/searxng
Merge pull request 'master' (#1) from Icycoide/searxng:master into master
Reviewed-on: #1
This commit is contained in:
commit
9f29131161
51 changed files with 1995 additions and 906 deletions
|
@ -51,6 +51,9 @@ def request(query, params):
|
|||
if netloc == main_wiki:
|
||||
eng_lang: str = traits.get_language(sxng_lang, 'English') # type: ignore
|
||||
query += ' (' + eng_lang + ')'
|
||||
# wiki.archlinux.org is protected by anubis
|
||||
# - https://github.com/searxng/searxng/issues/4646#issuecomment-2817848019
|
||||
params['headers']['User-Agent'] = "SearXNG"
|
||||
elif netloc == 'wiki.archlinuxcn.org':
|
||||
base_url = 'https://' + netloc + '/wzh/index.php?'
|
||||
|
||||
|
|
|
@ -169,18 +169,6 @@ ui:
|
|||
# - image_proxy
|
||||
# - query_in_title
|
||||
|
||||
# searx supports result proxification using an external service:
|
||||
# https://github.com/asciimoo/morty uncomment below section if you have running
|
||||
# morty proxy the key is base64 encoded (keep the !!binary notation)
|
||||
# Note: since commit af77ec3, morty accepts a base64 encoded key.
|
||||
#
|
||||
# result_proxy:
|
||||
# url: http://127.0.0.1:3000/
|
||||
# # the key is a base64 encoded string, the YAML !!binary prefix is optional
|
||||
# key: !!binary "your_morty_proxy_key"
|
||||
# # [true|false] enable the "proxy" button next to each result
|
||||
# proxify_results: true
|
||||
|
||||
# communication with search engines
|
||||
#
|
||||
outgoing:
|
||||
|
|
|
@ -230,11 +230,6 @@ SCHEMA = {
|
|||
'extra_proxy_timeout': SettingsValue(int, 0),
|
||||
'networks': {},
|
||||
},
|
||||
'result_proxy': {
|
||||
'url': SettingsValue((None, str), None),
|
||||
'key': SettingsBytesValue((None, bytes), None),
|
||||
'proxify_results': SettingsValue(bool, False),
|
||||
},
|
||||
'plugins': SettingsValue(dict, {}),
|
||||
'checker': {
|
||||
'off_when_debug': SettingsValue(bool, True, None),
|
||||
|
|
|
@ -44,10 +44,10 @@
|
|||
{%- endmacro -%}
|
||||
|
||||
<!-- Draw result sub footer -->
|
||||
{%- macro result_sub_footer(result, proxify) -%}
|
||||
{%- macro result_sub_footer(result) -%}
|
||||
<div class="engines">
|
||||
{% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}
|
||||
{{ icon_small('ellipsis-vertical') + result_link(cache_url + result.url, _('cached'), "cache_link") }}‎ {% if proxify and proxify_results %} {{ result_link(proxify(result.url), _('proxied'), "proxyfied_link") }} {% endif %}
|
||||
{{ icon_small('ellipsis-vertical') + result_link(cache_url + result.url, _('cached'), "cache_link") }}
|
||||
</div>{{- '' -}}
|
||||
<div class="break"></div>{{- '' -}}
|
||||
{%- endmacro -%}
|
||||
|
|
|
@ -28,5 +28,5 @@
|
|||
{{- result.codelines|code_highlighter(result.code_language)|safe -}}
|
||||
</div>
|
||||
|
||||
{{- result_sub_footer(result, proxify) -}}
|
||||
{{- result_sub_footer(result) -}}
|
||||
{{- result_footer(result) -}}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{{ _('This site did not provide any description.')|safe }}
|
||||
</p>
|
||||
{% endif -%}
|
||||
{{- result_sub_footer(result, proxify) -}}
|
||||
{{- result_sub_footer(result) -}}
|
||||
{% if result.iframe_src -%}
|
||||
<div id="result-media-{{ index }}" class="embedded-content invisible">
|
||||
<iframe data-src="{{result.iframe_src}}" frameborder="0" allowfullscreen></iframe>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<small> <a class="btn-collapse collapsed searxng_init_map hide_if_nojs" data-target="#result-map-{{ index }}" data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %}>{{ icon_small( 'globe') }} {{ _('show map') }}</a></small>
|
||||
{%- endif -%}
|
||||
|
||||
{{- result_sub_footer(result, proxify) -}}
|
||||
{{- result_sub_footer(result) -}}
|
||||
|
||||
{% if (result.latitude and result.longitude) or result.boundingbox -%}
|
||||
<div id="result-map-{{ index }}" class="invisible"><div id="osm-map-{{ index }}" class="osm-map-box"></div></div>
|
||||
|
|
|
@ -34,5 +34,5 @@
|
|||
{%- if result.html_url -%}{{ result_link(result.html_url, _('HTML')) }}{%- endif -%}
|
||||
{%- if result.doi %}{{ result_link('https://www.altmetric.com/details/doi/' + result.doi, 'Altmetric') }}{% endif -%}
|
||||
</p>
|
||||
{{- result_sub_footer(result, proxify) -}}
|
||||
{{- result_sub_footer(result) -}}
|
||||
{{- result_footer(result) }}
|
||||
|
|
|
@ -10,5 +10,5 @@
|
|||
{{ result.content|safe }}
|
||||
</p>
|
||||
{% endif -%}
|
||||
{{- result_sub_footer(result, proxify) -}}
|
||||
{{- result_sub_footer(result) -}}
|
||||
{{- result_footer(result) }}
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
{%- if result.files %}{{ icon_big('file') }} <span class="badge">{{ result.files }} {{ _('Number of Files') }}</span>{%- endif -%}
|
||||
</p>
|
||||
{%- if result.content %}<p class="content">{{ result.content|safe }}</p>{%- endif -%}
|
||||
{{- result_sub_footer(result, proxify) -}}
|
||||
{{- result_sub_footer(result) -}}
|
||||
{{- result_footer(result) -}}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</p>
|
||||
{% endif -%}
|
||||
</p>
|
||||
{{- result_sub_footer(result, proxify) -}}
|
||||
{{- result_sub_footer(result) -}}
|
||||
{% if result.iframe_src -%}
|
||||
<div id="result-video-{{ index }}" class="embedded-video invisible">
|
||||
<iframe data-src="{{result.iframe_src}}" frameborder="0" allowfullscreen></iframe>
|
||||
|
|
|
@ -41,6 +41,12 @@ def subprocess_run(args, **kwargs):
|
|||
|
||||
|
||||
def get_git_url_and_branch():
|
||||
# handle GHA directly
|
||||
if "GITHUB_REPOSITORY" in os.environ and "GITHUB_REF_NAME" in os.environ:
|
||||
git_url = f"https://github.com/{os.environ['GITHUB_REPOSITORY']}"
|
||||
git_branch = os.environ["GITHUB_REF_NAME"]
|
||||
return git_url, git_branch
|
||||
|
||||
try:
|
||||
ref = subprocess_run("git rev-parse --abbrev-ref @{upstream}")
|
||||
except subprocess.CalledProcessError:
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
@ -261,24 +259,6 @@ def custom_url_for(endpoint: str, **values):
|
|||
return url_for(endpoint, **values) + suffix
|
||||
|
||||
|
||||
def morty_proxify(url: str):
|
||||
if not url:
|
||||
return url
|
||||
|
||||
if url.startswith('//'):
|
||||
url = 'https:' + url
|
||||
|
||||
if not settings['result_proxy']['url']:
|
||||
return url
|
||||
|
||||
url_params = dict(mortyurl=url)
|
||||
|
||||
if settings['result_proxy']['key']:
|
||||
url_params['mortyhash'] = hmac.new(settings['result_proxy']['key'], url.encode(), hashlib.sha256).hexdigest()
|
||||
|
||||
return '{0}?{1}'.format(settings['result_proxy']['url'], urlencode(url_params))
|
||||
|
||||
|
||||
def image_proxify(url: str):
|
||||
if not url:
|
||||
return url
|
||||
|
@ -300,9 +280,6 @@ def image_proxify(url: str):
|
|||
return url
|
||||
return None
|
||||
|
||||
if settings['result_proxy']['url']:
|
||||
return morty_proxify(url)
|
||||
|
||||
h = new_hmac(settings['server']['secret_key'], url.encode())
|
||||
|
||||
return '{0}?{1}'.format(url_for('image_proxy'), urlencode(dict(url=url.encode(), h=h)))
|
||||
|
@ -424,8 +401,6 @@ def render(template_name: str, **kwargs):
|
|||
kwargs['url_for'] = custom_url_for # override url_for function in templates
|
||||
kwargs['image_proxify'] = image_proxify
|
||||
kwargs['favicon_url'] = favicons.favicon_url
|
||||
kwargs['proxify'] = morty_proxify if settings['result_proxy']['url'] is not None else None
|
||||
kwargs['proxify_results'] = settings['result_proxy']['proxify_results']
|
||||
kwargs['cache_url'] = settings['ui']['cache_url']
|
||||
kwargs['get_result_template'] = get_result_template
|
||||
kwargs['opensearch_url'] = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue