Commit ede69396 authored by Arnau Vàzquez's avatar Arnau Vàzquez
Browse files

Merge branch '60-rename-theme' into 'master'

Renaming theme, folder name and templates

Closes #60

See merge request e/cloud/my-spot!64
parents dfc5b6c3 b4f58da3
{% extends "eelo/base.html" %}
{% extends "etheme/base.html" %}
{% block content %}
{% if errors %}
{% from 'eelo/macros.html' import errors_panel %}
{% from 'etheme/macros.html' import errors_panel %}
<div class="content-small-centered">
{{ errors_panel(errors, error_details) }}
</div>
......@@ -11,6 +11,6 @@
<div id="index">
<img src="{{ url_for('static', filename='img/logo_searx_a.png') }}" alt="searx logo" />
<img id="logo_inline" src="{{ url_for('static', filename='img/logo_searx_a.png') }}" alt="e logo" />
{% include 'eelo/components/search.html' %}
{% include 'etheme/components/search.html' %}
</div>
{% endblock %}
......@@ -10,7 +10,7 @@
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" id="search_form" {% if inline %}class="inline-search" {% endif %} role="search">
<div id="search_input_container" {% if rtl -%} class="rtl" {%- endif %}>
{% if inline %}
<a href="{{ url_for('index') }}" id="logo_link"><img src="{{ url_for('static', filename='themes/eelo/img/logo.png') }}" alt="" id="logo"></a>
<a href="{{ url_for('index') }}" id="logo_link"><img src="{{ url_for('static', filename='themes/etheme/img/logo.png') }}" alt="" id="logo"></a>
{% endif %}
<input type="search" name="q" class="form-control" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ value }}" {% if autofocus %}autofocus{% endif %}>
<button type="submit">{{ icon('search') }}</button>
......@@ -27,7 +27,7 @@
<!-- Draw favicon -->
{% macro draw_favicon(favicon) -%}
<img width="32" height="32" class="favicon" src="{{ url_for('static', filename='themes/eelo/img/icons/' + favicon + '.png') }}" alt="{{ favicon }}" />
<img width="32" height="32" class="favicon" src="{{ url_for('static', filename='themes/etheme/img/icons/' + favicon + '.png') }}" alt="{{ favicon }}" />
{%- endmacro %}
{%- macro result_link(url, title, classes='') -%}
......
{% from 'eelo/macros.html' import icon %}
{% from 'etheme/macros.html' import icon %}
<div class="alert alert-success fade in" role="alert">
<button class="close" data-dismiss="alert" type="button">
<span aria-hidden="true">×</span>
......
{% from 'eelo/macros.html' import icon %}
{% from 'etheme/macros.html' import icon %}
<div class="alert alert-danger fade in" role="alert">
<button class="close" data-dismiss="alert" type="button">
<span aria-hidden="true">×</span>
......
{% from 'eelo/macros.html' import checkbox_toggle, support_toggle %}
{% extends "eelo/base.html" %}
{% from 'etheme/macros.html' import checkbox_toggle, support_toggle %}
{% extends "etheme/base.html" %}
{% block title %}{{ _('preferences') }} - {% endblock %}
{% block content %}
......@@ -29,7 +29,7 @@
{% set language_label = _('Search language') %}
{% set language_info = _('What language do you prefer for search?') %}
{% call preferences_item(language_info, language_label, rtl) %}
{% include 'eelo/components/languages.html' %}
{% include 'etheme/components/languages.html' %}
{% endcall %}
{% set locale_label = _('Interface language') %}
......@@ -76,8 +76,8 @@
{% set theme_info = _('Change searx layout') %}
{% call preferences_item(theme_info, theme_label, rtl) %}
<select class="form-control custom-select" name="theme">
{% for name in themes %}
<option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
{% for t in themes %}
<option value="{{ t }}" {% if t == theme %}selected="selected"{% endif %}>{{ themes[t] }}</option>
{% endfor %}
</select>
{% endcall %}
......@@ -184,7 +184,7 @@
{% endfor %}
</ul>
{% else %}
{% include 'eelo/messages/no_cookies.html' %}
{% include 'etheme/messages/no_cookies.html' %}
{% endif %}
</section>
</div> <!-- End Advanced Tab -->
......@@ -210,7 +210,7 @@
<div id="info">
{% if errors %}
{% from 'eelo/macros.html' import errors_panel %}
{% from 'etheme/macros.html' import errors_panel %}
{{ errors_panel(errors) }}
{% endif %}
......
{% extends "eelo/base.html" %}
{% extends "etheme/base.html" %}
{% block title %}{{ _('Privacy policy') }} - {% endblock %}
......
{% from 'eelo/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
{% from 'etheme/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
{{ result_header(result, favicons) }}
{% call result_sub_header(result) %}
......
{% from 'eelo/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon with context %}
{% from 'etheme/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon with context %}
{{ result_header(result, favicons) }}
{% call result_sub_header(result) %}
......
{% from 'eelo/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
{% from 'etheme/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
{{ result_header(result, favicons) }}
{{ result_sub_header(result) }}
......
{% from 'eelo/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, result_link, icon, format_filesize %}
{% from 'etheme/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, result_link, icon, format_filesize %}
{{ result_header(result, favicons) }}
{% call result_sub_header(result) %}
......
{% from 'eelo/macros.html' import result_header, result_engine, result_sub_header, format_filesize%}
{% from 'etheme/macros.html' import result_header, result_engine, result_sub_header, format_filesize%}
<div class="result-content">
<a class="thumbnail" href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>
......
{% from 'eelo/macros.html' import result_header, result_engine, result_sub_header%}
{% from 'etheme/macros.html' import result_header, result_engine, result_sub_header%}
<div class="result-content">
<a class="thumbnail" href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>
......
{% extends "eelo/base.html" %}
{% from "eelo/macros.html" import search_link %}
{% extends "etheme/base.html" %}
{% from "etheme/macros.html" import search_link %}
{%- macro search_url() %}{{ base_url }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}{% if time_range %}&amp;time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&amp;language={{ current_language }}{% endif %}{% endmacro -%}
......@@ -8,7 +8,7 @@
{% block content %}
<div id="search_bar_area">
{% include 'eelo/components/search_full.html' %}
{% include 'etheme/components/search_full.html' %}
</div>
{% set use_gallery_layout = 'images' in selected_categories or 'videos' in selected_categories %}
......@@ -34,7 +34,7 @@
{% endif %}
{% if not results and not answers %}
{% include 'eelo/messages/no_results.html' %}
{% include 'etheme/messages/no_results.html' %}
{% else %}
......@@ -52,12 +52,12 @@
{% if result.template %}
{# Torrents presented in a gallery like layout are different than the regular layout #}
{% if template == "torrent" and 'videos' in selected_categories %}
{% include get_result_template('eelo', 'video_torrent.html') %}
{% include get_result_template('etheme', 'video_torrent.html') %}
{% else %}
{% include get_result_template('eelo', result['template']) %}
{% include get_result_template('etheme', result['template']) %}
{% endif %}
{% else %}
{% include 'eelo/result_templates/default.html' %}
{% include 'etheme/result_templates/default.html' %}
{% endif %}
</div>
{% endif %}
......@@ -115,13 +115,13 @@
<div>
{% if errors %}
{% from 'eelo/macros.html' import errors_panel %}
{% from 'etheme/macros.html' import errors_panel %}
{{ errors_panel(errors) }}
{% endif %}
{% if infoboxes %}
{% for infobox in infoboxes %}
{% include 'eelo/components/infobox.html' %}
{% include 'etheme/components/infobox.html' %}
{% endfor %}
{% endif %}
......
......@@ -122,8 +122,8 @@
{% set theme_info = _('Change searx layout') %}
{{ preferences_item_header(theme_info, theme_label, rtl, 'theme') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="theme" id="theme">
{% for name in themes %}
<option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
{% for t in themes %}
<option value="{{ t }}" {% if t == theme %}selected="selected"{% endif %}>{{ themes[t] }}</option>
{% endfor %}
</select>
{{ preferences_item_footer(theme_info, theme_label, rtl) }}
......
......@@ -168,8 +168,8 @@
<legend>{{ _('Themes') }}</legend>
<p class="value">
<select name="theme">
{%- for name in themes -%}
<option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
{%- for t in themes -%}
<option value="{{ t }}" {% if t == theme %}selected="selected"{% endif %}>{{ themes[t] }}</option>
{%- endfor -%}
</select>
</p>
......
......@@ -63,8 +63,8 @@ from searx.engines import (
categories, engines, engine_shortcuts, get_engines_stats
)
from searx.webutils import (
UnicodeWriter, highlight_content, get_resources_directory,
get_static_files, get_result_templates, get_themes,
UnicodeWriter, get_themes, highlight_content, get_resources_directory,
get_static_files, get_result_templates, get_themes_folder_name,
prettify_url, new_hmac, is_flask_run_cmdline
)
from searx.webadapter import get_search_query_from_webapp, get_selected_categories
......@@ -101,10 +101,11 @@ static_files = get_static_files(static_path)
default_theme = settings['ui']['default_theme']
templates_path = get_resources_directory(searx_dir, 'templates', settings['ui']['templates_path'])
logger.debug('templates directory is %s', templates_path)
themes_folder_name = get_themes_folder_name(templates_path)
themes = get_themes(templates_path)
result_templates = get_result_templates(templates_path)
global_favicons = []
for indice, theme in enumerate(themes):
for indice, theme in enumerate(themes_folder_name):
global_favicons.append([])
theme_img_path = os.path.join(static_path, 'themes', theme, 'img', 'icons')
for (dirpath, dirnames, filenames) in os.walk(theme_img_path):
......@@ -280,7 +281,7 @@ def get_base_url():
return hostname
def get_current_theme_name(override=None):
def get_current_theme_folder_name(override=None):
"""Returns theme name.
Checks in this order:
......@@ -288,10 +289,10 @@ def get_current_theme_name(override=None):
2. cookies
3. settings"""
if override and (override in themes or override == '__common__'):
if override and (override in themes_folder_name or override == '__common__'):
return override
theme_name = request.args.get('theme', request.preferences.get_value('theme'))
if theme_name not in themes:
if theme_name not in themes_folder_name:
theme_name = default_theme
return theme_name
......@@ -305,7 +306,7 @@ def get_result_template(theme, template_name):
def url_for_theme(endpoint, override_theme=None, **values):
if endpoint == 'static' and values.get('filename'):
theme_name = get_current_theme_name(override=override_theme)
theme_name = get_current_theme_folder_name(override=override_theme)
filename_with_theme = "themes/{}/{}".format(theme_name, values['filename'])
if filename_with_theme in static_files:
values['filename'] = filename_with_theme
......@@ -414,7 +415,7 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['get_result_template'] = get_result_template
kwargs['theme'] = get_current_theme_name(override=override_theme)
kwargs['theme'] = get_current_theme_folder_name(override=override_theme)
kwargs['template_name'] = template_name
......@@ -464,7 +465,7 @@ def pre_request():
request.timings = []
request.errors = []
preferences = Preferences(themes, list(categories.keys()), engines, plugins)
preferences = Preferences(themes_folder_name, list(categories.keys()), engines, plugins)
user_agent = request.headers.get('User-Agent', '').lower()
if 'webkit' in user_agent and 'android' in user_agent:
preferences.key_value_settings['method'].value = 'GET'
......@@ -749,8 +750,8 @@ def search():
LANGUAGE_CODES,
fallback=request.preferences.get_value("language")),
base_url=get_base_url(),
theme=get_current_theme_name(),
favicons=global_favicons[themes.index(get_current_theme_name())],
theme=get_current_theme_folder_name(),
favicons=global_favicons[themes_folder_name.index(get_current_theme_folder_name())],
timeout_limit=request.form.get('timeout_limit', None)
)
......@@ -884,7 +885,7 @@ def preferences():
doi_resolvers=settings['doi_resolvers'],
current_doi_resolver=get_doi_resolver(request.args, request.preferences.get_value('doi_resolver')),
allowed_plugins=allowed_plugins,
theme=get_current_theme_name(),
theme=get_current_theme_folder_name(),
preferences_url_params=request.preferences.get_as_url_params(),
base_url=get_base_url(),
locked_preferences=locked_preferences,
......@@ -1030,7 +1031,7 @@ def favicon():
return send_from_directory(os.path.join(app.root_path,
static_path,
'themes',
get_current_theme_name(),
get_current_theme_folder_name(),
'img'),
'favicon.png',
mimetype='image/vnd.microsoft.icon')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment