diff options
author | Alexandre Flament <alex@al-f.net> | 2017-02-12 15:06:01 +0100 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2017-08-06 16:04:21 +0200 |
commit | 10a24bdc2c3870f07ec62dd710841628d325aaf6 (patch) | |
tree | 400b579adb6268092f21ec21621a16c730cfef41 /searx/templates | |
parent | 4f6586d8085460c368ad16904685199de630e1c8 (diff) | |
download | searxng-10a24bdc2c3870f07ec62dd710841628d325aaf6.tar.gz searxng-10a24bdc2c3870f07ec62dd710841628d325aaf6.zip |
[enh] add simple theme (WIP)
Diffstat (limited to 'searx/templates')
21 files changed, 818 insertions, 1 deletions
diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index 49f67bcd8..afb389e44 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -171,7 +171,7 @@ {{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }} </td> <th>{{ search_engine.name }}</th> - <td>{{ shortcuts[search_engine.name] }}</td> + <td class="name">{{ shortcuts[search_engine.name] }}</td> <td><input type="checkbox" {{ "checked" if current_language == 'all' or current_language in search_engine.supported_languages or current_language.split('-')[0] in search_engine.supported_languages else ""}} readonly="readonly" disabled="disabled"></td> <td><input type="checkbox" {{ "checked" if search_engine.safesearch==True else ""}} readonly="readonly" disabled="disabled"></td> <td><input type="checkbox" {{ "checked" if search_engine.time_range_support==True else ""}} readonly="readonly" disabled="disabled"></td> diff --git a/searx/templates/simple/404.html b/searx/templates/simple/404.html new file mode 100644 index 000000000..1843c9892 --- /dev/null +++ b/searx/templates/simple/404.html @@ -0,0 +1,9 @@ +{% extends "simple/base.html" %} +{% block content %} +<div class="center"> + <h1>{{ _('Page not found') }}</h1> + {% autoescape false %} + <p>{{ _('Go to %(search_page)s.', search_page='<a href="{}">{}</a>'.decode('utf-8').format(url_for('index'), _('search page'))) }}</p> + {% endautoescape %} +</div> +{% endblock %} diff --git a/searx/templates/simple/about.html b/searx/templates/simple/about.html new file mode 100644 index 000000000..1913879da --- /dev/null +++ b/searx/templates/simple/about.html @@ -0,0 +1,4 @@ +{% extends 'simple/base.html' %} +{% block content %} +{% include '__common__/about.html' %} +{% endblock %} diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html new file mode 100644 index 000000000..0003f113e --- /dev/null +++ b/searx/templates/simple/base.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<html class="no-js" lang="en" {% if rtl %} dir="rtl"{% endif %}> +<head> + <meta charset="UTF-8" /> + <meta name="description" content="searx - a privacy-respecting, hackable metasearch engine"> + <meta name="keywords" content="searx, search, search engine, metasearch, meta search"> + <meta name="generator" content="searx/{{ searx_version }}"> + <meta name="referrer" content="no-referrer"> + <meta name="robots" content="noarchive"> + <meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=1"> + <meta name="HandheldFriendly" content="True"> + <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"> + <title>{% block title %}{% endblock %}searx</title> + {% if rtl %} + <link rel="stylesheet" href="{{ url_for('static', filename='css/searx-rtl.min.css') }}" type="text/css" media="screen" /> + {% else %} + <link rel="stylesheet" href="{{ url_for('static', filename='css/searx.min.css') }}" type="text/css" media="screen" /> + {% endif %} + {% block styles %}{% endblock %} + {% block meta %}{% endblock %} + {% block head %} + <link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/> + {% endblock %} + <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" /> + <script type="text/javascript"> + var searx = { + autocompleter: {% if autocomplete %}true{% else %}false{% endif %}, + method: "{{ method or 'POST' }}", + touch: (("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch) || false, + staticPath: "{{ url_for('static', filename='themes/simple') }}/", + noItemFound: "{{ _('No item found') }}", + search_on_category_select: {{ 'true' if 'plugins/js/search_on_category_select.js' in scripts else 'false'}}, + infinite_scroll: {{ 'true' if 'plugins/js/infinite_scroll.js' in scripts else 'false' }} + }; + document.getElementsByTagName("html")[0].className = (searx.touch)?"js touch":"js"; + </script> +</head> +<body> + <main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}"> + {% if errors %} + <div class="dialog-error" role="alert"> + <a href="#" class="close" aria-label="close" title="close">×</a> + <ul> + {% for message in errors %} + <li>{{ message }}</li> + {% endfor %} + </ul> + </div> + {% endif %} + + {% block content %} + {% endblock %} + </main> + <footer> + <p>{{ _('Powered by') }} <a href="{{ url_for('about') }}">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}</p> + </footer> + <!--[if gte IE 9]>--> + <script src="{{ url_for('static', filename='js/searx.min.js') }}" ></script> + <!--<![endif]--> +</body> +</html> diff --git a/searx/templates/simple/categories.html b/searx/templates/simple/categories.html new file mode 100644 index 000000000..127d55b2b --- /dev/null +++ b/searx/templates/simple/categories.html @@ -0,0 +1,8 @@ +<div id="categories">{{- '' -}} + <div id="categories_container"> + {%- for category in categories -%} + <div class="category"><input type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}"{% if category in selected_categories %} checked="checked"{% endif %}/><label for="checkbox_{{ category|replace(' ', '_') }}" class="tooltips">{{ _(category) }}</label></div> + {%- endfor -%} + {%- if display_tooltip %}<div class="help">{{ _('Click on the magnifier to perform search') }}</div>{% endif -%} + </div>{{- '' -}} +</div> diff --git a/searx/templates/simple/index.html b/searx/templates/simple/index.html new file mode 100644 index 000000000..4e8e76cce --- /dev/null +++ b/searx/templates/simple/index.html @@ -0,0 +1,12 @@ +{% extends "simple/base.html" %} +{% from 'simple/macros.html' import icon %} +{% block meta %} + <link rel="preload" href="{{ url_for('static', filename='img/searx.png') }}" as="image" /> +{% endblock %} +{% block content %} +<nav id="linkto_preferences"><a href="{{ url_for('preferences') }}">{{ icon('navicon-round') }}</a></nav> +<div class="index"> + <div class="title"><h1>searx</h1></div> + {% include 'simple/search.html' %} +</div> +{% endblock %} diff --git a/searx/templates/simple/infobox.html b/searx/templates/simple/infobox.html new file mode 100644 index 000000000..d99806ac4 --- /dev/null +++ b/searx/templates/simple/infobox.html @@ -0,0 +1,46 @@ +<aside class="infobox"> + <h2><bdi>{{ infobox.infobox }}</bdi></h2> + {% if infobox.img_src %}<img src="{{ image_proxify(infobox.img_src) }}" title="{{ infobox.infobox|striptags }}" alt="{{ infobox.infobox|striptags }}" />{% endif %} + <p><bdi>{{ infobox.entity }}</bdi></p> + <p><bdi>{{ infobox.content | safe }}</bdi></p> + {% if infobox.attributes %} + <div class="attributes"> + {% for attribute in infobox.attributes %} + <dl> + <dt><bdi>{{ attribute.label }} :</bdi></dt> + {%- if attribute.image -%} + <dd><img src="{{ image_proxify(attribute.image.src) }}" alt="{{ attribute.image.alt }}" /></dd> + {%- else -%} + <dd><bdi>{{ attribute.value }}</bdi></dd> + {%- endif -%} + </dl> + {% endfor %} + </div> + {% endif %} + + {% if infobox.urls %} + <div class="urls"> + <ul> + {%- for url in infobox.urls -%} + <li class="url"><bdi><a href="{{ url.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ url.title }}</a></bdi></li> + {%- endfor -%} + </ul> + </div> + {% endif %} + + {% if infobox.relatedTopics %} + <div class="relatedTopics"> + {% for topic in infobox.relatedTopics %} + <div> + <h3><bdi>{{ topic.name }}</bdi></h3> + {% for suggestion in topic.suggestions %} + <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> + <input type="hidden" name="q" value="{{ suggestion }}"> + <input type="submit" value="{{ suggestion }}" /> + </form> + {% endfor %} + </div> + {% endfor %} + </div> + {% endif %} +</aside> diff --git a/searx/templates/simple/languages.html b/searx/templates/simple/languages.html new file mode 100644 index 000000000..dd928ff68 --- /dev/null +++ b/searx/templates/simple/languages.html @@ -0,0 +1,8 @@ +<select class="language" id="language" name="language" tabindex="2">{{- '' -}} + <option value="all" {% if current_language == 'all' %}selected="selected"{% endif %}>{{ _('Default language') }}</option> + {%- for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) -%} + <option value="{{ lang_id }}" {% if lang_id == current_language %}selected="selected"{% endif %}> + {{- lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id -}} + </option> + {%- endfor -%} +</select> diff --git a/searx/templates/simple/macros.html b/searx/templates/simple/macros.html new file mode 100644 index 000000000..76c53a635 --- /dev/null +++ b/searx/templates/simple/macros.html @@ -0,0 +1,86 @@ +<!-- Draw glyphicon icon from bootstrap-theme --> +{% macro icon(action) -%} + <span class="ion-icon-big ion-{{ action }}"></span> +{%- endmacro %} + +{% macro icon_small(action) -%} + <span class="ion-icon ion-{{ action }}"></span> +{%- endmacro %} + +<!-- Draw favicon --> +<!-- TODO: using url_for methode --> +{% macro draw_favicon(favicon) -%} + <img width="14" height="14" class="favicon" src="static/themes/simple/img/icons/{{ favicon }}.png" alt="{{ favicon }}" /> +{%- endmacro %} + +{% macro result_open_link(url, classes='') -%} + <a href="{{ url }}" {% if classes %}class="{{ classes }}" {% endif %}{% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}> +{%- endmacro %} + +{%- macro result_close_link() -%} + </a> +{%- endmacro %} + +{%- macro result_link(url, title, classes='') -%} + {{ result_open_link(url, classes) }}{{ title }}{{ result_close_link() }} +{%- endmacro -%} + +<!-- Draw result header --> +{% macro result_header(result, favicons, image_proxify) -%} +<article class="result {% if result['template'] %}result-{{ result.template|replace('.html', '') }}{% else %}result-default{% endif %} {% if result['category'] %}category-{{ result['category'] }}{% endif %}"> + {%- if result.img_src %}{{ result_open_link(result.url) }}<img class="image" src="{{ image_proxify(result.img_src) }}" alt="{{ result.title|striptags }}" title="{{ result.title|striptags }}" class="image" />{{ result_close_link() }}{% endif -%} + {%- if result.thumbnail %}{{ result_open_link(result.url) }}<img class="thumbnail" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/>{{ result_close_link() }}{% endif -%} + <h3>{{ result_link(result.url, result.title|safe) }}</h3> +{%- endmacro -%} + +<!-- Draw result sub header --> +{%- macro result_sub_header(result) -%} + {% if result.publishedDate %}<time class="published_date" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %} +{%- endmacro -%} + +<!-- Draw result sub footer --> +{%- macro result_sub_footer(result, proxify) -%} +<div class="engines">{% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}</div>{{- '' -}} +<p class="url"><span class="url">{{ result.pretty_url }}</span>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "cache_link") }}‎ {% if proxify %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}</p>{{- '' -}} +<div class="break"></div>{{- '' -}} +{%- endmacro -%} + +<!-- Draw result footer --> +{%- macro result_footer(result) -%} +</article> +{%- endmacro -%} + +<!-- --> +{%- macro tabs_open() -%} +<div class="tabs" role="tablist"> +{%- endmacro -%} + +{%- macro tab_header(name, id, label) -%} +<input type="radio" name="{{ name }}" id="tab_{{ id }}"/> +<label for="tab_{{ id }}" role="tab" + aria-controls="panel{{ id }}">{{ label }}</label> +<section id="tab-content{{ id }}" role="tabpanel" + aria-labelledby="{{ label }}" aria-hidden="false"> +{%- endmacro -%} + +{%- macro tab_footer() -%} +</section> +{%- endmacro -%} + +{%- macro tabs_close() -%} +</div> +{%- endmacro -%} + +{%- macro checkbox_onoff(name, checked) -%} +<div class="checkbox-onoff">{{- '' -}} + <input type="checkbox" value="None" id="{{ name }}" name="{{ name }}" {% if checked %}checked{% endif %}/>{{- '' -}} + <label for="{{ name }}"></label>{{- '' -}} +</div> +{%- endmacro -%} + +{%- macro checkbox(name, checked, readonly, disabled) -%} +<div class="checkbox">{{- '' -}} + <input type="checkbox" value="None" id="{{ name }}" name="{{ name }}" {% if checked %}checked{% endif %}{% if readonly %} readonly="readonly" {% endif %}{% if disabled %} disabled="disabled" {% endif %}/>{{- '' -}} + <label for="{{ name }}"></label>{{- '' -}} +</div> +{%- endmacro -%} diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html new file mode 100644 index 000000000..4529fea8c --- /dev/null +++ b/searx/templates/simple/preferences.html @@ -0,0 +1,190 @@ +{% from 'simple/macros.html' import tabs_open, tabs_close, tab_header, tab_footer, checkbox_onoff, checkbox %} + +{% extends "simple/base.html" %} + +{%- macro plugin_preferences(section) -%} +{%- for plugin in plugins -%} +{%- if plugin.preference_section == section -%} +<fieldset>{{- '' -}} + <legend>{{ _(plugin.name) }}</legend>{{- '' -}} + <div class="value"> + {{- checkbox_onoff('plugin_' + plugin.id, plugin.id not in allowed_plugins) -}} + </div>{{- '' -}} + <div class="description"> + {{- _(plugin.description) -}} + </div>{{- '' -}} +</fieldset> +{%- endif -%} +{%- endfor -%} +{%- endmacro -%} + +{% block head %} {% endblock %} +{% block content %} + +<a href="{{ url_for('index') }}"><h1><span>searx</span></h1></a> + +<h2>{{ _('Preferences') }}</h2> + +<form id="search_form" method="post" action="{{ url_for('preferences') }}"> + +{{ tabs_open() }} + +{{ tab_header('maintab', 'general', _('General')) }} + <fieldset> + <legend>{{ _('Default categories') }}</legend> + {% set display_tooltip = false %} + {% include 'simple/categories.html' %} + </fieldset> + <fieldset> + <legend>{{ _('Search language') }}</legend> + <p class="value">{{- '' -}} + <select name='language'>{{- '' -}} + <option value="all" {% if current_language == 'all' %}selected="selected"{% endif %}>{{ _('Default language') }}</option> + {%- for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) -%} + <option value="{{ lang_id }}" {% if lang_id == current_language %}selected="selected"{% endif %}>{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}</option> + {%- endfor -%} + </select>{{- '' -}} + </p> + <div class="description">{{ _('What language do you prefer for search?') }}</div> + </fieldset> + <fieldset> + <legend>{{ _('Autocomplete') }}</legend> + <p class="value"> + <select name="autocomplete"> + <option value=""> - </option> + {% for backend in autocomplete_backends %} + <option value="{{ backend }}" {% if backend == autocomplete %}selected="selected"{% endif %}>{{ backend }}</option> + {% endfor %} + </select> + </p> + <div class="description">{{ _('Find stuff as you type') }}</div> + </fieldset> + <fieldset> + <legend>{{ _('SafeSearch') }}</legend> + <p class="value"> + <select name='safesearch'> + <option value="2" {% if safesearch == '2' %}selected="selected"{% endif %}>{{ _('Strict') }}</option> + <option value="1" {% if safesearch == '1' %}selected="selected"{% endif %}>{{ _('Moderate') }}</option> + <option value="0" {% if safesearch == '0' %}selected="selected"{% endif %}>{{ _('None') }}</option> + </select> + </p> + <div class="description">{{ _('Filter content') }}</p> + </fieldset> + {{ plugin_preferences('general') }} + {{ tab_footer() }} + + {{ tab_header('maintab', 'engines', _('Engines')) }} + <p>{{ _('Currently used search engines') }}</p> + + {{ tabs_open() }} + {% for categ in all_categories %} + + {{ tab_header('enginetab', 'category' + categ, _(categ)) }} + <div class="scrollx"> + <table class="striped"> + <tr> + <th class="engine_checkbox">{{ _("Allow") }}</th> + <th class="name">{{ _("Engine name") }}</th> + <th class="shortcut">{{ _("Shortcut") }}</th> + <th>{{ _("Supports selected language") }}</th> + <th>{{ _("SafeSearch") }}</th> + <th>{{ _("Time range") }}</th> + <th>{{ _("Avg. time") }}</th> + <th>{{ _("Max time") }}</th> + </tr> + {% for search_engine in engines_by_category[categ] %} + + {% if not search_engine.private %} + {% set engine_id = 'engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_') %} + <tr> + <td class="engine_checkbox">{{ checkbox_onoff(engine_id, (search_engine.name, categ) in disabled_engines) }}</td> + <th class="name">{{ search_engine.name }}</th> + <td class="shortcut">{{ shortcuts[search_engine.name] }}</td> + <td>{{ checkbox(engine_id + '_supported_languages', current_language == 'all' or current_language in search_engine.supported_languages or current_language.split('-')[0] in search_engine.supported_languages, true, true) }}</td> + <td>{{ checkbox(engine_id + '_safesearch', search_engine.safesearch==True, true, true) }}</td> + <td>{{ checkbox(engine_id + '_time_range_support', search_engine.time_range_support==True, true, true) }}</td> + <td class="{{ 'danger' if stats[search_engine.name]['warn_time'] else '' }}">{{ 'N/A' if stats[search_engine.name].time==None else stats[search_engine.name].time }}</td> + <td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}</td> + </tr> + {% endif %} + {% endfor %} + </table> + <div> + {{ tab_footer() }} + {% endfor %} + {{ tabs_close() }} + {{ tab_footer() }} + + {{ tab_header('maintab', 'ui', _('User interface')) }} + <fieldset> + <legend>{{ _('Interface language') }}</legend> + <p class="value"> + <select name='locale'> + {% for locale_id,locale_name in locales.items() | sort %} + <option value="{{ locale_id }}" {% if locale_id == current_locale %}selected="selected"{% endif %}>{{ locale_name }}</option> + {% endfor %} + </select> + </p> + <div class="description">{{ _('Change the language of the layout') }}</div> + </fieldset> + <fieldset> + <legend>{{ _('Themes') }}</legend> + <p class="value"> + <select name="theme"> + {%- for name in themes -%} + <option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option> + {%- endfor -%} + </select> + </p> + <div class="description">{{ _('Change searx layout') }}</div> + </fieldset> + <fieldset> + <legend>{{ _('Results on new tabs') }}</legend> + <p class="value"> + <select name='results_on_new_tab'> + <option value="1" {% if results_on_new_tab %}selected="selected"{% endif %}>{{ _('On') }}</option> + <option value="0" {% if not results_on_new_tab %}selected="selected"{% endif %}>{{ _('Off')}}</option> + </select> + </p> + <div class="description">{{_('Open result links on new browser tabs') }}</div> + </fieldset> + {{ plugin_preferences('ui') }} + {{ tab_footer() }} + + {{ tab_header('maintab', 'privacy', _('Privacy')) }} + <fieldset> + <legend>{{ _('Method') }}</legend> + <p class="value"> + <select name='method'> + <option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option> + <option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option> + </select> + </p> + <div class="description">{{ _('Search language') }}</div> + </fieldset> + <fieldset> + <legend>{{ _('Image proxy') }}</legend> + <p class="value"> + <select name='image_proxy'> + <option value="1" {% if image_proxy %}selected="selected"{% endif %}>{{ _('Enabled') }}</option> + <option value="" {% if not image_proxy %}selected="selected"{% endif %}>{{ _('Disabled') }}</option> + </select> + </p> + <div class="description">{{ _('Proxying image results through searx') }}</div> + </fieldset> + {{ plugin_preferences('privacy') }} + {{ tab_footer() }} + + {{ tabs_close() }} + + <p class="small_font">{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }} + <br /> + {{ _("These cookies serve your sole convenience, we don't use these cookies to track you.") }} + </p> + + <input type="submit" value="{{ _('save') }}" /> + <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back"><a href="{{ url_for('clear_cookies') }}">{{ _('Reset defaults') }}</a></div> + <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back"><a href="{{ url_for('index') }}">{{ _('back') }}</a></div> + +</form> +{% endblock %} diff --git a/searx/templates/simple/result_templates/code.html b/searx/templates/simple/result_templates/code.html new file mode 100644 index 000000000..9db05311f --- /dev/null +++ b/searx/templates/simple/result_templates/code.html @@ -0,0 +1,13 @@ +{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_footer_rtl %} + +{{ result_header(result, favicons, image_proxify) -}} +{{- result_sub_header(result) -}} +{%- if result.content %}{{ result.content|safe }}{% endif %}</p> +{%- if result.repository -%} +<p class="content"><a href="{{ result.repository|safe }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.repository }}</a></p> +{%- endif -%} +<div dir="ltr" class="codelines"> + {{- result.codelines|code_highlighter(result.code_language)|safe -}} +</div>{{- '' -}} +{{- result_sub_footer(result, proxify) -}} +{{ result_footer(result) }} diff --git a/searx/templates/simple/result_templates/default.html b/searx/templates/simple/result_templates/default.html new file mode 100644 index 000000000..b29ca550f --- /dev/null +++ b/searx/templates/simple/result_templates/default.html @@ -0,0 +1,17 @@ +{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_footer_rtl %} + +{{ result_header(result, favicons, image_proxify) -}} +{{- result_sub_header(result) -}} +{% if result.embedded -%} +<p class="altlink"> • <a class="btn-collapse collapsed media-loader disabled_if_nojs" data-target="#result-media-{{ index }}" data-btn-text-collapsed="{{ _('show media') }}" data-btn-text-not-collapsed="{{ _('hide media') }}">{{ icon('music-note') }} {{ _('show media') }}</a></p> +{%- endif %} +<p class="content"> + {%- if result.content %}{{ result.content|safe }}{% endif -%} +</p> +{{- result_sub_footer(result, proxify) -}} +{% if result.embedded -%} +<div id="result-media-{{ index }}" class="invisible"> + {{- result.embedded|safe -}} +</div> +{%- endif %} +{{- result_footer(result) }} diff --git a/searx/templates/simple/result_templates/images.html b/searx/templates/simple/result_templates/images.html new file mode 100644 index 000000000..f756acbe3 --- /dev/null +++ b/searx/templates/simple/result_templates/images.html @@ -0,0 +1,4 @@ +<article class="result result-images {% if result['category'] %}category-{{ result['category'] }}{% endif %}"> + <a href="{{ result.img_src }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}><img class="image_thumbnail" src="{% if result.thumbnail_src %}{{ image_proxify(result.thumbnail_src) }}{% else %}{{ image_proxify(result.img_src) }}{% endif %}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}" /></a> + <span class="url"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %} class="small_font">{{ result.parsed_url[0] }}://{{ result.parsed_url[1] }}</a></span> +</article> diff --git a/searx/templates/simple/result_templates/map.html b/searx/templates/simple/result_templates/map.html new file mode 100644 index 000000000..1fe0c86ac --- /dev/null +++ b/searx/templates/simple/result_templates/map.html @@ -0,0 +1,71 @@ +{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_footer_rtl, icon %} + +{{ result_header(result, favicons, image_proxify) -}} +{{- result_sub_header(result) -}} + +{%- if (result.latitude and result.longitude) or result.boundingbox -%} + <small> • <a class="btn-collapse collapsed searx_init_map hide_if_nojs" data-target="#result-map-{{ index }}" data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %}>{{ icon( 'globe') }} {{ _('show map') }}</a></small> +{%- endif -%} + +{%- if result.osm and (result.osm.type and result.osm.id) -%} + <small> • <a class="btn-collapse collapsed hide_if_nojs searx_overpass_request" data-target="#result-overpass-{{ index }}" data-btn-text-collapsed="{{ _('show details') }}" data-btn-text-not-collapsed="{{ _('hide details') }}" data-osm-type="{{ result.osm.type }}" data-osm-id="{{ result.osm.id }}" data-result-table="result-overpass-table-{{ index }}" data-result-table-loadicon="result-overpass-table-loading-{{ index }}">{{ icon('location') }} {{ _('show details') }}</a></small> +{%- endif -%} +{#- +{% if (result.latitude and result.longitude) %} + <small> • <a class="btn-collapse disabled_if_nojs" data-target="#result-geodata-{{ index }}" data-btn-text-collapsed="{{ _('show geodata') }}" data-btn-text-not-collapsed="{{ _('hide geodata') }}">{{ icon('location') }} {{ _('show geodata') }}</a></small> +{% endif %} +-#} + +{%- if result.address -%} +<p itemscope itemtype="http://schema.org/PostalAddress" class="content"> + {%- if result.address.name -%} + <strong itemprop="name">{{ result.address.name }}</strong><br/> + {%- endif -%} + {% if result.address.road -%} + <span itemprop="streetAddress"> + {% if result.address.house_number %}{{ result.address.house_number }}, {% endif %} + {{ result.address.road }} + </span><br/> + {%- endif %} + {%- if result.address.locality -%} + <span itemprop="addressLocality">{{ result.address.locality }}</span> + {% if result.address.postcode %}, <span itemprop="postalCode">{{ result.address.postcode }}</span>{% endif %} + <br/> + {%- endif -%} + {%- if result.address.country -%} + <span itemprop="addressCountry">{{ result.address.country }}</span> + {%- endif -%} +</p> +{%- endif -%} + +{%- if result.content %}<p class="content">{{ result.content|safe }}</p>{% endif -%} + +{{- result_sub_footer(result, proxify) -}} + +{% if result.osm and (result.osm.type and result.osm.id) -%} + <div class="result-content invisible" id="result-overpass-{{ index }}"{% if rtl %} dir="ltr"{% endif %}> + <div id="result-overpass-table-loading-{{ index }}"><img src="{{ url_for('static', filename='img/loader.gif') }}" alt="Loading ..."/></div> + <table id="result-overpass-table-{{ index }}"> + <thead> + <tr><th>key</th><th>value</th></tr> + </thead> + <tbody> + </tbody> + </table> + </div> +{%- endif %} + +{#- +{% if (result.latitude and result.longitude) -%} + <div id="result-geodata-{{ index }}" class="invisible"> + <strong>Longitude:</strong> {{ result.longitude }} <br/> + <strong>Latitude:</strong> {{ result.latitude }} + </div> +{%- endif %} +-#} + +{% if (result.latitude and result.longitude) or result.boundingbox -%} + <div id="result-map-{{ index }}" class="invisible"><div id="osm-map-{{ index }}" style="height:300px; width:100%; margin: 10px 0;" ></div></div> +{%- endif %} + +{{- result_footer(result) }} diff --git a/searx/templates/simple/result_templates/torrent.html b/searx/templates/simple/result_templates/torrent.html new file mode 100644 index 000000000..3c7fd15e8 --- /dev/null +++ b/searx/templates/simple/result_templates/torrent.html @@ -0,0 +1,24 @@ +{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_footer_rtl, result_link %} + +{{ result_header(result, favicons, image_proxify) -}} +{{- result_sub_header(result) -}} + +{% if result.magnetlink %}<p class="altlink"> • {{ result_link(result.magnetlink, icon('magnet') + _('magnet link'), "magnetlink") }}</p>{% endif %} +{% if result.torrentfile %}<p class="altlink"> • {{ result_link(result.torrentfile, icon('download-alt') + _('torrent file'), "torrentfile") }}</p>{% endif %} + +{% if result.seed %}<p class="stat"> • {{ icon('arrow-swap') }} {{ _('Seeder') }} <span class="badge">{{ result.seed }}</span> • {{ _('Leecher') }} <span class="badge">{{ result.leech }}</span></p>{% endif %} + +{%- if result.filesize %}<p class="stat">{{ icon('floppy-disk') }} {{ _('Filesize') }}<span class="badge"> + {%- if result.filesize < 1024 %}{{ result.filesize }} {{ _('Bytes') }} + {%- elif result.filesize < 1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024) }} {{ _('kiB') }} + {%- elif result.filesize < 1024*1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024/1024) }} {{ _('MiB') }} + {%- elif result.filesize < 1024*1024*1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024) }} {{ _('GiB') }} + {%- else %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024/1024) }} {{ _('TiB') }}{% endif -%} + </span></p> +{%- endif -%} + +{%- if result.files %}<p class="stat">{{ icon('file') }} {{ _('Number of Files') }} <span class="badge">{{ result.files }}</span></p>{% endif -%} + +{%- if result.content %}<p class="content">{{ result.content|safe }}</p>{% endif -%} +{{- result_sub_footer(result, proxify) -}} +{{- result_footer(result) }} diff --git a/searx/templates/simple/result_templates/videos.html b/searx/templates/simple/result_templates/videos.html new file mode 100644 index 000000000..be270e932 --- /dev/null +++ b/searx/templates/simple/result_templates/videos.html @@ -0,0 +1,15 @@ +{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_footer_rtl %} + +{{ result_header(result, favicons, image_proxify) }} +{{ result_sub_header(result) }} +{% if result.embedded -%} +<p class="altlink"> • <a class="btn-collapse collapsed media-loader disabled_if_nojs" data-target="#result-video-{{ index }}" data-btn-text-collapsed="{{ _('show video') }}" data-btn-text-not-collapsed="{{ _('hide video') }}">{{ icon('film-outline') }} {{ _('show video') }}</a></p> +{%- endif %} +{% if result.content %}<p class="content">{{ result.content|safe }}</p>{% endif %} +{{- result_sub_footer(result, proxify) -}} +{% if result.embedded -%} +<div id="result-video-{{ index }}" class="invisible"> + {{- result.embedded|safe -}} +</div> +{%- endif %} +{{ result_footer(result) }} diff --git a/searx/templates/simple/results.html b/searx/templates/simple/results.html new file mode 100644 index 000000000..081118eaf --- /dev/null +++ b/searx/templates/simple/results.html @@ -0,0 +1,151 @@ +{% extends "simple/base.html" %} +{% from 'simple/macros.html' import icon, icon_small %} +{% block title %}{{ q|e }} - {% endblock %} +{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('index') }}?q={{ q|urlencode }}&categories={{ selected_categories|join(",") | replace(' ','+') }}&pageno={{ pageno }}&time_range={{ time_range }}&language={{ current_language }}&safesearch={{ safesearch }}&format=rss">{% endblock %} +{% block content %} +<nav id="linkto_preferences"><a href="{{ url_for('preferences') }}">{{ icon('navicon-round') }}</a></nav> +{% include 'simple/search.html' %} +<div id="results"> + {% if answers %} + <div id="answers"><h4 class="title">{{ _('Answers') }} : </h4> + {% for answer in answers -%} + <div class="answer">{{ answer }}</div> + {%- endfor %} + </div> + {% endif %} + + <div id="sidebar"> + + {% if number_of_results != '0' -%} + <p id="result_count"><small>{{ _('Number of results') }}: {{ number_of_results }}</small></p> + {%- endif %} + + {% if unresponsive_engines and results|length >= 1 %} + <div class="dialog-error" role="alert"> + <p><strong>{{ _('Error!') }}</strong> {{ _('Engines cannot retrieve results') }}:</p> + <p>{% for engine_name, error_type in unresponsive_engines %} + {{ engine_name }} ({{ error_type }}){% if not loop.last %}, {% endif %} + {% endfor %}</p> + </div> + {% endif %} + + {% if infoboxes %} + <div id="infoboxes"> + {% for infobox in infoboxes %} + {% include 'simple/infobox.html' %} + {% endfor %} + </div> + {% endif %} + + {% if suggestions %} + <div id="suggestions"> + <h4 class="title">{{ _('Suggestions') }} : </h4> + <div class="wrapper"> + {% for suggestion in suggestions %} + <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> + <input type="hidden" name="q" value="{{ suggestion }}"> + <input type="hidden" name="language" value="{{ current_language }}"> + <input type="hidden" name="safesearch" value="{{ safesearch }}"> + <input type="hidden" name="theme" value="{{ theme }}"> + <input type="submit" class="suggestion" value="• {{ suggestion }}"> + </form> + {% endfor %} + </div> + </div> + {% endif %} + + <div id="search_url"> + <h4 class="title">{{ _('Search URL') }} :</h4> + <div><pre>{{ base_url }}?q={{ q|urlencode }}&language={{ current_language }}&time_range={{ time_range }}&safesearch={{ safesearch }}{% if pageno > 1 %}&pageno={{ pageno }}{% endif %}{% if selected_categories %}&categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}</pre></div> + </div> + <div id="apis"> + <h4 class="title">{{ _('Download results') }}</h4> + {% for output_type in ('csv', 'json', 'rss') %} + <div class="left"> + <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> + <input type="hidden" name="q" value="{{ q|e }}"> + {% for category in selected_categories %} + <input type="hidden" name="category_{{ category }}" value="1"> + {% endfor %} + <input type="hidden" name="pageno" value="{{ pageno }}"> + <input type="hidden" name="time_range" value="{{ time_range }}"> + <input type="hidden" name="language" value="{{ current_language }}"> + <input type="hidden" name="safesearch" value="{{ safesearch }}"> + <input type="hidden" name="format" value="{{ output_type }}"> + <input type="submit" value="{{ output_type }}"> + </form> + </div> + {% endfor %} + </div> + </div> + + {% if corrections %} + <div id="corrections"> + <h4>{{ _('Try searching for:') }}</h4> + {% for correction in corrections %} + <div class="left"> + <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" role="navigation"> + <input type="hidden" name="q" value="{{ correction }}"> + <input type="hidden" name="time_range" value="{{ time_range }}"> + <input type="hidden" name="language" value="{{ current_language }}"> + <input type="hidden" name="safesearch" value="{{ safesearch }}"> + <input type="hidden" name="theme" value="{{ theme }}"> + <input type="submit" value="{{ correction }}"> + </form> + </div> + {% endfor %} + </div> + {% endif %} + + <div id="urls"> + {% for result in results %} + {% set index = loop.index %} + {% if result['template'] %} + {% include get_result_template('simple', result['template']) %} + {% else %} + {% include 'simple/result_templates/default.html' %} + {% endif %} + {% endfor %} + {% if not results and not answers %} + {% include 'simple/messages/no_results.html' %} + {% endif %} + </div> + <div id="backToTop"> + <a href="#">{{ icon_small('chevron-up') }}</a> + </div> + {% if paging %} + <nav id="pagination"> + {% if pageno > 1 %} + <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> + <div class="{% if rtl %}right{% else %}left{% endif %}"> + <input type="hidden" name="q" value="{{ q|e }}" > + {% for category in selected_categories %} + <input type="hidden" name="category_{{ category }}" value="1" > + {% endfor %} + <input type="hidden" name="pageno" value="{{ pageno-1 }}" > + <input type="hidden" name="time_range" value="{{ time_range }}" > + <input type="hidden" name="language" value="{{ current_language }}" > + <input type="hidden" name="safesearch" value="{{ safesearch }}" > + <input type="hidden" name="theme" value="{{ theme }}" > + <button type="submit">{{ icon_small('chevron-left') }} {{ _('previous page') }}</button> + </div> + </form> + {% endif %} + <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> + <div class="{% if rtl %}left{% else %}right{% endif %}"> + <input type="hidden" name="q" value="{{ q|e }}" > + {% for category in selected_categories %} + <input type="hidden" name="category_{{ category }}" value="1" > + {% endfor %} + <input type="hidden" name="pageno" value="{{ pageno+1 }}" > + <input type="hidden" name="time_range" value="{{ time_range }}" > + <input type="hidden" name="language" value="{{ current_language }}" > + <input type="hidden" name="safesearch" value="{{ safesearch }}" > + <input type="hidden" name="theme" value="{{ theme }}" > + <button type="submit">{{ _('next page') }} {{ icon_small('chevron-right') }}</button> + </div> + </form> + </nav> + {% endif %} +</div> +{% endblock %} diff --git a/searx/templates/simple/search.html b/searx/templates/simple/search.html new file mode 100644 index 000000000..3f48d7fcd --- /dev/null +++ b/searx/templates/simple/search.html @@ -0,0 +1,16 @@ +<form id="search" method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> + <div id="search_wrapper"> + <div class="search_box"> + <input id="q" name="q" type="text" placeholder="{{ _('Search for...') }}" tabindex="1" autocomplete="off" spellcheck="false" dir="auto" {% if q %}value="{{ q }}"{% endif %} > + <button id="send_search" type="submit" tabindex="-1"><span class="hide_if_nojs">{{ icon('search') }}</span><span class="show_if_nojs">{{ _('Start search') }}</span></button> + </div> + <div class="search_filters"> + {% include 'simple/languages.html' %} + {% include 'simple/time-range.html' %} + </div> + </div> + {% set display_tooltip = true %} + {% include 'simple/categories.html' %} + <input type="hidden" name="safesearch" value="{{ safesearch }}" > + <input type="hidden" name="theme" value="{{ theme }}" > +</form> diff --git a/searx/templates/simple/simple.spec.txt b/searx/templates/simple/simple.spec.txt new file mode 100644 index 000000000..a9724f8ef --- /dev/null +++ b/searx/templates/simple/simple.spec.txt @@ -0,0 +1,40 @@ +#container + .search + #search_form + +#results + + #sidebar + #result-count + .title + .content + + .infobox + h2 + img + p + div#attributes + table + tbody + tr + td + td + div#urls + ul + li + + #suggestions + .title + .suggestion + + #search_url + .title + input + + #apis + .title + .api-link + + .result + + diff --git a/searx/templates/simple/stats.html b/searx/templates/simple/stats.html new file mode 100644 index 000000000..462ab4aa9 --- /dev/null +++ b/searx/templates/simple/stats.html @@ -0,0 +1,25 @@ +{% extends "simple/base.html" %} +{% block head %} {% endblock %} +{% block content %} + +<a href="{{ url_for('index') }}"><h1><span>searx</span></h1></a> + +<h2>{{ _('Engine stats') }}</h2> + +{% for stat_name,stat_category in stats %} +<div class="left"> + <table> + <tr colspan="3"> + <th>{{ stat_name }}</th> + </tr> + {% for engine in stat_category %} + <tr> + <td>{{ engine.name }}</td> + <td>{{ '%.02f'|format(engine.avg) }}</td> + <td class="percentage"><div style="width: {{ engine.percentage }}%"> </div></td> + </tr> + {% endfor %} + </table> +</div> +{% endfor %} +{% endblock %} diff --git a/searx/templates/simple/time-range.html b/searx/templates/simple/time-range.html new file mode 100644 index 000000000..a9fc9f165 --- /dev/null +++ b/searx/templates/simple/time-range.html @@ -0,0 +1,17 @@ +<select name="time_range" id="time_range" class="time_range" tabindex="3">{{- '' -}} + <option id="time-range-anytime" value="" {{ "selected" if time_range=="" or not time_range else ""}}> + {{- _('Anytime') -}} + </option>{{- '' -}} + <option id="time-range-day" value="day" {{ "selected" if time_range=="day" else ""}}> + {{- _('Last day') -}} + </option>{{- '' -}} + <option id="time-range-week" value="week" {{ "selected" if time_range=="week" else ""}}> + {{- _('Last week') -}} + </option>{{- '' -}} + <option id="time-range-month" value="month" {{ "selected" if time_range=="month" else ""}}> + {{- _('Last month') -}} + </option>{{- '' -}} + <option id="time-range-year" value="year" {{ "selected" if time_range=="year" else ""}}> + {{- _('Last year') -}} + </option>{{- '' -}} +</select> |