Hacking searx
This revision is from 2024/08/06 23:56. You can Restore it.
In no specific order...
I want to add a new checkbox for the custom_option. I direct preferences.html to the the preferences folder and then add a new template for the option.
Update the preferences UI: searx/templates/preferences/custom_option.html, simply copy center_alignment.html and rename it to custom_option.html for this exercise.
<fieldset>{{- '' -}}
<legend id="pref_custom_option">{{ _('Custom Option Language') }}</legend>{{- '' -}}
<p class="value">{{- '' -}}
<input type="checkbox" {{- ' ' -}}
name="custom_option" {{- ' ' -}}
aria-labelledby="pref_custom_option" {{- ' ' -}}
class="checkbox-onoff" {{- ' ' -}}
{%- if preferences.get_value('center_alignment') -%}
checked
{%- endif -%}{{- ' ' -}}
/>{{- '' -}}
</p>{{- '' -}}
<div class="description">
{{- _('Displays my cock (Oscar layout).') -}}
</div>{{- '' -}}
</fieldset>{{- '' -}}
Add the custom template to preferences.html: searx/templates/preferences.html, for example line 197 slot in...
{%- if 'custom_option' not in locked_preferences -%}
{%- include 'simple/preferences/custom_option.html' -%}
{%- endif -%}
Open searx/preferences.py and add a new preference say on line 450
'custom_option': BooleanSetting(
settings['ui']['custom_option'],
locked=is_locked('custom_option')
),
Find the place to install it... for instance, searx/search/search.py
Find the function where search results are processed (e.g., _get_search_result_container).
Add logic...
def _get_search_result_container(self, request, selected_engines):
if request.preferences['test_option']:
results.append({'title': 'Test Output', 'content': 'this is a test'})