Commit graph

39 commits

Author SHA1 Message Date
Markus Heiser
edfbf1e118 [refactor] typification of SearXNG (initial) / result items (part 1)
Typification of SearXNG
=======================

This patch introduces the typing of the results.  The why and how is described
in the documentation, please generate the documentation ..

    $ make docs.clean docs.live

and read the following articles in the "Developer documentation":

- result types --> http://0.0.0.0:8000/dev/result_types/index.html

The result types are available from the `searx.result_types` module.  The
following have been implemented so far:

- base result type: `searx.result_type.Result`
  --> http://0.0.0.0:8000/dev/result_types/base_result.html

- answer results
  --> http://0.0.0.0:8000/dev/result_types/answer.html

including the type for translations (inspired by #3925).  For all other
types (which still need to be set up in subsequent PRs), template documentation
has been created for the transition period.

Doc of the fields used in Templates
===================================

The template documentation is the basis for the typing and is the first complete
documentation of the results (needed for engine development).  It is the
"working paper" (the plan) with which further typifications can be implemented
in subsequent PRs.

- https://github.com/searxng/searxng/issues/357

Answer Templates
================

With the new (sub) types for `Answer`, the templates for the answers have also
been revised, `Translation` are now displayed with collapsible entries (inspired
by #3925).

    !en-de dog

Plugins & Answerer
==================

The implementation for `Plugin` and `Answer` has been revised, see
documentation:

- Plugin: http://0.0.0.0:8000/dev/plugins/index.html
- Answerer: http://0.0.0.0:8000/dev/answerers/index.html

With `AnswerStorage` and `AnswerStorage` to manage those items (in follow up
PRs, `ArticleStorage`, `InfoStorage` and .. will be implemented)

Autocomplete
============

The autocompletion had a bug where the results from `Answer` had not been shown
in the past.  To test activate autocompletion and try search terms for which we
have answerers

- statistics: type `min 1 2 3` .. in the completion list you should find an
  entry like `[de] min(1, 2, 3) = 1`

- random: type `random uuid` .. in the completion list, the first item is a
  random UUID

Extended Types
==============

SearXNG extends e.g. the request and response types of flask and httpx, a module
has been set up for type extensions:

- Extended Types
  --> http://0.0.0.0:8000/dev/extended_types.html

Unit-Tests
==========

The unit tests have been completely revised.  In the previous implementation,
the runtime (the global variables such as `searx.settings`) was not initialized
before each test, so the runtime environment with which a test ran was always
determined by the tests that ran before it.  This was also the reason why we
sometimes had to observe non-deterministic errors in the tests in the past:

- https://github.com/searxng/searxng/issues/2988 is one example for the Runtime
  issues, with non-deterministic behavior ..

- https://github.com/searxng/searxng/pull/3650
- https://github.com/searxng/searxng/pull/3654
- https://github.com/searxng/searxng/pull/3642#issuecomment-2226884469
- https://github.com/searxng/searxng/pull/3746#issuecomment-2300965005

Why msgspec.Struct
==================

We have already discussed typing based on e.g. `TypeDict` or `dataclass` in the past:

- https://github.com/searxng/searxng/pull/1562/files
- https://gist.github.com/dalf/972eb05e7a9bee161487132a7de244d2
- https://github.com/searxng/searxng/pull/1412/files
- https://github.com/searxng/searxng/pull/1356

In my opinion, TypeDict is unsuitable because the objects are still dictionaries
and not instances of classes / the `dataclass` are classes but ...

The `msgspec.Struct` combine the advantages of typing, runtime behaviour and
also offer the option of (fast) serializing (incl. type check) the objects.

Currently not possible but conceivable with `msgspec`: Outsourcing the engines
into separate processes, what possibilities this opens up in the future is left
to the imagination!

Internally, we have already defined that it is desirable to decouple the
development of the engines from the development of the SearXNG core / The
serialization of the `Result` objects is a prerequisite for this.

HINT: The threads listed above were the template for this PR, even though the
implementation here is based on msgspec.  They should also be an inspiration for
the following PRs of typification, as the models and implementations can provide
a good direction.

Why just one commit?
====================

I tried to create several (thematically separated) commits, but gave up at some
point ... there are too many things to tackle at once / The comprehensibility of
the commits would not be improved by a thematic separation. On the contrary, we
would have to make multiple changes at the same places and the goal of a change
would be vaguely recognizable in the fog of the commits.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-01-28 07:07:08 +01:00
Markus Heiser
799d72e3fd [mod] add French translation for infopage
The French translation was provided by @jcarnat in #3738.

[3738] https://github.com/searxng/searxng/issues/3738

Co-authored-by: Joel Carnat @jcarnat https://github.com/jcarnat
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-08-20 07:25:39 +02:00
Markus Heiser
c19bffde4d [fix] issues reported by pylint-3.2.2
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-05-28 18:10:04 +02:00
Markus Heiser
542f7d0d7b [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION
In the past, some files were tested with the standard profile, others with a
profile in which most of the messages were switched off ... some files were not
checked at all.

- ``PYLINT_SEARXNG_DISABLE_OPTION`` has been abolished
- the distinction ``# lint: pylint`` is no longer necessary
- the pylint tasks have been reduced from three to two

  1. ./searx/engines -> lint engines with additional builtins
  2. ./searx ./searxng_extra ./tests -> lint all other python files

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-03-11 14:55:38 +01:00
centralscrutinizer21
fbea0dd3ce [l10n] Italian translation of infopages 2024-03-08 17:18:29 +01:00
Markus Heiser
bfcd41f04a [clean] drop obsolete py3.7 compatibility
- https://github.com/searxng/searxng/discussions/2356

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-02-10 09:27:19 +01:00
Bnyro
f0df53673e [mod] search-syntax.md: add tutorial about the feeling lucky feature 2023-09-21 15:17:23 +02:00
jazzzooo
223b3487c3 [fix] spelling 2023-09-18 16:20:27 +02:00
Jafar Farganlooj
7af66736c0 Create search-syntax.md fa 2023-08-30 16:39:10 +02:00
Jafar Farganlooj
26cd770cf7 [mod] Persian translation of the about page (fa_IR) 2023-08-30 16:13:44 +02:00
Markus Heiser
bbb2af7d94 [fix] minor typo in de/search-syntax page
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-04-08 10:25:52 +02:00
Alexandre Flament
a9d6f7532a weblate: migration to https://translate.codeberg.org/ 2023-01-21 15:45:12 +00:00
PrivateLalle
212acf7f7b [mod] about page: add information about adding enginge to the brownser 2023-01-07 14:48:06 +01:00
Markus Heiser
4cd3be8964 [fix] indentation and line size of the the markdown files
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-01-07 14:46:31 +01:00
Alexandre Flament
f8f239fe1f Donation link: default value to searxng.org, can be hidden or custom
Add a new setting: general.donation_url

By default the value is https://docs.searxng.org/donate.html

When the value is false, the link is hidden

When the value is true, the link goes to the infopage donation,
the administrator can create a custom page.
2022-07-02 11:29:21 +02:00
Alexandre Flament
1617ef1e41
Update searx/infopage/en/donate.md
Co-authored-by: Émilien Devos <contact@emiliendevos.be>
2022-06-29 21:03:01 +02:00
Alexandre FLAMENT
0e503c990a Move donation page to docs.searxng.org and link to it from instances
Close #1378
2022-06-29 17:26:19 +00:00
Alexandre FLAMENT
ecccf02a02 infopage: a .md file can be remove without crash
An administrator might decide to remove some of the .md files.
This commit make sure to not crash the application.
2022-06-29 17:25:07 +00:00
Alexandre Flament
0801f9a24e Add donate.md 2022-06-28 10:59:36 +02:00
Alexandre Flament
6e2b5f3d5a Theme: add Help and Donate links in all pages
Close https://github.com/searxng/searxng/issues/931
2022-06-25 20:31:40 +02:00
Markus Heiser
2de007138c [fix] prepare for pylint 2.14.0
Remove issue reported by Pylint 2.14.0:

- no-self-use: has been moved to optional extension [1]
- The refactoring checker now also raises 'consider-using-generator' messages
  for max(), min() and sum(). [2]

.pylintrc:
  - <option name>-hint has been removed since long, Pylint 2.14.0 raises an
    error on invalid options
  - bad-continuation and bad-whitespace have been removed [3]

[1] https://pylint.pycqa.org/en/latest/whatsnew/2/2.14/summary.html#removed-checkers
[2] https://pylint.pycqa.org/en/latest/whatsnew/2/2.14/full.html#what-s-new-in-pylint-2-14-0
[2] https://pylint.pycqa.org/en/latest/whatsnew/2/2.6/summary.html#summary-release-highlights

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-06-03 15:41:52 +02:00
Markus Heiser
e93385e6de
Merge pull request #1249 from Linerly/english-infopage
Capitalize website names in search-syntax.md, in the English infopage
2022-05-28 16:50:55 +02:00
Linerly
c2f7b1136e
Capitalize website names 2022-05-28 14:41:53 +00:00
Linerly
979c42f044
Replace link 2022-05-28 14:38:14 +00:00
Linerly
2871900651
Capitalize website names 2022-05-28 14:34:58 +00:00
Linerly
db26b9b13b
Replace English links to Indonesian links 2022-05-28 14:33:10 +00:00
Markus Heiser
22d8971bc9 [translation] add DE translation of about.md and search-syntax.md
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-05-28 14:28:51 +02:00
Linerly
f3134e0869 Add Indonesian translations of about.md and search-syntax.md 2022-05-27 10:06:44 +07:00
Markus Heiser
4326009d00 [format.python] based on bugfix in 9ed626130 2022-05-07 18:23:10 +02:00
Alexandre Flament
27f8fa6fe0
Merge pull request #1048 from Linerly/patch-1
Improve the about page
2022-04-09 20:30:49 +02:00
Markus Heiser
9215281232 [mod] replace Markdown parser mistletoe by markdown-it-py
There are several reasons why we should prefer markdown-it-py over mistletoe:

- Get identical rendering results in SearXNG's `/info` pages and the SearXNG's
  project documentation which is build by Sphinx-doc.

  In the Sphinx-doc we use the MyST parser to render Markdown and the MyST
  parser itself is built on top of the markdown-it-py package.

- markdown-it-py has a typographer that supports *replacements*
  and *smartquotes* (e.g. em-dash, copyright, ellipsis, ...) [1]

- markdown-it-py is much more flexible compared to mistletoe [2]

- markdown-it-py is the fastest CommonMark compliant parser in python [3]

[1] https://markdown-it-py.readthedocs.io/en/latest/using.html#typographic-components
[2] https://markdown-it-py.readthedocs.io/en/latest/plugins.html
[3] https://markdown-it-py.readthedocs.io/en/latest/other.html#performance

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-04-06 15:49:50 +02:00
Linerly
22309f398b
Fix spelling and punctuation 2022-04-06 12:36:17 +00:00
Markus Heiser
19ebd0e1ac [mod] review of the "Search Syntax" page (en)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-04-06 14:13:22 +02:00
Markus Heiser
655db9b003 [mod] review of the "About SearXNG" page (en)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-04-06 13:05:20 +02:00
Linerly
036b46493b
Improve the about page 2022-04-02 20:51:11 +00:00
Alexandre Flament
dbe3eaabc9 Info: code refactoring & bug fixes 2022-03-16 22:26:36 +01:00
Alexandre Flament
1157462ff9 Various change on PR 930 2022-03-13 22:22:02 +01:00
Markus Heiser
59100e8525 [fix] add module for backward compatibility
cache_property has been added in py3.8 [1]

To support cache_property in py3.7 the implementation from 3.8 has been
copied to compat.py.  This code can be cleanup with EOL of py3.7.

[1] https://docs.python.org/3/library/functools.html#functools.cached_property

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-03-12 15:45:28 +01:00
Markus Heiser
b1912607ae [mod] replace /help by /info pages and include pages in project docs
This patch implements a bolierplate to share content from info-pages of the
SearXNG instance (URL /info) with the project documentation (path /docs/user).

The info pages are using Markdown (CommonMark), to include them in the project
documentation (reST) the myst-parser [1] is used in the Sphinx-doc build chain.

If base_url is known (defined in settings.yml) links to the instance are also
inserted into the project documentation::

    searxng_extra/docs_prebuild

[1] https://www.sphinx-doc.org/en/master/usage/markdown.html

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-03-12 11:36:31 +01:00