Browse Source

[fix] merge fake "plugins" endpoint back to "static"

https: //matrix.to/#/!vxScbLNEAmRvOraXBn:matrix.org/$0zqTtH3s-eVKlMwiAgiEJdetOkRx27EIRs-C0o8FzSg?via=libera.chat&via=matrix.org&via=tchncs.de
Co-Authored-By: Alexandre Flament <alex.andre@al-f.net>
Austin Huang 3 years ago
parent
commit
6353b850b0
2 changed files with 9 additions and 13 deletions
  1. 1 1
      searx/templates/oscar/base.html
  2. 8 12
      searx/webapp.py

+ 1 - 1
searx/templates/oscar/base.html

@@ -103,7 +103,7 @@
             data-infinite-scroll="{% if infinite_scroll %}true{% else %}false{% endif %}"
             data-translations="{{ translations }}"></script>
     {% for script in scripts %}
-    {{""}}<script src="{{ url_for('plugins', filename=script) }}"></script>
+    {{""}}<script src="{{ url_for('static', filename=script) }}"></script>
     {% endfor %}
     <noscript>
       <style>

+ 8 - 12
searx/webapp.py

@@ -348,19 +348,15 @@ def get_result_template(theme_name: str, template_name: str):
 def custom_url_for(endpoint: str, override_theme: Optional[str] = None, **values):
     suffix = ""
     if endpoint == 'static' and values.get('filename'):
-        theme_name = get_current_theme_name(override=override_theme)
-        filename_with_theme = "themes/{}/{}".format(theme_name, values['filename'])
-        values['filename'] = filename_with_theme
-        if get_setting('ui.static_use_hash', False):
+        file_hash = static_files.get(values['filename'])
+        if not file_hash:
+            # try file in the current theme
+            theme_name = get_current_theme_name(override=override_theme)
+            filename_with_theme = "themes/{}/{}".format(theme_name, values['filename'])
             file_hash = static_files.get(filename_with_theme)
-            if file_hash:
-                suffix = "?" + file_hash
-    if endpoint == 'plugins' and values.get('filename'):
-        endpoint = 'static'
-        if get_setting('ui.static_use_hash', False):
-            file_hash = static_files.get(values['filename'])
-            if file_hash:
-                suffix = "?" + file_hash
+            values['filename'] = filename_with_theme
+        if get_setting('ui.static_use_hash') and file_hash:
+            suffix = "?" + file_hash
     if endpoint == 'info' and 'locale' not in values:
         locale = request.preferences.get_value('locale')
         if _INFO_PAGES.get_page(values['pagename'], locale) is None: