Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #36 from pistolero/stable

Fixed glob patterns (issue #31)

Conflicts:
	src/flask_assets.py
  • Loading branch information...
commit 2639ce0c81eae3f7fcd94e9d5e4561fd622a86dd 2 parents f86f45b + 265b1b1
@miracle2k authored
Showing with 13 additions and 22 deletions.
  1. +13 −22 src/flask_assets.py
View
35 src/flask_assets.py
@@ -145,16 +145,19 @@ def split_prefix(self, item):
if hasattr(self.env._app, 'blueprints'):
blueprint, name = item.split('/', 1)
directory = get_static_folder(self.env._app.blueprints[blueprint])
+ endpoint = '%s.static' % blueprint
item = name
else:
# Module support for Flask < 0.7
module, name = item.split('/', 1)
directory = get_static_folder(self.env._app.modules[module])
+ endpoint = '%s.static' % module
item = name
except (ValueError, KeyError):
directory = get_static_folder(self.env._app)
+ endpoint = 'static'
- return directory, item
+ return directory, item, endpoint
@property
def use_webassets_system_for_output(self):
@@ -174,7 +177,7 @@ def search_for_source(self, item):
return Resolver.search_for_source(self, item)
# Look in correct blueprint's directory
- directory, item = self.split_prefix(item)
+ directory, item, endpoint = self.split_prefix(item)
try:
return self.consider_single_directory(directory, item)
except IOError:
@@ -188,7 +191,7 @@ def resolve_output_to_path(self, target, bundle):
return Resolver.resolve_output_to_path(self, target, bundle)
# Allow targeting blueprint static folders
- directory, rel_path = self.split_prefix(target)
+ directory, rel_path, endpoint = self.split_prefix(target)
return path.normpath(path.join(directory, rel_path))
def resolve_source_to_url(self, filepath, item):
@@ -196,7 +199,7 @@ def resolve_source_to_url(self, filepath, item):
if self.use_webassets_system_for_sources:
return super(FlaskResolver, self).resolve_source_to_url(filepath, item)
- return self.convert_item_to_flask_url(item)
+ return self.convert_item_to_flask_url(item, filepath)
def resolve_output_to_url(self, target):
# With a directory/url pair set, use it for output files.
@@ -206,30 +209,18 @@ def resolve_output_to_url(self, target):
# Otherwise, behaves like all other flask URLs.
return self.convert_item_to_flask_url(target)
- def convert_item_to_flask_url(self, item):
+ def convert_item_to_flask_url(self, item, filepath=None):
"""Given a relative reference like `foo/bar.css`, returns
the Flask static url. By doing so it takes into account
blueprints, i.e. in the aformentioned example,
``foo`` may reference a blueprint.
"""
- filename = item
- if hasattr(self.env._app, 'blueprints'):
- try:
- blueprint, name = item.split('/', 1)
- self.env._app.blueprints[blueprint] # keyerror if no module
- endpoint = '%s.static' % blueprint
- filename = name
- except (ValueError, KeyError):
- endpoint = 'static'
+ directory, rel_path, endpoint = self.split_prefix(item)
+
+ if filepath is not None:
+ filename = filepath[len(directory)+1:]
else:
- # Module support for Flask < 0.7
- try:
- module, name = item.split('/', 1)
- self.env._app.modules[module] # keyerror if no module
- endpoint = '%s.static' % module
- filename = name
- except (ValueError, KeyError):
- endpoint = '.static'
+ filename = item
ctx = None
if not _request_ctx_stack.top:
Please sign in to comment.
Something went wrong with that request. Please try again.