Searxng Frequent Sites
This revision is from 2024/08/11 18:23. You can Restore it.
templates/simple/index.html
{% extends "simple/base.html" %}
{% from 'simple/icons.html' import icon_big %}
{% block content %}
<div class="index">
<div class="title"><h1>SearXNG</h1></div>
{% include 'simple/simple_search.html' %}
{% if most_visited_sites %}
<div class="top-sites">
<div class="site-grid" style="margin-top: 33px; max-width: 60%; margin-left: auto; margin-right: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px;">
{% for site in most_visited_sites %}
<a href="{{ site.url }}" class="site-tile">
<img src="{{ site.favicon }}" alt="{{ site.title }} favicon" width="32">
</a>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endblock %}
/searx/preferences.py:482
self.key_value_settings['custom_text'] = StringSetting(
'', locked=is_locked('custom_text')
)
/templates/simple/preferences.html
{{- tab_header('maintab', 'quicklinks', _('Quick Links')) -}}
{%- include 'simple/preferences/quicklinks.html' -%}
{{- tab_footer() -}}
/searx/webapp.py
def get_most_visited_sites(request, limit=50):
sites = []
custom_text = request.preferences.get_value('custom_text')
print(f"Cookie value: {custom_text}") # Debugging: check the cookie value
if custom_text:
# Split the cookie value by newlines instead of commas
for entry in custom_text.splitlines():
parts = entry.strip().split('|')
if len(parts) == 3:
sites.append({
"url": parts[0],
"title": parts[1],
"favicon": parts[2]
})
print(f"Parsed sites: {sites}") # Debugging: check the parsed list
return sites[:limit]
/searx/webapp.py
@app.route('/', methods=['GET', 'POST'])
def index():
if request.form.get('q'):
query = ('?' + request.query_string.decode()) if request.query_string else ''
return redirect(url_for('search') + query, 308)
if request.method == 'POST':
new_url = request.form.get('new_url')
new_title = request.form.get('new_title')
if new_url and new_title:
add_new_site(new_url, new_title)
most_visited_sites = get_most_visited_sites(request, limit=50)
return render(
'index.html',
selected_categories=get_selected_categories(request.preferences, request.form),
current_locale=request.preferences.get_value("locale"),
most_visited_sites=most_visited_sites
)
/searx/webapp.py:404
kwargs['custom_text'] = request.preferences.get_value('custom_text')
/searx/preferences.py:478
self.key_value_settings['custom_text'] = StringSetting(
'', locked=is_locked('custom_text')
)