Menu
Home
About
Our Role
Goals
The Team
Roadmap
Tokenomics
How To Buy
Knowledge Base
Contacts
Sitemap & Links
A.I.
Chart
Shop
IMMORTALITY
🏠
⬇️
Add Commonly Visited sites to SearXNG homepage
New name
B
I
U
S
link
image
code
HTML
list
Show page
Syntax
Looks for a text file: most_visited_sites.txt in the searx directory with contents... https://imtcoin.com|Immortality|https://imtcoin.com/favicon.ico {pre} touch /usr/local/searxng/searxng-src/searx/most_visited_sites.txt {/pre} Make sure it has the write permsissions to add new sites and if something goes wrong you will have to manually edit the file. /usr/local/searxng/searxng-src/searx/webapp.py {pre} def get_most_visited_sites(limit=50): sites = [] file_path = os.path.join(os.path.dirname(__file__), 'most_visited_sites.txt') try: with open(file_path, 'r') as file: for line in file: parts = line.strip().split('|') if len(parts) == 3: sites.append({ "url": parts[0], "title": parts[1], "favicon": parts[2] }) except FileNotFoundError: print(f"Warning: {file_path} not found.") return sites[:limit] def add_new_site(url, title): file_path = os.path.join(os.path.dirname(__file__), 'most_visited_sites.txt') favicon = f"{url}/favicon.ico" with open(file_path, 'a') as file: file.write(f"{url}|{title}|{favicon}\n") @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(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 ) {/pre} /usr/local/searxng/searxng-src/searx/templates/index.html {pre} {% 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: 50%; margin-left: auto; margin-right: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 10px;"> {% 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 %} <button id="toggleAddSiteForm" class="toggle-button" style="margin-top: 40px">Add New Site</button> <div id="addSiteForm" class="add-site-form" style="display: none; padding: 40px;"> <form method="post"> <input type="url" name="new_url" placeholder="https://example.com" required> <input type="text" name="new_title" placeholder="Site Title" required> <button type="submit">Add Site</button> </form> </div> </div> <script> document.getElementById('toggleAddSiteForm').addEventListener('click', function() { var form = document.getElementById('addSiteForm'); if (form.style.display === 'none') { form.style.display = 'block'; this.textContent = 'Hide Add Site Form'; } else { form.style.display = 'none'; this.textContent = 'Add New Site'; } }); </script> {% endblock %} {/pre}
Password
Summary of changes
📜
⏱️
⬆️