Ver código fonte

Proxify most of images references

dalf 10 anos atrás
pai
commit
1d51512152

+ 2
- 2
searx/templates/courgette/result_templates/code.html Ver arquivo

@@ -1,9 +1,9 @@
1 1
 <div class="result {{ result.class }}">
2 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>
3 3
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
4
-    <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>
4
+    <p class="content">{% if result.img_src %}<img src="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
5 5
     {% if result.repository %}<p class="content"><a href="{{ result.repository|safe }}">{{ result.repository }}</a></p>{% endif %}
6 6
     {{ result.codelines|code_highlighter(result.code_language)|safe }}
7 7
 
8 8
     <p class="url">{{ result.pretty_url }}</p>
9
-</div>
9
+</div>

+ 2
- 2
searx/templates/courgette/result_templates/videos.html Ver arquivo

@@ -5,6 +5,6 @@
5 5
 
6 6
     <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
7 7
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span><br />{% endif %}
8
-    <a href="{{ result.url }}"><img width="400" src="{{ result.thumbnail }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
8
+    <a href="{{ result.url }}"><img width="400" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
9 9
     <p class="url">{{ result.pretty_url }}</p>
10
-</div>
10
+</div>

+ 1
- 1
searx/templates/default/result_templates/code.html Ver arquivo

@@ -2,7 +2,7 @@
2 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>
3 3
     <p class="url">{{ result.pretty_url }} <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}">cached</a></p>
4 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="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
6 6
     {% if result.repository %}<p class="result-content"><a href="{{ result.repository|safe }}">{{ result.repository }}</a></p>{% endif %}
7 7
 
8 8
     {{ result.codelines|code_highlighter(result.code_language)|safe }}

+ 1
- 1
searx/templates/default/result_templates/default.html Ver arquivo

@@ -2,5 +2,5 @@
2 2
     <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
3 3
     <p class="url">{{ result.pretty_url }} <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}">cached</a>
4 4
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% 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>
5
+    <p class="content">{% if result.img_src %}<img src="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
6 6
 </div>

+ 1
- 1
searx/templates/default/result_templates/map.html Ver arquivo

@@ -8,6 +8,6 @@
8 8
         <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
9 9
         <p class="url">{{ result.pretty_url }} <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}">cached</a>
10 10
         {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}</p>
11
-        <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>
11
+        <p class="content">{% if result.img_src %}<img src="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
12 12
     </div>
13 13
 </div>

+ 1
- 1
searx/templates/default/result_templates/videos.html Ver arquivo

@@ -1,6 +1,6 @@
1 1
 <div class="result">
2 2
     <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
3 3
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span><br />{% endif %}
4
-    <a href="{{ result.url }}"><img class="thumbnail" src="{{ result.thumbnail }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
4
+    <a href="{{ result.url }}"><img class="thumbnail" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
5 5
     <p class="url">{{ result.url }}</p>
6 6
 </div>

+ 1
- 1
searx/templates/oscar/result_templates/videos.html Ver arquivo

@@ -15,7 +15,7 @@
15 15
 
16 16
 <div class="container-fluid">
17 17
     <div class="row">
18
-        <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>
18
+        <a href="{{ result.url }}"><img class="thumbnail col-xs-6 col-sm-4 col-md-4 result-content" src="{{ image_proxify(result.thumbnail) }}" alt="{{ result.title|striptags }} {{ result.engine }}" /></a>
19 19
         {% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8 result-content">{{ result.content|safe }}</p>{% endif %}
20 20
     </div>
21 21
 </div>

+ 2
- 2
searx/webapp.py Ver arquivo

@@ -214,11 +214,11 @@ def image_proxify(url):
214 214
     if url.startswith('//'):
215 215
         url = 'https:' + url
216 216
 
217
-    h = hashlib.sha256(url + settings['server']['secret_key']).hexdigest()
218
-
219 217
     if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'):
220 218
         return url
221 219
 
220
+    h = hashlib.sha256(url + settings['server']['secret_key']).hexdigest()
221
+
222 222
     return '{0}?{1}'.format(url_for('image_proxy'),
223 223
                             urlencode(dict(url=url, h=h)))
224 224