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.
This commit is contained in:
Gina Häußge 2015-02-10 16:24:28 +01:00
parent 65557f670a
commit 00760ef1b3
2 changed files with 16 additions and 0 deletions

View file

@ -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()

View file

@ -14,6 +14,10 @@
{% for asset in assets["less"] %}
<link href="{{ url_for('plugin_assets', name=name, filename=asset) }}" rel="stylesheet/less" type="text/css" media="screen">
{% endfor %}
{% elif "css" in assets %}
{% for asset in assets["css"] %}
<link href="{{ url_for('plugin_assets', name=name, filename=asset) }}" rel="stylesheet" type="text/css" media="screen">
{% endfor %}
{% endif %}
{% endfor %}
<!-- /Plugin files -->
@ -22,13 +26,22 @@
{% else %}
<link href="{{ url_for('static', filename='css/octoprint.css') }}" rel="stylesheet" type="text/css" media="screen">
<!-- Plugin files -->
{% set lessneeded=[] %}
{% for name, assets in assetPlugins.items() %}
{% if "css" in assets %}
{% for asset in assets["css"] %}
<link href="{{ url_for('plugin_assets', name=name, filename=asset) }}" rel="stylesheet" type="text/css" media="screen">
{% endfor %}
{% elif "less" in assets %}
{% do lessneeded.append(1) %}
{% for asset in assets["less"] %}
<link href="{{ url_for('plugin_assets', name=name, filename=asset) }}" rel="stylesheet/less" type="text/css" media="screen">
{% endfor %}
{% endif %}
{% endfor %}
{% if lessneeded %}
<script src="{{ url_for('static', filename='js/lib/less.min.js') }}" type="text/javascript"></script>
{% endif %}
<!-- /Plugin files -->
{% endif %}