浏览代码

Final commit on favicons

Definitely remove engine array
Change every themes to accomodate that change
Tweak of video template of oscar to add link on video thumbnail
Cqoicebordel 10 年前
父节点
当前提交
83d6f36659

+ 2
- 2
searx/templates/courgette/result_templates/default.html 查看文件

1
 <div class="result {{ result.class }}">
1
 <div class="result {{ result.class }}">
2
 
2
 
3
-  {% if result['favicon'] %}
4
-    <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" />
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}}" />
5
   {% endif %}
5
   {% endif %}
6
 
6
 
7
   <div>
7
   <div>

+ 2
- 2
searx/templates/courgette/result_templates/map.html 查看文件

1
 <div class="result {{ result.class }}">
1
 <div class="result {{ result.class }}">
2
 
2
 
3
-  {% if result['favicon'] %}
4
-    <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" />
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}}" />
5
   {% endif %}
5
   {% endif %}
6
 
6
 
7
   <div>
7
   <div>

+ 3
- 5
searx/templates/courgette/result_templates/videos.html 查看文件

1
 <div class="result">
1
 <div class="result">
2
-  {% if result['favicon'] %}
3
-    <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" />
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}}" />
4
   {% endif %}
4
   {% endif %}
5
 
5
 
6
-    <p>
7
       <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
6
       <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
8
       {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
7
       {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
9
-      <a href="{{ result.url }}"><img width="400px" src="{{ result.thumbnail }}" title={{ result.title }} alt=" {{ result.title }}"/></a>
8
+      <a href="{{ result.url }}"><img width="400" src="{{ result.thumbnail }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
10
       <p class="url">{{ result.url }}</p>
9
       <p class="url">{{ result.url }}</p>
11
-    </p>
12
 </div>
10
 </div>

+ 1
- 1
searx/templates/default/result_templates/default.html 查看文件

1
 <div class="result {{ result.class }}">
1
 <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" />{% 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>
3
     <p class="url">{{ result.pretty_url }} <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}">cached</a></p>
3
     <p class="url">{{ result.pretty_url }} <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}">cached</a></p>
4
     {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
4
     {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
5
     <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>
5
     <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>

+ 2
- 2
searx/templates/default/result_templates/map.html 查看文件

1
 <div class="result {{ result.class }}">
1
 <div class="result {{ result.class }}">
2
 
2
 
3
-  {% if result['favicon'] %}
4
-    <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" />
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}}" />
5
   {% endif %}
5
   {% endif %}
6
 
6
 
7
   <div>
7
   <div>

+ 2
- 4
searx/templates/default/result_templates/videos.html 查看文件

1
 <div class="result">
1
 <div class="result">
2
-    <p>
3
-      <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>
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>
4
       {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
3
       {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
5
-      <a href="{{ result.url }}"><img class="thumbnail" src="{{ result.thumbnail }}" title={{ result.title }} alt=" {{ result.title }}"/></a>
4
+      <a href="{{ result.url }}"><img class="thumbnail" src="{{ result.thumbnail }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
6
       <p class="url">{{ result.url }}</p>
5
       <p class="url">{{ result.url }}</p>
7
-    </p>
8
 </div>
6
 </div>

+ 1
- 1
searx/templates/oscar/result_templates/default.html 查看文件

1
 {% from 'oscar/macros.html' import icon %}
1
 {% from 'oscar/macros.html' import icon %}
2
 
2
 
3
-<h4 class="result_header">{% if result['favicon']~".png" in favicons %}<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>
4
 
4
 
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>

+ 1
- 1
searx/templates/oscar/result_templates/images.html 查看文件

7
         <div class="modal-content">
7
         <div class="modal-content">
8
             <div class="modal-header">
8
             <div class="modal-header">
9
                 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
9
                 <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']~".png" in favicons %}<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>
11
             </div>
11
             </div>
12
             <div class="modal-body">
12
             <div class="modal-body">
13
                 <img class="img-responsive center-block" src="{{ result.img_src }}" alt="{{ result.title }}">
13
                 <img class="img-responsive center-block" src="{{ result.img_src }}" alt="{{ result.title }}">

+ 1
- 1
searx/templates/oscar/result_templates/map.html 查看文件

1
 {% from 'oscar/macros.html' import icon %}
1
 {% from 'oscar/macros.html' import icon %}
2
 
2
 
3
-<h4 class="result_header">{% if result['favicon']~".png" in favicons %}<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>
4
 
4
 
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
6
 
6
 

+ 1
- 1
searx/templates/oscar/result_templates/torrent.html 查看文件

1
 {% from 'oscar/macros.html' import icon %}
1
 {% from 'oscar/macros.html' import icon %}
2
 
2
 
3
-<h4 class="result_header">{% if result['favicon']~".png" in favicons %}<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>
4
 
4
 
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>

+ 2
- 2
searx/templates/oscar/result_templates/videos.html 查看文件

1
 {% from 'oscar/macros.html' import icon %}
1
 {% from 'oscar/macros.html' import icon %}
2
 
2
 
3
-<h4 class="result_header">{% if result['favicon']~".png" in favicons %}<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>
4
     
4
     
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
7
 
7
 
8
 <div class="container-fluid">
8
 <div class="container-fluid">
9
     <div class="row">
9
     <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>
11
         {% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8 result-content">{{ result.content|safe }}</p>{% endif %}
11
         {% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8 result-content">{{ result.content|safe }}</p>{% endif %}
12
     </div>
12
     </div>
13
 </div>
13
 </div>

+ 0
- 8
searx/webapp.py 查看文件

68
 
68
 
69
 babel = Babel(app)
69
 babel = Babel(app)
70
 
70
 
71
-#TODO configurable via settings.yml
72
-favicons = ['wikipedia', 'youtube', 'vimeo', 'dailymotion', 'soundcloud',
73
-            'twitter', 'stackoverflow', 'github', 'deviantart']
74
-            
75
 global_favicons = []
71
 global_favicons = []
76
 for indice,theme in enumerate(themes):
72
 for indice,theme in enumerate(themes):
77
     global_favicons.append([])
73
     global_favicons.append([])
294
             result['pretty_url'] = u'{0}[...]{1}'.format(*url_parts)
290
             result['pretty_url'] = u'{0}[...]{1}'.format(*url_parts)
295
         else:
291
         else:
296
             result['pretty_url'] = result['url']
292
             result['pretty_url'] = result['url']
297
-
298
-        for engine in result['engines']:
299
-            if engine in favicons:
300
-                result['favicon'] = engine
301
                 
293
                 
302
         # TODO, check if timezone is calculated right
294
         # TODO, check if timezone is calculated right
303
         if 'publishedDate' in result:
295
         if 'publishedDate' in result: