From 74ca542a0282e269c991cc75511ccc76a7c8901c Mon Sep 17 00:00:00 2001 From: rhapsodhy Date: Sat, 11 Jan 2014 03:31:54 +0000 Subject: [PATCH 1/2] [enh] set up special css classes for highlighting results + highlight definitions with dark grey border --- searx/engines/duckduckgo_definitions.py | 7 ++++--- searx/static/css/style.css | 13 +++++++++---- searx/templates/result_templates/default.html | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/searx/engines/duckduckgo_definitions.py b/searx/engines/duckduckgo_definitions.py index 2d97f8154..7b3950b85 100644 --- a/searx/engines/duckduckgo_definitions.py +++ b/searx/engines/duckduckgo_definitions.py @@ -13,9 +13,10 @@ def response(resp): results = [] if 'Definition' in search_res: if search_res.get('AbstractURL'): - res = {'title' : search_res.get('Heading', '') - ,'content' : search_res.get('Definition', '') - ,'url' : search_res.get('AbstractURL', '') + res = {'title' : search_res.get('Heading', '') + ,'content' : search_res.get('Definition', '') + ,'url' : search_res.get('AbstractURL', '') + ,'class' : 'definition_result' } results.append(res) diff --git a/searx/static/css/style.css b/searx/static/css/style.css index c9e0335aa..76bcd2a1a 100644 --- a/searx/static/css/style.css +++ b/searx/static/css/style.css @@ -97,6 +97,11 @@ a:visited { color: #7b11be; } .image_result p span a { color: #FFFFFF; } .image_result p:hover span a { display: block; position: absolute; bottom: 0; right: 0; padding: 4px; background-color: rgba(0, 0, 0, 0.6); font-size: 0.7em; } +.torrent_result { border-left: 10px solid lightgray; padding-left: 3px; } +.torrent_result p { margin: 3px; font-size: 0.8em; } + +.definition_result { border-left: 10px solid gray; padding-left: 3px; } + .percentage { position: relative; width: 300px; } .percentage div { background: #444444; } td { padding: 0 4px; } @@ -142,7 +147,7 @@ tr:hover td { background: #DDDDDD; } #suggestions form { display: block; } #suggestions input { padding: 2px 6px; margin: 2px 4px; font-size: 0.8em; display: inline-block; background: #E4E4E4; border-radius: 4px; border: 0; cursor: pointer; } -#preferences { +#preferences { top: 10px; padding: 0; border: 0; @@ -163,7 +168,7 @@ tr:hover td { background: #DDDDDD; } } @media screen and (max-width: 60em) { - + #suggestions { position: static; max-width: 50em; margin: 0 0 2px 0; padding: 0; float: none; border: none; width: auto } #suggestions span { display: inline; font-size: 0.8em } #suggestions form { display: inline; } @@ -172,13 +177,13 @@ tr:hover td { background: #DDDDDD; } } @media screen and (max-width: 680px) { - + #search_wrapper { width: 90%; clear:both; overflow: hidden } .right { display: none; postion: fixed !important; top: 100px; right: 0px; } #categories { font-size: 80% } - + #categories .checkbox_container { margin-top: 2px; margin: 0 2px; } .result { border-top: 1px solid #e8e7e6; margin: 7px 0 6px 0; } diff --git a/searx/templates/result_templates/default.html b/searx/templates/result_templates/default.html index 27cf57528..48c0775ae 100644 --- a/searx/templates/result_templates/default.html +++ b/searx/templates/result_templates/default.html @@ -1,4 +1,4 @@ -
+

{{ result.title|safe }}

{% if result.content %}{{ result.content|safe }}
{% endif %}

{{ result.pretty_url }}

From b0a440421772c334b090f89187b747a350d31e5a Mon Sep 17 00:00:00 2001 From: rhapsodhy Date: Sat, 11 Jan 2014 03:33:41 +0000 Subject: [PATCH 2/2] [enh] highlight piratebay results with light grey border, and indent peers+magnet link --- searx/engines/piratebay.py | 6 +++--- searx/templates/result_templates/torrent.html | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 searx/templates/result_templates/torrent.html diff --git a/searx/engines/piratebay.py b/searx/engines/piratebay.py index 95ab884d5..11538dd6b 100644 --- a/searx/engines/piratebay.py +++ b/searx/engines/piratebay.py @@ -28,8 +28,8 @@ def response(resp): title = ' '.join(link.xpath('.//text()')) content = escape(' '.join(result.xpath('.//font[@class="detDesc"]//text()'))) seed, leech = result.xpath('.//td[@align="right"]/text()')[:2] - content += '
Seed: %s, Leech: %s' % (seed, leech) magnetlink = result.xpath('.//a[@title="Download this torrent using magnet"]')[0] - content += '
magnet link' % urljoin(url, magnetlink.attrib['href']) - results.append({'url': href, 'title': title, 'content': content}) + results.append({'url': href, 'title': title, 'content': content, + 'seed': seed, 'leech': leech, 'magnetlink': magnetlink.attrib['href'], + 'template': 'torrent.html'}) return results diff --git a/searx/templates/result_templates/torrent.html b/searx/templates/result_templates/torrent.html new file mode 100644 index 000000000..4b7cfbf2a --- /dev/null +++ b/searx/templates/result_templates/torrent.html @@ -0,0 +1,7 @@ +
+

{{ result.title|safe }}

+

{% if result.content %}{{ result.content|safe }}
{% endif %}

+

Seed: {{ result.seed }}, Leech: {{ result.leech }}

+

magnet link

+

{{ result.pretty_url }}

+