 50f92779bd
			
		
	
	
		50f92779bd
		
	
	
	
	
		
			
			This patch brings two major changes:
- ``Result.filter_urls(..)`` to pass a filter function for URL fields
- The ``enabled_plugins:`` section in SearXNG's settings do no longer exists.
To understand plugin development compile documentation:
    $ make docs.clean docs.live
and read http://0.0.0.0:8000/dev/plugins/development.html
There is no longer a distinction between built-in and external plugin, all
plugins are registered via the settings in the ``plugins:`` section.
In SearXNG, plugins can be registered via a fully qualified class name.  A
configuration (`PluginCfg`) can be transferred to the plugin, e.g. to activate
it by default / *opt-in* or *opt-out* from user's point of view.
built-in plugins
================
The built-in plugins are all located in the namespace `searx.plugins`.
.. code:: yaml
    plugins:
      searx.plugins.calculator.SXNGPlugin:
        active: true
      searx.plugins.hash_plugin.SXNGPlugin:
        active: true
      searx.plugins.self_info.SXNGPlugin:
        active: true
      searx.plugins.tracker_url_remover.SXNGPlugin:
        active: true
      searx.plugins.unit_converter.SXNGPlugin:
        active: true
      searx.plugins.ahmia_filter.SXNGPlugin:
        active: true
      searx.plugins.hostnames.SXNGPlugin:
        active: true
      searx.plugins.oa_doi_rewrite.SXNGPlugin:
        active: false
      searx.plugins.tor_check.SXNGPlugin:
        active: false
external plugins
================
SearXNG supports *external plugins* / there is no need to install one, SearXNG
runs out of the box.
- Only show green hosted results: https://github.com/return42/tgwf-searx-plugins/
To get a developer installation in a SearXNG developer environment:
.. code:: sh
   $ git clone git@github.com:return42/tgwf-searx-plugins.git
   $ ./manage pyenv.cmd python -m \
         pip install -e tgwf-searx-plugins
To register the plugin in SearXNG add ``only_show_green_results.SXNGPlugin`` to
the ``plugins:``:
.. code:: yaml
    plugins:
      # ...
      only_show_green_results.SXNGPlugin:
        active: false
Result.filter_urls(..)
======================
The ``Result.filter_urls(..)`` can be used to filter and/or modify URL fields.
In the following example, the filter function ``my_url_filter``:
.. code:: python
   def my_url_filter(result, field_name, url_src) -> bool | str:
       if "google" in url_src:
           return False              # remove URL field from result
       if "facebook" in url_src:
           new_url = url_src.replace("facebook", "fb-dummy")
           return new_url            # return modified URL
       return True                   # leave URL in field unchanged
is applied to all URL fields in the :py:obj:`Plugin.on_result` hook:
.. code:: python
   class MyUrlFilter(Plugin):
       ...
       def on_result(self, request, search, result) -> bool:
           result.filter_urls(my_url_filter)
           return True
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
		
	
			
		
			
				
	
	
		
			142 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			142 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| general:
 | |
|   debug: false
 | |
|   instance_name: "searx"
 | |
| 
 | |
| search:
 | |
|   safe_search: 0
 | |
|   autocomplete: ""
 | |
|   favicon_resolver: ""
 | |
|   default_lang: ""
 | |
|   ban_time_on_fail: 5
 | |
|   max_ban_time_on_fail: 120
 | |
| 
 | |
| server:
 | |
|   port: 9000
 | |
|   bind_address: "[::]"
 | |
|   secret_key: "user_settings_secret"
 | |
|   base_url: false
 | |
|   image_proxy: false
 | |
|   http_protocol_version: "1.0"
 | |
|   method: "POST"
 | |
|   default_http_headers:
 | |
|     X-Content-Type-Options: nosniff
 | |
|     X-Download-Options: noopen
 | |
|     X-Robots-Tag: noindex, nofollow
 | |
|     Referrer-Policy: no-referrer
 | |
| 
 | |
| ui:
 | |
|   static_path: ""
 | |
|   templates_path: ""
 | |
|   default_theme: simple
 | |
|   default_locale: ""
 | |
|   theme_args:
 | |
|     simple_style: auto
 | |
| 
 | |
| plugins:
 | |
| 
 | |
|   searx.plugins.calculator.SXNGPlugin:
 | |
|     active: true
 | |
| 
 | |
|   searx.plugins.hash_plugin.SXNGPlugin:
 | |
