Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
7dc5c7b8
Commit
7dc5c7b8
authored
Dec 22, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make it pass a real world tests
parent
fa19a325
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
pipeline/conf/settings.py
+2
-0
pipeline/storage.py
+34
-7
No files found.
pipeline/conf/settings.py
View file @
7dc5c7b8
...
...
@@ -3,6 +3,8 @@ from django.conf import settings
PIPELINE
=
getattr
(
settings
,
'PIPELINE'
,
not
settings
.
DEBUG
)
PIPELINE_ROOT
=
getattr
(
settings
,
'PIPELINE_ROOT'
,
settings
.
STATIC_ROOT
)
PIPELINE_URL
=
getattr
(
settings
,
'PIPELINE_URL'
,
settings
.
STATIC_URL
)
PIPELINE_STORAGE
=
getattr
(
settings
,
'PIPELINE_STORAGE'
,
'pipeline.storage.PipelineFinderStorage'
)
...
...
pipeline/storage.py
View file @
7dc5c7b8
try
:
from
staticfiles
import
finders
from
staticfiles.storage
import
CachedStaticFilesStorage
,
StaticFilesStorage
except
ImportError
:
from
django.contrib.staticfiles
import
finders
from
django.contrib.staticfiles.storage
import
CachedStaticFilesStorage
,
StaticFilesStorage
from
django.core.files.storage
import
get_storage_class
...
...
@@ -18,25 +20,50 @@ class PipelineStorage(StaticFilesStorage):
packager
=
Packager
()
for
package_name
in
packager
.
packages
[
'css'
]:
package
=
packager
.
package_for
(
'css'
,
package_name
)
for
path
in
package
[
'paths'
]:
if
path
in
paths
:
paths
.
remove
(
path
)
output_file
=
packager
.
pack_stylesheets
(
package
)
paths
.
append
(
output_file
)
for
package_name
in
packager
.
packages
[
'js'
]:
package
=
packager
.
package_for
(
'js'
,
package_name
)
for
path
in
package
[
'paths'
]:
if
path
in
paths
:
paths
.
remove
(
path
)
output_file
=
packager
.
pack_javascripts
(
package
)
paths
.
append
(
output_file
)
return
super
(
PipelineStorage
,
self
)
.
post_process
(
paths
,
dry_run
,
**
options
)
super_class
=
super
(
PipelineStorage
,
self
)
if
hasattr
(
super_class
,
'post_process'
):
return
super_class
.
post_process
(
paths
,
dry_run
,
**
options
)
return
paths
class
PipelineCachedStorage
(
PipelineStorage
,
CachedStaticFilesStorage
):
pass
class
BaseFinderStorage
(
PipelineStorage
):
finders
=
None
def
__init__
(
self
,
finders
=
None
,
*
args
,
**
kwargs
):
if
finders
is
not
None
:
self
.
finders
=
finders
if
self
.
finders
is
None
:
raise
ImproperlyConfigured
(
"The storage
%
r doesn't have a finders class assigned."
%
self
.
__class__
)
super
(
BaseFinderStorage
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
path
(
self
,
name
):
path
=
self
.
finders
.
find
(
name
)
if
not
path
:
path
=
super
(
BaseFinderStorage
,
self
)
.
path
(
name
)
return
path
def
exists
(
self
,
name
):
exists
=
self
.
finders
.
find
(
name
)
!=
None
if
not
exists
:
exists
=
super
(
BaseFinderStorage
,
self
)
.
exists
(
name
)
return
exists
class
PipelineFinderStorage
(
BaseFinderStorage
):
finders
=
finders
class
DefaultStorage
(
LazyObject
):
def
_setup
(
self
):
self
.
_wrapped
=
get_storage_class
(
settings
.
PIPELINE_STORAGE
)()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment