on master help sign in
Merge branch 'Cqoicebordel-Detect-favicons'
commitb4f39237a351d35b1b46dcbd33a4a1d94d313d07 authorAdam Tauber <asciimoo@gmail.com> dateWed 24 Dec 2014, 20:34 (12 years ago) parent5857141ada01cb
12 files changed+24−24
searx/templates/courgette/result_templates/default.html+2−2 searx/templates/courgette/result_templates/map.html+2−2 searx/templates/courgette/result_templates/videos.html+2−2 searx/templates/default/result_templates/default.html+1−1 searx/templates/default/result_templates/map.html+2−2 searx/templates/default/result_templates/videos.html+1−1 searx/templates/oscar/result_templates/default.html+1−1 searx/templates/oscar/result_templates/images.html+1−1 searx/templates/oscar/result_templates/map.html+1−1 searx/templates/oscar/result_templates/torrent.html+1−1 searx/templates/oscar/result_templates/videos.html+2−2 searx/webapp.py+8−8
searx/templates/courgette/result_templates/default.html+2−2
@@ -1,7 +1,7 @@
11<div class="result {{ result.class }}">
22
3− {% if result['favicon'] %}
4− <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />
3+ {% if "icon_"~result.engine~".ico" in favicons %}
4+ <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result.engine}}.ico" alt="{{result.engine}}" />
55 {% endif %}
66
77 <div>
searx/templates/courgette/result_templates/map.html+2−2
@@ -1,7 +1,7 @@
11<div class="result {{ result.class }}">
22
3− {% if result['favicon'] %}
4− <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />
3+ {% if "icon_"~result.engine~".ico" in favicons %}
4+ <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result.engine}}.ico" alt="{{result.engine}}" />
55 {% endif %}
66
77 <div>
searx/templates/courgette/result_templates/videos.html+2−2
@@ -1,6 +1,6 @@
11<div class="result">
2− {% if result['favicon'] %}
3− <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />
2+ {% if "icon_"~result.engine~".ico" in favicons %}
3+ <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result.engine}}.ico" alt="{{result.engine}}" />
44 {% endif %}
55
66 <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
searx/templates/default/result_templates/default.html+1−1
@@ -1,5 +1,5 @@
11<div class="result {{ result.class }}">
2− <h3 class="result_title"> {% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
2+ <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result.engine}}.ico" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
33 <p class="url">{{ result.pretty_url }} <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}">cached</a></p>
44 {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
55 <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>
searx/templates/default/result_templates/map.html+2−2
@@ -1,7 +1,7 @@
11<div class="result {{ result.class }}">
22
3− {% if result['favicon'] %}
4− <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />
3+ {% if "icon_"~result.engine~".ico" in favicons %}
4+ <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result.engine}}.ico" alt="{{result.engine}}" />
55 {% endif %}
66
77 <div>
searx/templates/default/result_templates/videos.html+1−1
@@ -1,5 +1,5 @@
11<div class="result">
2− <h3 class="result_title"> {% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
2+ <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result.engine}}.ico" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
33 {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
44 <a href="{{ result.url }}"><img class="thumbnail" src="{{ result.thumbnail }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
55 <p class="url">{{ result.url }}</p>
searx/templates/oscar/result_templates/default.html+1−1
@@ -1,6 +1,6 @@
11{% from 'oscar/macros.html' import icon %}
22
3−<h4 class="result_header">{% if result['favicon'] %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result['favicon'] }}.png" alt="{{ result['favicon'] }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
3+<h4 class="result_header">{% if result.engine~".png" in favicons %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result.engine }}.png" alt="{{ result.engine }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
44
55{% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
66<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
searx/templates/oscar/result_templates/images.html+1−1
@@ -7,7 +7,7 @@
77 <div class="modal-content">
88 <div class="modal-header">
99 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
10− <h4 class="modal-title">{% if result['favicon'] %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result['favicon'] }}.png" alt="{{ result['favicon'] }}" /> {% endif %}{{ result.title|striptags }}</h4>
10+ <h4 class="modal-title">{% if result.engine~".png" in favicons %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result.engine }}.png" alt="{{ result.engine }}" /> {% endif %}{{ result.title|striptags }}</h4>
1111 </div>
1212 <div class="modal-body">
1313 <img class="img-responsive center-block" src="{{ result.img_src }}" alt="{{ result.title }}">
searx/templates/oscar/result_templates/map.html+1−1
@@ -1,6 +1,6 @@
11{% from 'oscar/macros.html' import icon %}
22
3−<h4 class="result_header">{% if result['favicon'] %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result['favicon'] }}.png" alt="{{ result['favicon'] }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
3+<h4 class="result_header">{% if result.engine~".png" in favicons %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result.engine }}.png" alt="{{ result.engine }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
44
55{% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
66
searx/templates/oscar/result_templates/torrent.html+1−1
@@ -1,6 +1,6 @@
11{% from 'oscar/macros.html' import icon %}
22
3−<h4 class="result_header">{% if result['favicon'] %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result['favicon'] }}.png" alt="{{ result['favicon'] }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
3+<h4 class="result_header">{% if result.engine~".png" in favicons %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result.engine }}.png" alt="{{ result.engine }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
44
55{% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
66<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
searx/templates/oscar/result_templates/videos.html+2−2
@@ -1,13 +1,13 @@
11{% from 'oscar/macros.html' import icon %}
22
3−<h4 class="result_header">{% if result['favicon'] %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result['favicon'] }}.png" alt="{{ result['favicon'] }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
3+<h4 class="result_header">{% if result.engine~".png" in favicons %}<img width="32" height="32" class="favicon" src="static/{{ theme }}/img/icons/{{ result.engine }}.png" alt="{{ result.engine }}" /> {% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h4>
44
55{% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
66<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
77
88<div class="container-fluid">
99 <div class="row">
10− <img class="thumbnail col-xs-6 col-sm-4 col-md-4 result-content" src="{{ result.thumbnail|safe }}" alt="{{ result.title|urlencode }} {{ result['favicon'] }}" />
10+ <a href="{{ result.url }}"><img class="thumbnail col-xs-6 col-sm-4 col-md-4 result-content" src="{{ result.thumbnail|safe }}" alt="{{ result.title|striptags }} {{ result.engine }}" /></a>
1111 {% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8 result-content">{{ result.content|safe }}</p>{% endif %}
1212 </div>
1313</div>
searx/webapp.py+8−8
@@ -65,9 +65,12 @@ app.secret_key = settings['server']['secret_key']
6565
6666babel = Babel(app)
6767
68−#TODO configurable via settings.yml
69−favicons = ['wikipedia', 'youtube', 'vimeo', 'dailymotion', 'soundcloud',
70− 'twitter', 'stackoverflow', 'github', 'deviantart', 'kickass']
68+global_favicons = []
69+for indice, theme in enumerate(themes):
70+ global_favicons.append([])
71+ theme_img_path = searx_dir+"/static/"+theme+"/img/"
72+ for (dirpath, dirnames, filenames) in os.walk(theme_img_path):
73+ global_favicons[indice].extend(filenames)
7174
7275cookie_max_age = 60 * 60 * 24 * 365 * 23 # 23 years
7376
@@ -233,10 +236,6 @@ def index():
233236 else:
234237 result['pretty_url'] = result['url']
235238
236− for engine in result['engines']:
237− if engine in favicons:
238− result['favicon'] = engine
239−
240239 # TODO, check if timezone is calculated right
241240 if 'publishedDate' in result:
242241 result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S%z')
@@ -289,7 +288,8 @@ def index():
289288 suggestions=search.suggestions,
290289 answers=search.answers,
291290 infoboxes=search.infoboxes,
292− theme=get_current_theme_name()
291+ theme=get_current_theme_name(),
292+ favicons=global_favicons[themes.index(get_current_theme_name())]
293293 )
294294
295295