|     active: true
 | |
| 
 | |
|   searx.plugins.self_info.SXNGPlugin:
 | |
|     active: true
 | |
| 
 | |
|   searx.plugins.tracker_url_remover.SXNGPlugin:
 | |
|     active: true
 | |
| 
 | |
|   searx.plugins.unit_converter.SXNGPlugin:
 | |
|     active: true
 | |
| 
 | |
|   searx.plugins.ahmia_filter.SXNGPlugin:
 | |
|     active: true
 | |
| 
 | |
|   searx.plugins.hostnames.SXNGPlugin:
 | |
|     active: true
 | |
| 
 | |
|   searx.plugins.oa_doi_rewrite.SXNGPlugin:
 | |
|     active: false
 | |
| 
 | |
|   searx.plugins.tor_check.SXNGPlugin:
 | |
|     active: false
 | |
| 
 | |
| 
 | |
| engines:
 | |
|   - name: wikidata
 | |
|     engine: wikidata
 | |
|     shortcut: wd
 | |
|     timeout: 3.0
 | |
|     weight: 2
 | |
| 
 | |
|   - name: wikibooks
 | |
|     engine: mediawiki
 | |
|     shortcut: wb
 | |
|     categories: general
 | |
|     base_url: "https://{language}.wikibooks.org/"
 | |
|     number_of_results: 5
 | |
|     search_type: text
 | |
| 
 | |
|   - name: wikinews
 | |
|     engine: mediawiki
 | |
|     shortcut: wn
 | |
|     categories: news
 | |
|     base_url: "https://{language}.wikinews.org/"
 | |
|     number_of_results: 5
 | |
|     search_type: text
 | |
| 
 | |
|   - name: wikiquote
 | |
|     engine: mediawiki
 | |
|     shortcut: wq
 | |
|     categories: general
 | |
|     base_url: "https://{language}.wikiquote.org/"
 | |
|     number_of_results: 5
 | |
|     search_type: text
 | |
| 
 | |
| locales:
 | |
|   en: English
 | |
|   ar: العَرَبِيَّة (Arabic)
 | |
|   bg: Български (Bulgarian)
 | |
|   bo: བོད་སྐད་ (Tibetian)
 | |
|   ca: Català (Catalan)
 | |
|   cs: Čeština (Czech)
 | |
|   cy: Cymraeg (Welsh)
 | |
|   da: Dansk (Danish)
 | |
|   de: Deutsch (German)
 | |
|   el_GR: Ελληνικά (Greek_Greece)
 | |
|   eo: Esperanto (Esperanto)
 | |
|   es: Español (Spanish)
 | |
|   et: Eesti (Estonian)
 | |
|   eu: Euskara (Basque)
 | |
|   fa_IR: (fārsī) فارسى (Persian)
 | |
|   fi: Suomi (Finnish)
 | |
|   fil: Wikang Filipino (Filipino)
 | |
|   fr: Français (French)
 | |
|   gl: Galego (Galician)
 | |
|   he: עברית (Hebrew)
 | |
|   hr: Hrvatski (Croatian)
 | |
|   hu: Magyar (Hungarian)
 | |
|   ia: Interlingua (Interlingua)
 | |
|   it: Italiano (Italian)
 | |
|   ja: 日本語 (Japanese)
 | |
|   lt: Lietuvių (Lithuanian)
 | |
|   nl: Nederlands (Dutch)
 | |
|   nl_BE: Vlaams (Dutch_Belgium)
 | |
|   oc: Lenga D'òc (Occitan)
 | |
|   pl: Polski (Polish)
 | |
|   pt: Português (Portuguese)
 | |
|   pt_BR: Português (Portuguese_Brazil)
 | |
|   ro: Română (Romanian)
 | |
|   ru: Русский (Russian)
 | |
|   sk: Slovenčina (Slovak)
 | |
|   sl: Slovenski (Slovene)
 | |
|   sr: српски (Serbian)
 | |
|   sv: Svenska (Swedish)
 | |
|   te: తెలుగు (telugu)
 | |
|   ta: தமிழ் (Tamil)
 | |
|   tr: Türkçe (Turkish)
 | |
|   uk: українська мова (Ukrainian)
 | |
|   vi: tiếng việt (Vietnamese)
 | |
|   zh: 中文 (Chinese)
 | |
|   zh_TW: 國語 (Taiwanese Mandarin)
 |