From 798bef77f9b43e713aeb9ac2938785538538a99c Mon Sep 17 00:00:00 2001
From: Adam Tauber <asciimoo@gmail.com>
Date: Thu, 1 Jan 2015 19:24:47 +0100
Subject: [PATCH] [fix] static content paths

---
 searx/templates/courgette/result_templates/default.html | 2 +-
 searx/templates/default/result_templates/default.html   | 2 +-
 searx/templates/oscar/result_templates/default.html     | 2 +-
 searx/tests/test_webapp.py                              | 2 +-
 searx/webapp.py                                         | 4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/searx/templates/courgette/result_templates/default.html b/searx/templates/courgette/result_templates/default.html
index b46f95e9f..710b0a8e7 100644
--- a/searx/templates/courgette/result_templates/default.html
+++ b/searx/templates/courgette/result_templates/default.html
@@ -1,7 +1,7 @@
 <div class="result {{ result.class }}">
 
   {% if "icon_"~result.engine~".ico" in favicons %}
-    <img width="14" height="14" class="favicon" src="static/{{theme}}/img/icons/icon_{{result.engine}}.ico" alt="{{result.engine}}" />
+    <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
   {% endif %}
 
   <div>
diff --git a/searx/templates/default/result_templates/default.html b/searx/templates/default/result_templates/default.html
index 73e9af1a9..85882e56a 100644
--- a/searx/templates/default/result_templates/default.html
+++ b/searx/templates/default/result_templates/default.html
@@ -1,5 +1,5 @@
 <div class="result {{ result.class }}">
-    <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icons/icon_{{result.engine}}.ico" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
+    <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>
     <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 %}
     <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>
diff --git a/searx/templates/oscar/result_templates/default.html b/searx/templates/oscar/result_templates/default.html
index 3c8e6255d..b84430814 100644
--- a/searx/templates/oscar/result_templates/default.html
+++ b/searx/templates/oscar/result_templates/default.html
@@ -1,6 +1,6 @@
 {% from 'oscar/macros.html' import icon %}
 
-<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>
+<h4 class="result_header">{% if result.engine~".png" in favicons %}<img width="32" height="32" 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></h4>
 
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
diff --git a/searx/tests/test_webapp.py b/searx/tests/test_webapp.py
index a979e786d..d26b75e8f 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"><img width="14" height="14" class="favicon" src="static/themes/default/img/icons/icon_youtube.ico" alt="youtube" /><a href="http://second.test.xyz">Second <span class="highlight">Test</span></a></h3>',  # noqa
+            '<h3 class="result_title"><img width="14" height="14" class="favicon" src="/static/themes/default/img/icons/icon_youtube.ico" alt="youtube" /><a href="http://second.test.xyz">Second <span class="highlight">Test</span></a></h3>',  # noqa
             result.data
         )
         self.assertIn(
diff --git a/searx/webapp.py b/searx/webapp.py
index fca42d48e..6ee9af745 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -73,7 +73,7 @@ babel = Babel(app)
 global_favicons = []
 for indice, theme in enumerate(themes):
     global_favicons.append([])
-    theme_img_path = searx_dir+"/static/"+theme+"/img/icons/"
+    theme_img_path = searx_dir+"/static/themes/"+theme+"/img/icons/"
     for (dirpath, dirnames, filenames) in os.walk(theme_img_path):
         global_favicons[indice].extend(filenames)
 
@@ -506,7 +506,7 @@ def opensearch():
 @app.route('/favicon.ico')
 def favicon():
     return send_from_directory(os.path.join(app.root_path,
-                                            'static',
+                                            'static/themes',
                                             get_current_theme_name(),
                                             'img'),
                                'favicon.png',