diff options
Diffstat (limited to 'searx')
26 files changed, 233 insertions, 90 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 183769af8..545bd69e7 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -69,7 +69,7 @@ def wikipedia(query): # wikipedia autocompleter url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json' # noqa - resp = loads(get(url.format(urlencode(dict(q=query)))).text) + resp = loads(get(url.format(urlencode(dict(search=query)))).text) if len(resp) > 1: return resp[1] return [] diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index 2adbfb3e4..16da728cd 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -1,8 +1,8 @@ -## Startpage (Web) -# +# Startpage (Web) +# # @website https://startpage.com # @provide-api no (nothing found) -# +# # @using-api no # @results HTML # @stable no (HTML can change) @@ -17,8 +17,11 @@ import re # engine dependent config categories = ['general'] -# there is a mechanism to block "bot" search (probably the parameter qid), require storing of qid's between mulitble search-calls -#paging = False +# there is a mechanism to block "bot" search +# (probably the parameter qid), require +# storing of qid's between mulitble search-calls + +# paging = False language_support = True # search-url @@ -40,11 +43,12 @@ def request(query, params): params['url'] = search_url params['method'] = 'POST' params['data'] = {'query': query, - 'startat': offset} + 'startat': offset} # set language if specified if params['language'] != 'all': - params['data']['with_language'] = 'lang_' + params['language'].split('_')[0] + params['data']['with_language'] = ('lang_' + + params['language'].split('_')[0]) return params @@ -54,10 +58,13 @@ def response(resp): results = [] dom = html.fromstring(resp.content) - + # parse results for result in dom.xpath(results_xpath): - link = result.xpath(link_xpath)[0] + links = result.xpath(link_xpath) + if not links: + continue + link = links[0] url = link.attrib.get('href') title = escape(link.text_content()) @@ -66,13 +73,14 @@ def response(resp): continue if result.xpath('./p[@class="desc"]'): - content = escape(result.xpath('./p[@class="desc"]')[0].text_content()) + content = escape(result.xpath('./p[@class="desc"]')[0] + .text_content()) else: content = '' # append result - results.append({'url': url, - 'title': title, + results.append({'url': url, + 'title': title, 'content': content}) # return results diff --git a/searx/search.py b/searx/search.py index f051d6df2..0e7aaed8f 100644 --- a/searx/search.py +++ b/searx/search.py @@ -131,7 +131,7 @@ def score_results(results): weight = 1.0 # strip multiple spaces and cariage returns from content - if 'content' in res: + if res.get('content'): res['content'] = re.sub(' +', ' ', res['content'].strip().replace('\n', '')) diff --git a/searx/settings.yml b/searx/settings.yml index c4589a0a7..d64a23bf1 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -7,6 +7,7 @@ server: themes_path : "" # Custom ui themes path default_theme : default # ui theme https_rewrite : True # Force rewrite result urls. See searx/https_rewrite.py + useragent_suffix : "" # suffix of searx_useragent, could contain informations like an email address to the administrator engines: - name : wikipedia diff --git a/searx/static/default/css/style.css b/searx/static/default/css/style.css index 70265b072..277f55e8d 100644 --- a/searx/static/default/css/style.css +++ b/searx/static/default/css/style.css @@ -21,11 +21,11 @@ a:hover.hmarg{color:#3498db} .top_margin{margin-top:60px} .center{text-align:center} h1{font-size:5em} -div.title{background:url('../img/searx.png') no-repeat;width:100%;background-position:center}div.title h1{visibility:hidden} +div.title{background:url('../img/searx.png') no-repeat;width:100%;min-height:80px;background-position:center}div.title h1{visibility:hidden} input[type="submit"]{padding:2px 6px;margin:2px 4px;display:inline-block;background:#3498db;color:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;border:0;cursor:pointer} input[type="checkbox"]{visibility:hidden} fieldset{margin:8px;border:1px solid #3498db} -#categories{margin:0 10px} +#categories{margin:0 10px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} .checkbox_container{display:inline-block;position:relative;margin:0 3px;padding:0}.checkbox_container input{display:none} .checkbox_container label,.engine_checkbox label{cursor:pointer;padding:4px 10px;margin:0;display:block;text-transform:capitalize;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} .checkbox_container input[type="checkbox"]:checked+label{background:#3498db;color:#fff} @@ -43,7 +43,8 @@ a{text-decoration:none;color:#1a11be}a:visited{color:#8e44ad} .result .content{font-size:.8em;margin:0;padding:0;max-width:54em;word-wrap:break-word;line-height:1.24}.result .content img{float:left;margin-right:5px;max-width:200px;max-height:100px} .result .content br.last{clear:both} .result .url{font-size:.8em;margin:0 0 3px 0;padding:0;max-width:54em;word-wrap:break-word;color:#c0392b} -.result .published_date{font-size:.8em;color:#888;margin:5px 20px} +.result .published_date{font-size:.8em;color:#888;Margin:5px 20px} +.result .thumbnail{width:400px} .engines{color:#888} .small_font{font-size:.8em} .small p{margin:2px 0} @@ -52,7 +53,7 @@ a{text-decoration:none;color:#1a11be}a:visited{color:#8e44ad} .left{float:left} .highlight{color:#094089} .content .highlight{color:#000} -.image_result{float:left;margin:10px 10px;position:relative;height:160px}.image_result img{border:0;height:160px} +.image_result{display:inline-block;margin:10px 10px;position:relative;max-height:160px}.image_result img{border:0;max-height:160px} .image_result p{margin:0;padding:0}.image_result p span a{display:none;color:#fff} .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:.7em} .torrent_result{border-left:10px solid #d3d3d3;padding-left:3px}.torrent_result p{margin:3px;font-size:.8em} @@ -64,18 +65,22 @@ tr:hover{background:#ddd} #results{margin:auto;padding:0;width:50em;margin-bottom:20px} #sidebar{position:fixed;bottom:10px;left:10px;margin:0 2px 5px 5px;padding:0 2px 2px 2px;width:14em}#sidebar input{padding:0;margin:3px;font-size:.8em;display:inline-block;background:transparent;color:#444;cursor:pointer} #sidebar input[type="submit"]{text-decoration:underline} -#suggestions,#answers{margin-top:20px} +#suggestions form{display:inline} +#suggestions,#answers{margin-top:20px;max-width:45em} #suggestions input,#answers input,#infoboxes input{padding:0;margin:3px;font-size:.8em;display:inline-block;background:transparent;color:#444;cursor:pointer} #suggestions input[type="submit"],#answers input[type="submit"],#infoboxes input[type="submit"]{text-decoration:underline} -#suggestions form,#answers form,#infoboxes form{display:inline} -#infoboxes{position:absolute;top:100px;right:20px;margin:0 2px 5px 5px;padding:0 2px 2px;max-width:21em}#infoboxes .infobox{margin:10px 0 10px;border:1px solid #ddd;padding:5px;font-size:.8em}#infoboxes .infobox img{max-width:20em;max-heigt:12em;display:block;margin:5px;padding:5px} +#answers form,#infoboxes form{min-width:210px} +#infoboxes{position:absolute;top:100px;right:20px;margin:0 2px 5px 5px;padding:0 2px 2px;max-width:21em}#infoboxes .infobox{margin:10px 0 10px;border:1px solid #ddd;padding:5px;font-size:.8em;}#infoboxes .infobox img{max-width:20em;max-heigt:12em;display:block;margin:5px;padding:5px} #infoboxes .infobox h2{margin:0} #infoboxes .infobox table{width:auto}#infoboxes .infobox table td{vertical-align:top} #infoboxes .infobox input{font-size:1em} #infoboxes .infobox br{clear:both} #search_url{margin-top:8px}#search_url input{border:1px solid #888;padding:4px;color:#444;width:14em;display:block;margin:4px;font-size:.8em} #preferences{top:10px;padding:0;border:0;background:url('../img/preference-icon.png') no-repeat;background-size:28px 28px;opacity:.8;width:28px;height:30px;display:block}#preferences *{display:none} -#pagination{clear:both;width:40em} +#pagination{clear:both}#pagination br{clear:both} #apis{margin-top:8px;clear:both} -@media screen and (max-width:50em){#results{margin:auto;padding:0;width:90%} .github{display:none} .checkbox_container{display:block;width:90%}.checkbox_container label{border-bottom:0} .right{display:none;postion:fixed !important;top:100px;right:0}}@media screen and (max-width:75em){#infoboxes{position:inherit;max-width:inherit}#infoboxes .infobox{clear:both}#infoboxes .infobox img{float:left;max-width:10em} #categories{font-size:90%;clear:both}#categories .checkbox_container{margin-top:2px;margin:auto} #sidebar{position:static;max-width:50em;margin:0 0 2px 0;padding:0;float:none;border:none;width:auto}#sidebar input{border:0} #apis{display:none} #search_url{display:none} .result{border-top:1px solid #e8e7e6;margin:7px 0 6px 0}}.favicon{float:left;margin-right:4px;margin-top:2px} +#categories_container{position:relative} +@media screen and (max-width:50em){#results{margin:auto;padding:0;width:90%} .github{display:none} .checkbox_container{display:block;width:90%}.checkbox_container label{border-bottom:0} .preferences_container{display:none;postion:fixed !important;top:100px;right:0}}@media screen and (max-width:75em){div.title h1{font-size:1em} html.touch #categories{width:95%;height:30px;text-align:left;overflow-x:scroll;overflow-y:hidden;-webkit-overflow-scrolling:touch}html.touch #categories #categories_container{width:1000px;width:-moz-max-content;width:-webkit-max-content;width:max-content}html.touch #categories #categories_container .checkbox_container{display:inline-block;width:auto} #categories{font-size:90%;clear:both}#categories .checkbox_container{margin-top:2px;margin:auto} #suggestions,#answers{margin-top:5px} #infoboxes{position:inherit;max-width:inherit}#infoboxes .infobox{clear:both}#infoboxes .infobox img{float:left;max-width:10em} #categories{font-size:90%;clear:both}#categories .checkbox_container{margin-top:2px;margin:auto} #sidebar{position:static;max-width:50em;margin:0 0 2px 0;padding:0;float:none;border:none;width:auto}#sidebar input{border:0} #apis{display:none} #search_url{display:none} .result{border-top:1px solid #e8e7e6;margin:8px 0 8px 0}.result .thumbnail{max-width:98%} .image_result{max-width:98%}.image_result img{max-width:98%}}.favicon{float:left;margin-right:4px;margin-top:2px} .preferences_back{background:none repeat scroll 0 0 #3498db;border:0 none;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;cursor:pointer;display:inline-block;margin:2px 4px;padding:4px 6px}.preferences_back a{color:#fff} +.hidden{opacity:0;overflow:hidden;font-size:.8em;position:absolute;bottom:-20px;width:100%;text-position:center;background:#fff;transition:opacity 1s ease} +#categories_container:hover .hidden{transition:opacity 1s ease;opacity:.8} diff --git a/searx/static/default/img/favicon.png b/searx/static/default/img/favicon.png Binary files differindex cefbac496..28afb0111 100644 --- a/searx/static/default/img/favicon.png +++ b/searx/static/default/img/favicon.png diff --git a/searx/static/default/img/preference-icon.png b/searx/static/default/img/preference-icon.png Binary files differindex f74635788..300279d24 100644 --- a/searx/static/default/img/preference-icon.png +++ b/searx/static/default/img/preference-icon.png diff --git a/searx/static/default/img/search-icon.png b/searx/static/default/img/search-icon.png Binary files differindex 1222421b2..d70310b5d 100644 --- a/searx/static/default/img/search-icon.png +++ b/searx/static/default/img/search-icon.png diff --git a/searx/static/default/img/searx.png b/searx/static/default/img/searx.png Binary files differindex e162da502..e69e9eef9 100644 --- a/searx/static/default/img/searx.png +++ b/searx/static/default/img/searx.png diff --git a/searx/static/default/js/searx.js b/searx/static/default/js/searx.js index c87dc30d4..9be969bb3 100644 --- a/searx/static/default/js/searx.js +++ b/searx/static/default/js/searx.js @@ -41,5 +41,9 @@ if(searx.autocompleter) { } }); + if (!!('ontouchstart' in window)) { + document.getElementsByTagName("html")[0].className += " touch"; + } + })(window, document); diff --git a/searx/static/default/less/style.less b/searx/static/default/less/style.less index c43c0fe72..9851b1305 100644 --- a/searx/static/default/less/style.less +++ b/searx/static/default/less/style.less @@ -97,6 +97,7 @@ h1 { div.title { background: url('../img/searx.png') no-repeat; width: 100%; + min-height: 80px; background-position: center; h1 { @@ -126,6 +127,7 @@ fieldset { #categories { margin: 0 10px; + .user-select; } .checkbox_container { @@ -260,8 +262,12 @@ a { .published_date { font-size: 0.8em; color: @color-result-publishdate-font; - margin: 5px 20px; + Margin: 5px 20px; } + + .thumbnail { + width: 400px; + } } .engines { @@ -297,14 +303,14 @@ a { } .image_result { - float: left; + display: inline-block; margin: 10px 10px; position: relative; - height: 160px; + max-height: 160px; img { border: 0; - height: 160px; + max-height: 160px; } p { @@ -369,17 +375,17 @@ tr { #results { margin: auto; padding: 0; - width: @results-width; + width: @results-width; margin-bottom: 20px; } #sidebar { position: fixed; - bottom: 10px; - left: 10px; + bottom: 10px; + left: 10px; margin: 0 2px 5px 5px; padding: 0 2px 2px 2px; - width: 14em; + width: 14em; input { padding: 0; @@ -390,14 +396,23 @@ tr { color: @color-result-search-url-font; cursor: pointer; } - input[type="submit"] { + input[type="submit"] { text-decoration: underline; - } + } +} + +#suggestions { + + form { + display: inline; + } + } #suggestions, #answers { margin-top: 20px; + max-width: 45em; } @@ -417,8 +432,11 @@ tr { text-decoration: underline; } +} + +#answers, #infoboxes { form { - display: inline; + min-width: 210px; } } @@ -436,6 +454,7 @@ tr { border: 1px solid #ddd; padding: 5px; font-size: 0.8em; + /* box-shadow: 0px 0px 5px #CCC; */ img { max-width: 20em; @@ -501,7 +520,10 @@ tr { #pagination { clear: both; - width: 40em; + + br { + clear: both; + } } #apis { @@ -509,20 +531,25 @@ tr { clear: both; } +#categories_container { + position: relative; +} + @media screen and (max-width: @results-width) { - #results { - margin: auto; - padding: 0; - width: 90%; - } + #results { + margin: auto; + padding: 0; + width: 90%; + } + .github { display: none; } .checkbox_container { display: block; - width: 90%; + width: 90%; //float: left; label { @@ -530,7 +557,7 @@ tr { } } - .right { + .preferences_container { display: none; postion: fixed !important; top: 100px; @@ -541,20 +568,61 @@ tr { @media screen and (max-width: 75em) { - #infoboxes { - position: inherit; - max-width: inherit; + div.title { + + h1 { + font-size: 1em; + } + } + + html.touch #categories { + width: 95%; + height: 30px; + text-align: left; + overflow-x: scroll; + overflow-y: hidden; + -webkit-overflow-scrolling: touch; + + #categories_container { + width: 1000px; + width: -moz-max-content; + width: -webkit-max-content; + width: max-content; + + .checkbox_container { + display: inline-block; + width: auto; + } + } + } + + #categories { + font-size: 90%; + clear: both; + + .checkbox_container { + margin-top: 2px; + margin: auto; + } + } + + #suggestions, #answers { + margin-top: 5px; + } + + #infoboxes { + position: inherit; + max-width: inherit; - .infobox { - clear:both; + .infobox { + clear:both; - img { - float: left; - max-width: 10em; - } - } - - } + img { + float: left; + max-width: 10em; + } + } + } #categories { font-size: 90%; @@ -583,13 +651,24 @@ tr { display: none; } - #search_url { - display: none; - } + #search_url { + display: none; + } .result { border-top: 1px solid @color-result-top-border; - margin: 7px 0 6px 0; + margin: 8px 0 8px 0; + + .thumbnail { + max-width: 98%; + } + } + + .image_result { + max-width: 98%; + img { + max-width: 98%; + } } } @@ -612,3 +691,20 @@ tr { color: @color-settings-return-font; } } + +.hidden { + opacity: 0; + overflow: hidden; + font-size: 0.8em; + position: absolute; + bottom: -20px; + width: 100%; + text-position: center; + background: white; + transition: opacity 1s ease; +} + +#categories_container:hover .hidden { + transition: opacity 1s ease; + opacity: 0.8; +} diff --git a/searx/templates/courgette/base.html b/searx/templates/courgette/base.html index da5ae905f..382b8d5ed 100644 --- a/searx/templates/courgette/base.html +++ b/searx/templates/courgette/base.html @@ -4,6 +4,7 @@ <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="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=1" /> <title>{% block title %}{% endblock %}searx</title> <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" media="screen" /> diff --git a/searx/templates/default/base.html b/searx/templates/default/base.html index da5ae905f..bc7f0972e 100644 --- a/searx/templates/default/base.html +++ b/searx/templates/default/base.html @@ -4,6 +4,7 @@ <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="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=1" /> <title>{% block title %}{% endblock %}searx</title> <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" media="screen" /> @@ -13,10 +14,6 @@ {% block head %} <link title="searx" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/> {% endblock %} - <script type="text/javascript"> - searx = {}; - searx.autocompleter = {% if autocomplete %}true{% else %}false{% endif %}; - </script> </head> <body> <div id="container"> @@ -26,6 +23,10 @@ <script src="{{ url_for('static', filename='js/mootools-core-1.4.5-min.js') }}" ></script> <script src="{{ url_for('static', filename='js/mootools-autocompleter-1.1.2-min.js') }}" ></script> {% endif %} +<script type="text/javascript"> + searx = {}; + searx.autocompleter = {% if autocomplete %}true{% else %}false{% endif %}; +</script> <script src="{{ url_for('static', filename='js/searx.js') }}" ></script> </div> </body> diff --git a/searx/templates/default/categories.html b/searx/templates/default/categories.html index 57e63c85d..017898ea7 100644 --- a/searx/templates/default/categories.html +++ b/searx/templates/default/categories.html @@ -1,7 +1,10 @@ <div id="categories"> + <div id="categories_container"> {% for category in categories %} - <div class="checkbox_container"> - <input type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} /><label for="checkbox_{{ category|replace(' ', '_') }}">{{ _(category) }}</label> - </div> + <div class="checkbox_container"> + <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 %} + <div class="hidden">{{ _('Click on the magnifier to perform search') }}</div> + </div> </div> diff --git a/searx/templates/default/index.html b/searx/templates/default/index.html index b4f55608b..72fbec8ca 100644 --- a/searx/templates/default/index.html +++ b/searx/templates/default/index.html @@ -1,6 +1,5 @@ {% extends "default/base.html" %} {% block content %} -{% include 'default/github_ribbon.html' %} <div class="center"> <div class="title"><h1>searx</h1></div> {% include 'default/search.html' %} @@ -9,4 +8,6 @@ <a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a> </p> </div> +{% include 'default/github_ribbon.html' %} {% endblock %} + diff --git a/searx/templates/default/infobox.html b/searx/templates/default/infobox.html index f963e898c..d03b008f9 100644 --- a/searx/templates/default/infobox.html +++ b/searx/templates/default/infobox.html @@ -2,7 +2,7 @@ <h2>{{ infobox.infobox }}</h2> {% if infobox.img_src %}<img src="{{ infobox.img_src }}" />{% endif %} <p>{{ infobox.entity }}</p> - <p>{{ infobox.content }}</p> + <p>{{ infobox.content | safe }}</p> {% if infobox.attributes %} <div class="attributes"> <table> diff --git a/searx/templates/default/result_templates/default.html b/searx/templates/default/result_templates/default.html index 78221aa01..d0e725ac5 100644 --- a/searx/templates/default/result_templates/default.html +++ b/searx/templates/default/result_templates/default.html @@ -1,13 +1,6 @@ <div class="result {{ result.class }}"> - - {% if result['favicon'] %} - <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" /> - {% endif %} - - <div> - <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3> + <h3 class="result_title"> {% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3> <p class="url">{{ result.pretty_url }} <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}">cached</a></p> - {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %} + {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %} <p class="content">{% if result.img_src %}<img src="{{ result.img_src }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p> - </div> </div> diff --git a/searx/templates/default/result_templates/images.html b/searx/templates/default/result_templates/images.html index 1f15ff2bb..bead78c48 100644 --- a/searx/templates/default/result_templates/images.html +++ b/searx/templates/default/result_templates/images.html @@ -1,6 +1,6 @@ <div class="image_result"> <p> - <a href="{{ result.img_src }}"><img src="{{ result.img_src }}" title={{ result.title }}/></a> + <a href="{{ result.img_src }}"><img src="{{ result.img_src }}" title="{{ result.title }}"/></a> <span class="url"><a href="{{ result.url }}" class="small_font">original context</a></span> </p> </div> diff --git a/searx/templates/default/result_templates/videos.html b/searx/templates/default/result_templates/videos.html index 8ceb0b180..233a6c021 100644 --- a/searx/templates/default/result_templates/videos.html +++ b/searx/templates/default/result_templates/videos.html @@ -1,12 +1,8 @@ <div class="result"> - {% if result['favicon'] %} - <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" /> - {% endif %} - <p> - <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3> + <h3 class="result_title"> {% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3> {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %} - <a href="{{ result.url }}"><img width="400px" src="{{ result.thumbnail }}" title={{ result.title }} alt=" {{ result.title }}"/></a> + <a href="{{ result.url }}"><img class="thumbnail" src="{{ result.thumbnail }}" title={{ result.title }} alt=" {{ result.title }}"/></a> <p class="url">{{ result.url }}</p> </p> </div> diff --git a/searx/templates/default/results.html b/searx/templates/default/results.html index b66d6e2af..541983532 100644 --- a/searx/templates/default/results.html +++ b/searx/templates/default/results.html @@ -1,7 +1,7 @@ {% extends "default/base.html" %} {% block title %}{{ q }} - {% endblock %} {% block content %} -<div class="right"><a href="{{ url_for('preferences') }}" id="preferences"><span>preferences</span></a></div> +<div class="preferences_container right"><a href="{{ url_for('preferences') }}" id="preferences"><span>preferences</span></a></div> <div class="small search center"> {% include 'default/search.html' %} </div> @@ -80,7 +80,7 @@ </form> {% endif %} <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"> - <div class="left"> + <div class="right"> {% for category in selected_categories %} <input type="hidden" name="category_{{ category }}" value="1"/> {% endfor %} @@ -89,6 +89,8 @@ <input type="submit" value="{{ _('next page') }} >>" /> </div> </form> + + <br /> </div> {% endif %} </div> diff --git a/searx/templates/default/search.html b/searx/templates/default/search.html index 8a9965582..75cfa41d6 100644 --- a/searx/templates/default/search.html +++ b/searx/templates/default/search.html @@ -1,6 +1,6 @@ <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form"> <div id="search_wrapper"> - <input type="text" placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" autocomplete="off" {% if q %}value="{{ q }}"{% endif %}/> + <input type="text" placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" autocomplete="off" size="100" {% if q %}value="{{ q }}"{% endif %}/> <input type="submit" value="search" id="search_submit" /> </div> {% include 'default/categories.html' %} diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index d9a3c0014..6fde942ac 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -5,6 +5,7 @@ <meta name="description" content="Searx - a privacy-respecting, hackable metasearch engine" /> <meta name="keywords" content="searx, search, search engine, metasearch, meta search" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="generator" content="searx/{{ searx_version }}"> <meta name="viewport" content="width=device-width, initial-scale=1 , maximum-scale=1.0, user-scalable=1" /> <title>{% block title %}{% endblock %}searx</title> @@ -65,7 +66,7 @@ <div class="container"> {% block footer %} {% endblock %} - <p class="text-muted">{{ _('Powered by') }} <a href="https://github.com/asciimoo/searx">Searx</a> - {{ _('a privacy-respecting, hackable metasearch engine') }}</p> + <p class="text-muted">{{ _('Powered by') }} <a href="https://github.com/asciimoo/searx">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}</p> </div> </div> <script src="{{ url_for('static', filename='js/jquery-1.11.1.min.js') }}"></script> diff --git a/searx/tests/test_webapp.py b/searx/tests/test_webapp.py index 9cf586180..7771567f0 100644 --- a/searx/tests/test_webapp.py +++ b/searx/tests/test_webapp.py @@ -49,7 +49,7 @@ class ViewsTestCase(SearxTestCase): ) result = self.app.post('/', data={'q': 'test'}) self.assertIn( - '<h3 class="result_title"><a href="http://first.test.xyz">First <span class="highlight">Test</span></a></h3>', # noqa + '<h3 class="result_title"> <img width="14" height="14" class="favicon" src="static/default/img/icon_youtube.ico" /><a href="http://first.test.xyz">First <span class="highlight">Test</span></a></h3>', # noqa result.data ) self.assertIn( diff --git a/searx/utils.py b/searx/utils.py index 7764291fc..47980bd36 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -3,6 +3,9 @@ from codecs import getincrementalencoder from HTMLParser import HTMLParser from random import choice +from searx.version import VERSION_STRING +from searx import settings + import cStringIO import csv import os @@ -21,7 +24,8 @@ def gen_useragent(): def searx_useragent(): - return 'searx' + return 'searx/{searx_version} {suffix}'.format(searx_version=VERSION_STRING, + suffix=settings['server'].get('useragent_suffix', '')) def highlight_content(content, query): diff --git a/searx/version.py b/searx/version.py new file mode 100644 index 000000000..8127d853d --- /dev/null +++ b/searx/version.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +''' +searx is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +searx is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with searx. If not, see < http://www.gnu.org/licenses/ >. + +(C) 2013- by Adam Tauber, <asciimoo@gmail.com> +''' + +# version of searx +VERSION_MAJOR = 0 +VERSION_MINOR = 4 +VERSION_BUILD = 0 + +VERSION_STRING = "%d.%d.%d" % (VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD) diff --git a/searx/webapp.py b/searx/webapp.py index e25a4067a..46061913e 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -44,6 +44,7 @@ from searx.engines import ( from searx.utils import ( UnicodeWriter, highlight_content, html_to_text, get_themes ) +from searx.version import VERSION_STRING from searx.https_rewrite import https_rules from searx.languages import language_codes from searx.search import Search @@ -171,13 +172,15 @@ def render(template_name, override_theme=None, **kwargs): if 'autocomplete' not in kwargs: kwargs['autocomplete'] = autocomplete + kwargs['searx_version'] = VERSION_STRING + kwargs['method'] = request.cookies.get('method', 'POST') # override url_for function in templates kwargs['url_for'] = url_for_theme kwargs['theme'] = get_current_theme_name(override=override_theme) - + kwargs['template_name'] = template_name return render_template( |