Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/0.1.6'

  • Loading branch information...
commit 439924176cb9627343c9f51eeef012f99507b319 2 parents f1db9c5 + 27c5dfe
@klen authored
View
2  Changelog
@@ -1,6 +1,6 @@
2012-09-02 klen
- * Version 0.1.5
+ * Version 0.1.6
* Add docs
2012-08-18 klen
View
2  flask_collect/__init__.py
@@ -16,7 +16,7 @@
assert Collect
-__version__ = '0.1.5'
+__version__ = '0.1.6'
__project__ = __name__
__author__ = "Kirill Klenov <horneds@gmail.com>"
__license__ = "BSD"
View
12 flask_collect/collect.py
@@ -26,7 +26,9 @@ class Collect():
def __init__(self, app=None):
self.static_root = None
+ self.static_url = None
self.storage = None
+ self.blueprints = None
if app:
self.init_app(app)
@@ -45,9 +47,14 @@ def init_app(self, app):
self.static_root = app.config.get('COLLECT_STATIC_ROOT',
op.join(app.root_path, 'static')).rstrip('/')
+ self.static_url = app.static_url_path
+
self.storage = app.config.get(
'COLLECT_STORAGE', 'flask.ext.collect.storage.file')
+ # Save link on blueprints
+ self.blueprints = app.blueprints
+
def init_script(self, manager):
"""This callback can be used to initialize collect scripts with
`Flask-Script`_ manager instance.
@@ -68,11 +75,12 @@ def init_script(self, manager):
.. _Flask-Script: http://packages.python.org/Flask-Script/
"""
- @manager.command
def collect(verbose=True):
" Collect static from blueprints. "
+
self.collect(verbose=verbose)
- assert collect
+
+ manager.command(collect)
def collect(self, verbose=False):
"""Collect static files from blueprints.
View
9 flask_collect/storage/base.py
@@ -9,16 +9,15 @@ def __init__(self, collect, verbose=False):
def __iter__(self):
" Seek static files and result full and relative paths. "
- app = self.collect.app
- for bp in app.blueprints.values():
+ for bp in self.collect.blueprints.values():
if bp.static_folder and op.isdir(bp.static_folder):
for root, _, files in walk(bp.static_folder):
for f in files:
fpath = op.join(root, f)
opath = op.relpath(fpath, bp.static_folder.rstrip('/'))
- if bp.static_url_path and bp.static_url_path.startswith(op.join(app.static_url_path, '')):
- opath = op.join(op.relpath(bp.
- static_url_path, app.static_url_path), opath)
+ if bp.static_url_path and bp.static_url_path.startswith(op.join(self.collect.static_url, '')):
+ opath = op.join(op.relpath(
+ bp.static_url_path, self.collect.static_url), opath)
yield bp, fpath, opath
def log(self, msg):
View
2  flask_collect/storage/file.py
@@ -17,4 +17,4 @@ def run(self):
if not op.exists(destination) or op.getmtime(destination) < op.getmtime(f):
copy2(f, destination)
self.log("Copied: [%s] '%s'" % (bp.name,
- op.join(self.collect.app.static_url_path, destination)))
+ op.join(self.collect.static_url, destination)))
View
4 tests/__init__.py
@@ -23,5 +23,5 @@ def test_collect(self):
collect = Collect(app)
collect.collect(verbose=True)
- assert op.exists(op.join(static_root, 'test1', 'test.css'))
- assert op.exists(op.join(static_root, 'js', 'test.js'))
+ self.assertTrue(op.exists(op.join(static_root, 'test1', 'test.css')))
+ self.assertTrue(op.exists(op.join(static_root, 'js', 'test.js')))
Please sign in to comment.
Something went wrong with that request. Please try again.