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
5f205fc2
Commit
5f205fc2
authored
Dec 23, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename some package property
parent
6a37fce5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
21 deletions
+17
-21
docs/configuration.rst
+1
-1
pipeline/compressors/__init__.py
+7
-9
pipeline/packager.py
+5
-7
pipeline/templatetags/compressed.py
+2
-2
tests/tests/compressor.py
+2
-2
No files found.
docs/configuration.rst
View file @
5f205fc2
...
...
@@ -92,7 +92,7 @@ Group options
For CSS, if you do not specify ``extra_context``/``media``, the default media in
the ``<link>`` output will be ``media="all"``.
``absolute_
asset_
paths``
``absolute_paths``
........................
**Optional**
...
...
pipeline/compressors/__init__.py
View file @
5f205fc2
...
...
@@ -62,10 +62,10 @@ class Compressor(object):
return
js
def
compress_css
(
self
,
paths
,
variant
=
None
,
asset_url
=
None
,
absolute_
asset_
paths
=
True
,
**
kwargs
):
absolute_paths
=
True
,
**
kwargs
):
"""Concatenate and compress CSS files"""
css
=
self
.
concatenate_and_rewrite
(
paths
,
variant
,
absolute_
asset_
paths
)
absolute_paths
)
compressor
=
self
.
css_compressor
if
compressor
:
css
=
getattr
(
compressor
(
verbose
=
self
.
verbose
),
'compress_css'
)(
css
)
...
...
@@ -117,8 +117,7 @@ class Compressor(object):
),
r"\1"
,
path
)
return
re
.
sub
(
r"[\/\\]"
,
"_"
,
name
)
def
concatenate_and_rewrite
(
self
,
paths
,
variant
=
None
,
absolute_asset_paths
=
True
):
def
concatenate_and_rewrite
(
self
,
paths
,
variant
=
None
,
absolute_paths
=
True
):
"""Concatenate together files and rewrite urls"""
stylesheets
=
[]
for
path
in
paths
:
...
...
@@ -126,8 +125,8 @@ class Compressor(object):
asset_path
=
match
.
group
(
1
)
if
asset_path
.
startswith
(
"http"
)
or
asset_path
.
startswith
(
"//"
):
return
"url(
%
s)"
%
asset_path
asset_url
=
self
.
construct_asset_path
(
asset_path
,
path
,
variant
,
absolute_asset
_paths
)
asset_url
=
self
.
construct_asset_path
(
asset_path
,
path
,
variant
,
absolute
_paths
)
return
"url(
%
s)"
%
asset_url
content
=
self
.
read_file
(
path
)
content
=
re
.
sub
(
URL_DETECTOR
,
reconstruct
,
content
)
...
...
@@ -138,13 +137,12 @@ class Compressor(object):
"""Concatenate together a list of files"""
return
'
\n
'
.
join
([
self
.
read_file
(
path
)
for
path
in
paths
])
def
construct_asset_path
(
self
,
asset_path
,
css_path
,
variant
=
None
,
absolute_asset_paths
=
True
):
def
construct_asset_path
(
self
,
asset_path
,
css_path
,
variant
=
None
,
absolute_paths
=
True
):
"""Return a rewritten asset URL for a stylesheet"""
public_path
=
self
.
absolute_path
(
asset_path
,
os
.
path
.
dirname
(
css_path
))
if
self
.
embeddable
(
public_path
,
variant
):
return
"__EMBED__
%
s"
%
public_path
if
not
absolute_
asset_
paths
:
if
not
absolute_paths
:
return
asset_path
if
not
os
.
path
.
isabs
(
asset_path
):
asset_path
=
self
.
relative_path
(
public_path
)
...
...
pipeline/packager.py
View file @
5f205fc2
...
...
@@ -26,7 +26,7 @@ class Package(object):
paths
.
append
(
str
(
path
))
self
.
_sources
=
paths
return
self
.
_sources
@property
def
paths
(
self
):
return
[
path
for
path
in
self
.
sources
...
...
@@ -38,7 +38,7 @@ class Package(object):
if
path
.
endswith
(
settings
.
PIPELINE_TEMPLATE_EXT
)]
@property
def
output
(
self
):
def
output
_filename
(
self
):
return
self
.
config
.
get
(
'output_filename'
)
@property
...
...
@@ -59,7 +59,7 @@ class Package(object):
@property
def
absolute_paths
(
self
):
return
self
.
config
.
get
(
'absolute_
asset_
paths'
,
True
)
return
self
.
config
.
get
(
'absolute_paths'
,
True
)
class
Packager
(
object
):
...
...
@@ -93,17 +93,15 @@ class Packager(object):
relative_url
)
def
pack_stylesheets
(
self
,
package
,
**
kwargs
):
variant
=
package
.
variant
absolute_asset_paths
=
package
.
absolute_paths
return
self
.
pack
(
package
,
self
.
compressor
.
compress_css
,
css_compressed
,
variant
=
variant
,
absolute_asset_paths
=
absolute_asset
_paths
,
variant
=
package
.
variant
,
absolute_paths
=
package
.
absolute
_paths
,
**
kwargs
)
def
compile
(
self
,
paths
):
return
self
.
compiler
.
compile
(
paths
)
def
pack
(
self
,
package
,
compress
,
signal
,
**
kwargs
):
output_filename
=
package
.
output
output_filename
=
package
.
output
_filename
if
self
.
verbose
:
print
"Saving:
%
s"
%
output_filename
paths
=
self
.
compile
(
package
.
paths
)
...
...
pipeline/templatetags/compressed.py
View file @
5f205fc2
...
...
@@ -29,7 +29,7 @@ class CompressedCSSNode(template.Node):
return
''
# fail silently, do not return anything if an invalid group is specified
if
settings
.
PIPELINE
:
return
self
.
render_css
(
package
,
package
.
output
)
return
self
.
render_css
(
package
,
package
.
output
_filename
)
else
:
paths
=
self
.
packager
.
compile
(
package
.
paths
)
return
self
.
render_individual
(
package
,
paths
)
...
...
@@ -64,7 +64,7 @@ class CompressedJSNode(template.Node):
return
''
# fail silently, do not return anything if an invalid group is specified
if
settings
.
PIPELINE
:
return
self
.
render_js
(
package
,
package
.
output
)
return
self
.
render_js
(
package
,
package
.
output
_filename
)
else
:
paths
=
self
.
packager
.
compile
(
package
.
paths
)
templates
=
self
.
packager
.
pack_templates
(
package
)
...
...
tests/tests/compressor.py
View file @
5f205fc2
...
...
@@ -95,11 +95,11 @@ class CompressorTest(TestCase):
def
test_construct_asset_path_relative
(
self
):
asset_path
=
self
.
compressor
.
construct_asset_path
(
"../../images/sprite.png"
,
"css/plugins/gallery.css"
,
absolute_
asset_
paths
=
False
)
absolute_paths
=
False
)
self
.
assertEquals
(
asset_path
,
"../../images/sprite.png"
)
asset_path
=
self
.
compressor
.
construct_asset_path
(
"/images/sprite.png"
,
"css/plugins/gallery.css"
,
absolute_
asset_
paths
=
False
)
absolute_paths
=
False
)
self
.
assertEquals
(
asset_path
,
"/images/sprite.png"
)
def
test_url_rewrite
(
self
):
...
...
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