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
29eee6f8
Commit
29eee6f8
authored
Sep 16, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow to bust version cache without compressing files
parent
c5dbf437
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
17 deletions
+31
-17
pipeline/compressors/__init__.py
+2
-2
pipeline/management/commands/synccompress.py
+17
-4
pipeline/packager.py
+8
-9
pipeline/signals.py
+3
-1
pipeline/versioning/__init__.py
+1
-1
No files found.
pipeline/compressors/__init__.py
View file @
29eee6f8
...
...
@@ -49,7 +49,7 @@ class Compressor(object):
return
to_class
(
settings
.
PIPELINE_CSS_COMPRESSOR
)
css_compressor
=
property
(
css_compressor
)
def
compress_js
(
self
,
paths
,
templates
=
None
,
asset_url
=
None
):
def
compress_js
(
self
,
paths
,
templates
=
None
,
asset_url
=
None
,
**
kwargs
):
"""Concatenate and compress JS files"""
js
=
self
.
concatenate
(
paths
)
if
templates
:
...
...
@@ -58,7 +58,7 @@ class Compressor(object):
js
=
getattr
(
self
.
js_compressor
(
verbose
=
self
.
verbose
),
'compress_js'
)(
js
)
return
js
def
compress_css
(
self
,
paths
,
variant
=
None
,
asset_url
=
None
):
def
compress_css
(
self
,
paths
,
variant
=
None
,
asset_url
=
None
,
**
kwargs
):
"""Concatenate and compress CSS files"""
css
=
self
.
concatenate_and_rewrite
(
paths
,
variant
)
css
=
getattr
(
self
.
css_compressor
(
verbose
=
self
.
verbose
),
'compress_css'
)(
css
)
...
...
pipeline/management/commands/synccompress.py
View file @
29eee6f8
...
...
@@ -10,18 +10,31 @@ class Command(BaseCommand):
default
=
False
,
help
=
'Force update of all files, even if the source files are older than the current compressed file.'
),
make_option
(
'--dry-run'
,
action
=
'store_false'
,
default
=
True
,
help
=
'Don
\'
t attempt to update files.'
),
make_option
(
'--no-cache-bust'
,
dest
=
'bust_cache'
,
action
=
'store_false'
,
default
=
True
,
help
=
'Don
\'
t update version cache.'
)
)
help
=
'Updates and compresses CSS and JS on-demand
, without restarting Django
'
help
=
'Updates and compresses CSS and JS on-demand'
args
=
'<group>'
def
handle
(
self
,
group
=
None
,
**
options
):
from
pipeline.packager
import
Packager
packager
=
Packager
(
sync
=
True
,
force
=
options
.
get
(
'force'
,
False
),
verbose
=
int
(
options
.
get
(
'verbosity'
,
1
))
>=
2
)
sync
=
options
.
get
(
'dry_run'
,
True
),
bust_cache
=
options
.
get
(
'bust_cache'
,
True
)
for
package_name
in
packager
.
packages
[
'css'
]:
if
group
and
package_name
!=
group
:
continue
...
...
@@ -31,7 +44,7 @@ class Command(BaseCommand):
message
=
"CSS Group '
%
s'"
%
package_name
print
message
print
len
(
message
)
*
'-'
packager
.
pack_stylesheets
(
package
)
packager
.
pack_stylesheets
(
package
,
sync
=
sync
,
bust_cache
=
bust_cache
)
for
package_name
in
packager
.
packages
[
'js'
]:
if
group
and
package_name
!=
group
:
...
...
@@ -42,4 +55,4 @@ class Command(BaseCommand):
message
=
"JS Group '
%
s'"
%
package_name
print
message
print
len
(
message
)
*
'-'
packager
.
pack_javascripts
(
package
)
packager
.
pack_javascripts
(
package
,
sync
=
sync
,
bust_cache
=
bust_cache
)
pipeline/packager.py
View file @
29eee6f8
...
...
@@ -13,10 +13,9 @@ from pipeline.versioning import Versioning
class
Packager
(
object
):
def
__init__
(
self
,
force
=
False
,
sync
=
False
,
verbose
=
False
,
css_packages
=
None
,
js_packages
=
None
):
def
__init__
(
self
,
force
=
False
,
verbose
=
False
,
css_packages
=
None
,
js_packages
=
None
):
self
.
force
=
force
self
.
verbose
=
verbose
self
.
sync
=
sync
self
.
compressor
=
Compressor
(
verbose
)
self
.
versioning
=
Versioning
(
verbose
)
self
.
compiler
=
Compiler
(
verbose
)
...
...
@@ -43,16 +42,16 @@ class Packager(object):
return
urlparse
.
urljoin
(
settings
.
PIPELINE_URL
,
self
.
compressor
.
relative_path
(
filename
)[
1
:])
def
pack_stylesheets
(
self
,
package
):
def
pack_stylesheets
(
self
,
package
,
**
kwargs
):
variant
=
package
.
get
(
'variant'
,
None
)
return
self
.
pack
(
package
,
self
.
compressor
.
compress_css
,
css_compressed
,
variant
=
variant
)
variant
=
variant
,
**
kwargs
)
def
compile
(
self
,
paths
):
return
self
.
compiler
.
compile
(
paths
)
def
pack
(
self
,
package
,
compress
,
signal
,
**
kwargs
):
if
settings
.
PIPELINE_AUTO
or
self
.
force
or
s
elf
.
s
ync
:
def
pack
(
self
,
package
,
compress
,
signal
,
sync
=
False
,
**
kwargs
):
if
settings
.
PIPELINE_AUTO
or
self
.
force
or
sync
:
need_update
,
version
=
self
.
versioning
.
need_update
(
package
[
'output'
],
package
[
'paths'
])
if
need_update
or
self
.
force
:
...
...
@@ -68,14 +67,14 @@ class Packager(object):
content
=
compress
(
paths
,
asset_url
=
self
.
individual_url
(
output_filename
),
**
kwargs
)
self
.
save_file
(
output_filename
,
content
)
signal
.
send
(
sender
=
self
,
package
=
package
,
version
=
version
)
else
:
filename_base
,
filename
=
os
.
path
.
split
(
package
[
'output'
])
version
=
self
.
versioning
.
version_from_file
(
filename_base
,
filename
)
signal
.
send
(
sender
=
self
,
package
=
package
,
version
=
version
,
**
kwargs
)
return
self
.
versioning
.
output_filename
(
package
[
'output'
],
version
)
def
pack_javascripts
(
self
,
package
):
return
self
.
pack
(
package
,
self
.
compressor
.
compress_js
,
js_compressed
,
templates
=
package
[
'templates'
])
def
pack_javascripts
(
self
,
package
,
**
kwargs
):
return
self
.
pack
(
package
,
self
.
compressor
.
compress_js
,
js_compressed
,
templates
=
package
[
'templates'
]
,
**
kwargs
)
def
pack_templates
(
self
,
package
):
return
self
.
compressor
.
compile_templates
(
package
[
'templates'
])
...
...
pipeline/signals.py
View file @
29eee6f8
...
...
@@ -12,7 +12,9 @@ js_compressed = Signal(providing_args=["package", "version"])
@receiver
(
css_compressed
)
@receiver
(
js_compressed
)
def
invalidate_cache
(
sender
,
package
,
version
,
**
kwargs
):
def
invalidate_cache
(
sender
,
package
,
version
,
bust_cache
=
False
,
**
kwargs
):
filename_base
,
filename
=
os
.
path
.
split
(
package
[
'output'
])
if
bust_cache
:
print
"bust_cache"
cache
.
set
(
"pipeline:
%
s"
%
filename
,
str
(
version
),
settings
.
PIPELINE_CACHE_TIMEOUT
)
pipeline/versioning/__init__.py
View file @
29eee6f8
...
...
@@ -25,7 +25,7 @@ class Versioning(object):
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
regex
=
re
.
compile
(
r'^
%
s$'
%
self
.
output_filename
(
filename
,
r'([A-Za-z0-9]+)'
))
for
f
in
s
torage
.
listdir
(
path
)[
1
]
:
for
f
in
s
orted
(
storage
.
listdir
(
path
)[
1
],
reverse
=
True
)
:
match
=
regex
.
match
(
f
)
if
match
and
match
.
groups
():
version
=
match
.
group
(
1
)
...
...
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