From f3b565e17ecd4c875381a3a212d73fb065f9a89d Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sat, 27 Sep 2014 12:33:22 +0200 Subject: [PATCH] oscar template: implement first version of results page * implement results page * improve search form template * implement all result_templates * fix youtube engine --- searx/engines/youtube.py | 6 +---- searx/static/oscar/css/oscar.css | 26 +++++++++++++++++++ searx/templates/oscar/index.html | 2 +- .../oscar/result_templates/default.html | 8 ++++++ .../oscar/result_templates/images.html | 21 +++++++++++++++ .../oscar/result_templates/torrent.html | 14 ++++++++++ .../oscar/result_templates/videos.html | 13 ++++++++++ searx/templates/oscar/results.html | 22 ++++++++++++++++ searx/templates/oscar/search.html | 13 +++------- searx/templates/oscar/search_full.html | 17 ++++++++++++ 10 files changed, 127 insertions(+), 15 deletions(-) create mode 100644 searx/templates/oscar/result_templates/default.html create mode 100644 searx/templates/oscar/result_templates/images.html create mode 100644 searx/templates/oscar/result_templates/torrent.html create mode 100644 searx/templates/oscar/result_templates/videos.html create mode 100644 searx/templates/oscar/results.html create mode 100644 searx/templates/oscar/search_full.html diff --git a/searx/engines/youtube.py b/searx/engines/youtube.py index a3c3980af..e217fb079 100644 --- a/searx/engines/youtube.py +++ b/searx/engines/youtube.py @@ -69,12 +69,8 @@ def response(resp): if result['media$group']['media$thumbnail']: thumbnail = result['media$group']['media$thumbnail'][0]['url'] - content += ''.format(url, thumbnail) # noqa - if content: - content += '
' + result['content']['$t'] - else: - content = result['content']['$t'] + content = result['content']['$t'] # append result results.append({'url': url, diff --git a/searx/static/oscar/css/oscar.css b/searx/static/oscar/css/oscar.css index 4ff475e89..b3e42f607 100644 --- a/searx/static/oscar/css/oscar.css +++ b/searx/static/oscar/css/oscar.css @@ -25,3 +25,29 @@ input[type=checkbox]:checked ~ .label_hide_if_checked { input[type=checkbox]:not(:checked) ~ .label_hide_if_not_checked { display:none; } + +.search_categories { + margin:10px 0; +} + +.result-default { + clear: both; +} + +.result-images { + float: left !important; +} + +.result-videos { + clear: both; +} + +.result-torrents { + clear: both; +} + +.img-thumbnail { + margin: 5px; + max-height: 128px; + min-height: 128px; +} diff --git a/searx/templates/oscar/index.html b/searx/templates/oscar/index.html index adb535d9b..e58aa073a 100644 --- a/searx/templates/oscar/index.html +++ b/searx/templates/oscar/index.html @@ -8,7 +8,7 @@
- {% include 'oscar/search.html' %} + {% include 'oscar/search_full.html' %}
diff --git a/searx/templates/oscar/result_templates/default.html b/searx/templates/oscar/result_templates/default.html new file mode 100644 index 000000000..2ea246542 --- /dev/null +++ b/searx/templates/oscar/result_templates/default.html @@ -0,0 +1,8 @@ +

{{ result.title|safe }}

+ +{% if result.publishedDate %}{% endif %} + +{% if result.content %}

{{ result.content|safe }}

{% endif %} + +{{ result.engine }} +

{% if result['favicon'] %}{% endif %} {{ result.pretty_url }}

diff --git a/searx/templates/oscar/result_templates/images.html b/searx/templates/oscar/result_templates/images.html new file mode 100644 index 000000000..07b427d78 --- /dev/null +++ b/searx/templates/oscar/result_templates/images.html @@ -0,0 +1,21 @@ + + {{ result.title|e }} + + + diff --git a/searx/templates/oscar/result_templates/torrent.html b/searx/templates/oscar/result_templates/torrent.html new file mode 100644 index 000000000..14ac63232 --- /dev/null +++ b/searx/templates/oscar/result_templates/torrent.html @@ -0,0 +1,14 @@ +{% from 'oscar/macros.html' import icon %} + +

{{ result.title|safe }}

+ +{% if result.publishedDate %}{% endif %} + +

{{ icon('transfer') }} {{ _('Seeder') }} {{ result.seed }}, {{ _('Leecher') }} {{ result.leech }}

+ +

{{ icon('magnet') }} magnet link

+ +{% if result.content %}

{{ result.content|safe }}

{% endif %} + +{{ result.engine }} +

{% if result['favicon'] %}{% endif %} {{ result.pretty_url }}

diff --git a/searx/templates/oscar/result_templates/videos.html b/searx/templates/oscar/result_templates/videos.html new file mode 100644 index 000000000..32112472e --- /dev/null +++ b/searx/templates/oscar/result_templates/videos.html @@ -0,0 +1,13 @@ +

{{ result.title|safe }}

+ +{% if result.publishedDate %}{% endif %} + +
+
+ + {% if result.content %}

{{ result.content|safe }}

{% endif %} +
+
+ +{{ result.engine }} +

{% if result['favicon'] %}{% endif %} {{ result.pretty_url }}

diff --git a/searx/templates/oscar/results.html b/searx/templates/oscar/results.html new file mode 100644 index 000000000..fde65c883 --- /dev/null +++ b/searx/templates/oscar/results.html @@ -0,0 +1,22 @@ +{% extends "oscar/base.html" %} +{% block title %}{{ q }} - {% endblock %} +{% block content %} +
+
+

{{ _('Search results') }}

+ {% include 'oscar/search.html' %} + + {% for result in results %} +
+ {% set index = loop.index %} + {% if result.template %}{% include 'oscar/result_templates/'+result['template'] %}{% else %}{% include 'oscar/result_templates/default.html' %}{% endif %} +
+ {% endfor %} + +
+ +
+ +
+{% endblock %} diff --git a/searx/templates/oscar/search.html b/searx/templates/oscar/search.html index f44d48adf..4b1f8b6a1 100644 --- a/searx/templates/oscar/search.html +++ b/searx/templates/oscar/search.html @@ -1,17 +1,12 @@ {% from 'oscar/macros.html' import icon %} -