[mod] enable calculator and allow plugin on public instances

Remove quirks that prevented the Calculator from being used on public instances.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2024-05-30 14:03:25 +02:00 committed by Markus Heiser
parent 3a3ff8f020
commit b774ee04ba
3 changed files with 3 additions and 11 deletions

View file

@ -7,13 +7,12 @@ import operator
from multiprocessing import Process, Queue from multiprocessing import Process, Queue
from flask_babel import gettext from flask_babel import gettext
from searx import settings
from searx.plugins import logger from searx.plugins import logger
name = "Basic Calculator" name = "Basic Calculator"
description = gettext("Calculate mathematical expressions via the search bar") description = gettext("Calculate mathematical expressions via the search bar")
default_on = False default_on = True
preference_section = 'general' preference_section = 'general'
plugin_id = 'calculator' plugin_id = 'calculator'
@ -81,9 +80,6 @@ def timeout_func(timeout, func, *args, **kwargs):
def post_search(_request, search): def post_search(_request, search):
# don't run on public instances due to possible attack surfaces
if settings['server']['public_instance']:
return True
# only show the result of the expression on the first page # only show the result of the expression on the first page
if search.search_query.pageno > 1: if search.search_query.pageno > 1:
@ -113,7 +109,3 @@ def post_search(_request, search):
if result != query: if result != query:
search.result_container.answers['calculate'] = {'answer': f"{query} = {result}"} search.result_container.answers['calculate'] = {'answer': f"{query} = {result}"}
return True return True
def is_allowed():
return not settings['server']['public_instance']

View file

@ -219,13 +219,13 @@ outgoing:
# #
# enabled_plugins: # enabled_plugins:
# # these plugins are enabled if nothing is configured .. # # these plugins are enabled if nothing is configured ..
# - 'Basic Calculator'
# - 'Hash plugin' # - 'Hash plugin'
# - 'Self Information' # - 'Self Information'
# - 'Tracker URL remover' # - 'Tracker URL remover'
# - 'Ahmia blacklist' # activation depends on outgoing.using_tor_proxy # - 'Ahmia blacklist' # activation depends on outgoing.using_tor_proxy
# # these plugins are disabled if nothing is configured .. # # these plugins are disabled if nothing is configured ..
# - 'Hostnames plugin' # see 'hostnames' configuration below # - 'Hostnames plugin' # see 'hostnames' configuration below
# - 'Basic Calculator'
# - 'Open Access DOI rewrite' # - 'Open Access DOI rewrite'
# - 'Tor check plugin' # - 'Tor check plugin'
# # Read the docs before activate: auto-detection of the language could be # # Read the docs before activate: auto-detection of the language could be

View file

@ -38,7 +38,7 @@
{%- macro plugin_preferences(section) -%} {%- macro plugin_preferences(section) -%}
{%- for plugin in plugins -%} {%- for plugin in plugins -%}
{%- if plugin.preference_section == section and (plugin.is_allowed() if plugin.is_allowed else True) -%} {%- if plugin.preference_section == section -%}
<fieldset>{{- '' -}} <fieldset>{{- '' -}}
<legend>{{ _(plugin.name) }}</legend>{{- '' -}} <legend>{{ _(plugin.name) }}</legend>{{- '' -}}
<div class="value"> <div class="value">