Depend on Flask-Assets 0.10
Compatibility adjustments and version pinning
This commit is contained in:
parent
b63f842210
commit
261f6709a3
3 changed files with 16 additions and 35 deletions
2
setup.py
2
setup.py
|
|
@ -21,7 +21,7 @@ INSTALL_REQUIRES = [
|
|||
"Flask-Login==0.2.2",
|
||||
"Flask-Principal==0.3.5",
|
||||
"Flask-Babel==0.9",
|
||||
"Flask-Assets",
|
||||
"Flask-Assets==0.10",
|
||||
"pyserial",
|
||||
"netaddr",
|
||||
"watchdog",
|
||||
|
|
|
|||
|
|
@ -731,8 +731,13 @@ class Server():
|
|||
"css/jquery.fileupload-ui.css",
|
||||
"css/pnotify.min.css"
|
||||
]
|
||||
css_app = ["empty"] + dynamic_assets["css"]
|
||||
less_app = ["empty"] + dynamic_assets["less"]
|
||||
css_app = list(dynamic_assets["css"])
|
||||
if len(css_app) == 0:
|
||||
css_app = ["empty"]
|
||||
|
||||
less_app = list(dynamic_assets["less"])
|
||||
if len(less_app) == 0:
|
||||
less_app = ["empty"]
|
||||
|
||||
js_libs_bundle = Bundle(*js_libs, output="webassets/packed_libs.js")
|
||||
if settings().getBoolean(["devel", "webassets", "minify"]):
|
||||
|
|
|
|||
|
|
@ -416,49 +416,25 @@ def get_json_command_from_request(request, valid_commands):
|
|||
|
||||
class PluginAssetResolver(flask.ext.assets.FlaskResolver):
|
||||
|
||||
def split_prefix(self, item):
|
||||
def split_prefix(self, ctx, item):
|
||||
app = ctx.environment._app
|
||||
if item.startswith("plugin/"):
|
||||
try:
|
||||
prefix, plugin, name = item.split("/", 2)
|
||||
blueprint = prefix + "." + plugin
|
||||
|
||||
directory = flask.ext.assets.get_static_folder(self.env._app.blueprints[blueprint])
|
||||
directory = flask.ext.assets.get_static_folder(app.blueprints[blueprint])
|
||||
item = name
|
||||
return directory, item
|
||||
endpoint = blueprint + ".static"
|
||||
return directory, item, endpoint
|
||||
except (ValueError, KeyError):
|
||||
pass
|
||||
|
||||
return flask.ext.assets.FlaskResolver.split_prefix(self, item)
|
||||
return flask.ext.assets.FlaskResolver.split_prefix(self, ctx, item)
|
||||
|
||||
def resolve_output_to_path(self, target, bundle):
|
||||
def resolve_output_to_path(self, ctx, target, bundle):
|
||||
import os
|
||||
return os.path.normpath(os.path.join(self.env.directory, target))
|
||||
|
||||
def resolve_source_to_url(self, filepath, item):
|
||||
if item.startswith("plugin/"):
|
||||
try:
|
||||
prefix, plugin, name = item.split('/', 2)
|
||||
blueprint = prefix + "." + plugin
|
||||
|
||||
self.env._app.blueprints[blueprint] # keyerror if no module
|
||||
endpoint = '%s.static' % blueprint
|
||||
filename = name
|
||||
except (ValueError, KeyError):
|
||||
endpoint = 'static'
|
||||
filename = item
|
||||
|
||||
ctx = None
|
||||
if not flask._request_ctx_stack.top:
|
||||
ctx = self.env._app.test_request_context()
|
||||
ctx.push()
|
||||
try:
|
||||
return flask.url_for(endpoint, filename=filename)
|
||||
finally:
|
||||
if ctx:
|
||||
ctx.pop()
|
||||
|
||||
return flask.ext.assets.FlaskResolver.resolve_source_to_url(self, filepath, item)
|
||||
|
||||
return os.path.normpath(os.path.join(ctx.environment.directory, target))
|
||||
|
||||
##~~ plugin assets collector
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue