From 00760ef1b35142bee8bb93656c0c683f0e24c08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 10 Feb 2015 16:24:28 +0100 Subject: [PATCH] If plugins only provide LESS or CSS files, they should still be properly included in the page regardless of stylesheet mode Up until now OctoPrint would not include anything for plugins which didn't provide LESS files but CSS files when in LESS mode (and vice versa). This is not rectified to make development a bit easier and less restrictive - if a plugin author doesn't want to use LESS but just plain CSS, that's now fine too. --- src/octoprint/server/__init__.py | 3 +++ src/octoprint/templates/stylesheets.jinja2 | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index dd833656..fa08a6a8 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -122,6 +122,8 @@ def index(): for name, implementation in asset_plugins.items(): asset_plugin_urls[name] = implementation.get_assets() + ##~~ extract data from template plugins + templates = dict( navbar=dict(order=[], entries=dict()), sidebar=dict(order=[], entries=dict()), @@ -511,6 +513,7 @@ class Server(): ]) app.jinja_loader = jinja_loader del jinja2 + app.jinja_env.add_extension("jinja2.ext.do") # configure timelapse octoprint.timelapse.configureTimelapse() diff --git a/src/octoprint/templates/stylesheets.jinja2 b/src/octoprint/templates/stylesheets.jinja2 index 1fabcd2c..235185e9 100644 --- a/src/octoprint/templates/stylesheets.jinja2 +++ b/src/octoprint/templates/stylesheets.jinja2 @@ -14,6 +14,10 @@ {% for asset in assets["less"] %} {% endfor %} + {% elif "css" in assets %} + {% for asset in assets["css"] %} + + {% endfor %} {% endif %} {% endfor %} @@ -22,13 +26,22 @@ {% else %} + {% set lessneeded=[] %} {% for name, assets in assetPlugins.items() %} {% if "css" in assets %} {% for asset in assets["css"] %} {% endfor %} + {% elif "less" in assets %} + {% do lessneeded.append(1) %} + {% for asset in assets["less"] %} + + {% endfor %} {% endif %} {% endfor %} + {% if lessneeded %} + + {% endif %} {% endif %}