summaryrefslogtreecommitdiff
path: root/searx/webapp.py
AgeCommit message (Collapse)Author
2024-11-25[mod] add CSS (LESS) to xsl style to view rss in browserMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-11-25[refactor] <type> element isn't a part of the RSS 2.0 spec [1]Markus Heiser
[1] https://cyber.harvard.edu/rss/rss.html Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-11-24[feat] metrics: support for open metricsBnyro
2024-10-28[fix] calculator: use locale from UI (not from selected language)Markus Heiser
Closes: https://github.com/searxng/searxng/issues/3956 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-10-05[mod] Revision of the favicon solutionMarkus Heiser
All favicons implementations have been documented and moved to the Python package: searx.favicons There is a configuration (based on Pydantic) for the favicons and all its components: searx.favicons.config A solution for caching favicons has been implemented: searx.favicon.cache If the favicon is already in the cache, the returned URL is a data URL [1] (something like `data:image/png;base64,...`). By generating a data url from the FaviconCache, additional HTTP roundtripps via the favicon_proxy are saved: favicons.proxy.favicon_url The favicon proxy service now sets a HTTP header "Cache-Control: max-age=...": favicons.proxy.favicon_proxy The resolvers now also provide the mime type (data, mime): searx.favicon.resolvers [1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-10-05[feat] add favicons to result urlsBrock Vojkovic
2024-09-03[feat] results: show response timesGenericMale
2024-07-14[mod] revision of the settings_loaderMarkus Heiser
The intention of this PR is to modernize the settings_loader implementations. The concept is old (remember, this is partly from 2014), back then we only had one config file, meanwhile we have had a folder with config files for a very long time. Callers can now load a YAML configuration from this folder as follows :: settings_loader.get_yaml_cfg('my-config.yml') - BTW this is a fix of #3557. - Further the `existing_filename_or_none` construct dates back to times when there was not yet a `pathlib.Path` in all Python versions we supported in the past. - Typehints have been added wherever appropriate At the same time, this patch should also be downward compatible and not introduce a new environment variable. The localization of the folder with the configurations is further based on: SEARXNG_SETTINGS_PATH (wich defaults to /etc/searxng/settings.yml) Which means, the default config folder is `/etc/searxng/`. ATTENTION: intended functional changes! If SEARXNG_SETTINGS_PATH was set and pointed to a not existing file, the previous implementation silently loaded the default configuration. This behavior has been changed: if the file or folder does not exist, an EnvironmentError exception will be thrown in future. Closes: https://github.com/searxng/searxng/issues/3557 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-05-28[fix] issues reported by pylint-3.2.2Markus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-04-27improve "search existing issues from github" linkJinyuan Huang
2024-03-11[mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTIONMarkus Heiser
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-02-25[fix] re-add opensearch_url / its used in based.htmlMarkus Heiser
The URL was accidentally deleted in a85907a98, but is still required in base.html for auto-discovery / from base.html:: <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}" /> Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-02-25[fix] opensearxh.xml: firefox v123 does not except self-URI (URL with param)Markus Heiser
Before this patch we had a address in the rel-self-template with params [1]: GET:: <Url method="GET" rel="self" template="/opensearch.xml?method=GET&amp;autocomplete=google" type="application/opensearchdescription+xml"/> POST:: <Url method="POST" rel="self" template="/opensearch.xml?method=POST&amp;autocomplete=google" type="application/opensearchdescription+xml"/> The first one (GET) is no longer accepted by firefox since v123, the latter one was always been wrong (since it mixes GET params with a POST request). Since Firefox v123 a template syntax [2] in the rel-self-template is no longer supported / Firefox will report an error:: Firefox could not download the search plugin from: http://127.0.0.1:8888//opensearch.xml?method=GET&autocomplete=google This patch reduce the URL to:: template="http://127.0.0.1:8888/opensearch.xml" [1] https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md#url-rel-values [2] https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md#opensearch-url-template-syntax Closes: https://github.com/searxng/searxng/issues/3227 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-01-29[feat] preferences: button to copy input to restore preferences hashBnyro
2023-11-01[mod] isolation of botdetection from the limiterMarkus Heiser
This patch was inspired by the discussion around PR-2882 [2]. The goals of this patch are: 1. Convert plugin searx.plugin.limiter to normal code [1] 2. isolation of botdetection from the limiter [2] 3. searx/{tools => botdetection}/config.py and drop searx.tools 4. in URL /config, 'limiter.enabled' is true only if the limiter is really enabled (Redis is available). This patch moves all the code that belongs to botdetection into namespace searx.botdetection and code that belongs to limiter is placed in namespace searx.limiter. Tthe limiter used to be a plugin at some point botdetection was added, it was not a plugin. The modularization of these two components was long overdue. With the clear modularization, the documentation could then also be organized according to the architecture. [1] https://github.com/searxng/searxng/pull/2882 [2] https://github.com/searxng/searxng/pull/2882#issuecomment-1741716891 To test: - check the app works without the limiter, check `/config` - check the app works with the limiter and with the token, check `/config` - make docs.live .. and read - http://0.0.0.0:8000/admin/searx.limiter.html - http://0.0.0.0:8000/src/searx.botdetection.html#botdetection Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-09-25add new parameter called server.public_instanceEmilien Devos
for enabling by default advanced limiter functions in the future allow us to add features just for the public instances
2023-09-24/config: expose limiter configurationAlexandre Flament
2023-09-19[fix] Search on category select without JavaScript PR #2740Markus Heiser
Small addendum to #2740; search_on_category_select is now no longer a plugin. Related: https://github.com/searxng/searxng/pull/2740#issuecomment-1725437584 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-09-19[feat] implement feeling lucky featureBnyro
2023-09-19[mod] preferences: implement drop-down menu for hotkeys (default, vim)Markus Heiser
Replace the on/off checkbox of the vim-hotkeys in the preferences by a drop-down menu. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-09-18[feat] search on category select without JSBnyro
Co-authored-by: Alexandre Flament <alex@al-f.net>
2023-09-18[fix] spellingjazzzooo
2023-09-11[feature] dark theme for code highlighter in the result listMarkus Heiser
Closes: https://github.com/searxng/searxng/issues/1354 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-08-18[feat] results: show source of suggested answerBnyro
2023-06-19[mod] move some code from webapp module to webutils module (no functional ↵Markus Heiser
change) Over the years the webapp module became more and more a mess. To improve the modulaization a little this patch moves some implementations from the webapp module to webutils module. HINT: this patch brings non functional change Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-05-29[mod] limiter -> botdetection: modularization and documentationMarkus Heiser
In order to be able to meet the outstanding requirements, the implementation is modularized and supplemented with documentation. This patch does not contain functional change, except it fixes issue #2455 ---- Aktivate limiter in the settings.yml and simulate a bot request by:: curl -H 'Accept-Language: de-DE,en-US;q=0.7,en;q=0.3' \ -H 'Accept: text/html' -H 'User-Agent: xyz' \ -H 'Accept-Encoding: gzip' \ 'http://127.0.0.1:8888/search?q=foo' In the LOG: DEBUG searx.botdetection.link_token : missing ping for this request: ..... Since ``BURST_MAX_SUSPICIOUS = 2`` you can repeat the query above two time before you get a "Too Many Requests" response. Closes: https://github.com/searxng/searxng/issues/2455 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-05-29[mod] limiter: add random token to the limiter URLMarkus Heiser
By adding a random component in the limiter URL a bot can no longer send a ping by request a static URL. Related: https://github.com/searxng/searxng/pull/2357#issuecomment-1518525094 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-05-29[mod] limiter: reduce request rates for requests without a pingMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-04-15[mod] move language recognition to get_search_query_from_webappMarkus Heiser
To set the language from language recognition and hold the value selected by the client, the previous implementation creates a copy of the SearchQuery object and manipulates the SearchQuery object by calling function replace_auto_language(). This patch tries to implement a similar functionality in a more central place, in function get_search_query_from_webapp() when the SearchQuery object is build up. Additional this patch uses the language preferred by the client, if language recognition does not have a match / the existing implementation does not care about client preferences and uses 'all' in case of no match. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-04-15[mod] add a Preferences.client property to store client prefsMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-04-10[fix] don't show a category if there is no active engine inMarkus Heiser
When deactivate all the engines of a category, this category should disappeare. This feature has been lost in commit 8e9ad1cc. For better readability, webapp.get_enabled_categories() has been rewritten with identical functionality. Related: - https://github.com/searxng/searxng/issues/1020 - https://github.com/searxng/searxng/issues/1604 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-04-07[mod] clarify the difference of the default category and subgroupingMarkus Heiser
This PR does no functional change it is just an attempt to make more clear in the code, what a default category is and what a subcategory is. The previous name 'others' leads to confusion with the **category 'other'**. If a engine is not assigned to a category, the default is assigned:: DEFAULT_CATEGORY = 'other' If an engine has only one category and this category is shown as tab in the user interface, this engine has no further subgrouping:: NO_SUBGROUPING = 'without further subgrouping' Related: - https://github.com/searxng/searxng/issues/1604 - https://github.com/searxng/searxng/pull/1545 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-03-24[mod] replace utils.match_language by locales.match_localeMarkus Heiser
This patch replaces the *full of magic* ``utils.match_language`` function by a ``locales.match_locale``. The ``locales.match_locale`` function is based on the ``locales.build_engine_locales`` introduced in 9ae409a0 [1]. In the past SearXNG did only support a search by a language but not in a region. This has been changed a long time ago and regions have been added to SearXNG core but not to the engines. The ``utils.match_language`` was the function to handle the different aspects of language/regions in SearXNG core and the supported *languages* in the engine. The ``utils.match_language`` did it with some magic and works good for most use cases but fails in some edge case. To replace the concurrence of languages and regions in the SearXNG core the ``locales.build_engine_locales`` was introduced in 9ae409a0 [1]. With the last patches all engines has been migrated to a ``fetch_traits`` and a language/region concept that is based on ``locales.build_engine_locales``. To summarize: there is no longer a need for the ``locales.match_language``. [1] https://github.com/searxng/searxng/pull/1652 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-03-24[mod] remove obsolete EngineTraits.supported_languagesMarkus Heiser
All engines has been migrated from ``supported_languages`` to the ``fetch_traits`` concept. There is no longer a need for the obsolete code that implements the ``supported_languages`` concept. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-03-24[mod] replace searx.languages by searx.sxng_localesMarkus Heiser
With the language and region tags from the EngineTraitsMap the handling of SearXNG's tags of languages and regions has been normalized and is no longer a *mystery*. The "languages" became "locales" that are supported by babel and by this, the update_engine_traits.py can be simplified a lot. Other code places can be simplified as well, but these simplifications should (respectively can) only be done when none of the engines work with the deprecated EngineTraits.supported_languages interface anymore. This commit replaces searx.languages by searx.sxng_locales and fix the naming of some names from "language" to "locale" (e.g. language_codes --> sxng_locales). Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-03-24[mod] replace engines_languages.json by engines_traits.jsonMarkus Heiser
Implementations of the *traits* of the engines. Engine's traits are fetched from the origin engine and stored in a JSON file in the *data folder*. Most often traits are languages and region codes and their mapping from SearXNG's representation to the representation in the origin search engine. To load traits from the persistence:: searx.enginelib.traits.EngineTraitsMap.from_data() For new traits new properties can be added to the class:: searx.enginelib.traits.EngineTraits .. hint:: Implementation is downward compatible to the deprecated *supported_languages method* from the vintage implementation. The vintage code is tagged as *deprecated* an can be removed when all engines has been ported to the *traits method*. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-02-17Add "Auto-detected" as a language.Alexandre Flament
When the user choose "Auto-detected", the choice remains on the following queries. The detected language is displayed. For example "Auto-detected (en)": * the next query language is going to be auto detected * for the current query, the detected language is English. This replace the autodetect_search_language plugin.
2023-02-10[fix] time_range in HTML form should not be a string 'None'Markus Heiser
Before this patch SearXNG returns 'time_range': 'None':: <form method="GET" action="/searx/search"> ... <input type="hidden" name="time_range" value="None"> ... </form> Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-02-10[mod] make python code pylint 2.16.1 compliantMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-01-20Bump flask-babel from 2.0.0 to 3.0.0dependabot[bot]
Bumps [flask-babel](https://github.com/python-babel/flask-babel) from 2.0.0 to 3.0.0. - [Release notes](https://github.com/python-babel/flask-babel/releases) - [Changelog](https://github.com/python-babel/flask-babel/blob/master/CHANGELOG) - [Commits](https://github.com/python-babel/flask-babel/compare/v2.0.0...v3.0.0) --- updated-dependencies: - dependency-name: flask-babel dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
2022-12-10move searx.shared.redisdb to searx.redisdbAlexandre Flament
2022-11-05The checker requires RedisAlexandre Flament
Remove the abstraction in searx.shared.SharedDict. Implement a basic and dedicated scheduler for the checker using a Redis script.
2022-10-14searx.network: add "verify" option to the networksAlexandre Flament
Each network can define a verify option: * false to disable certificate verification * a path to existing certificate. SearXNG uses SSL_CERT_FILE and SSL_CERT_DIR when they are defined see https://www.python-httpx.org/environment_variables/#ssl_cert_file
2022-09-27[fix] typos / reported by @kianmeng in searx PR-3366Markus Heiser
[PR-3366] https://github.com/searx/searx/pull/3366 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-09-24[mod] paper.html: add links to doi resolverMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-09-23[mod] science category: various update of about PR 1705Alexandre Flament
2022-09-23Add searx.webutils.searxng_format_dateAlexandre FLAMENT
* Move the datetime to str code from searx.webapp.search to searx.webutils.searxng_format_date * When the month, day, hour, day and second are zero, the function returns only the year.
2022-09-04Merge pull request #1743 from dalf/update_about_metricsAlexandre Flament
Update about the metrics
2022-09-04[mod] option 'ui: cache_url:' to configure internet cache or archiveMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-09-02template: when enable_metrics are disabled, hide the empty statsAlexandre FLAMENT
when metrics are disabled: * hide the link to /stats at the bottom of the pages * in /preferences, hide the columns "Response time" and "Reliability"