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
af5e6672
Commit
af5e6672
authored
Nov 14, 2008
by
Sander Smits
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enabled COMPRESS_VERSION=True and COMPRESS_AUTO=False
parent
99c86bbf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
compress/templatetags/compressed.py
+10
-2
compress/utils.py
+9
-2
No files found.
compress/templatetags/compressed.py
View file @
af5e6672
...
...
@@ -5,7 +5,7 @@ from django import template
from
django.conf
import
settings
as
django_settings
from
compress.conf
import
settings
from
compress.utils
import
media_root
,
media_url
,
needs_update
,
filter_css
,
filter_js
,
get_output_filename
,
get_version
from
compress.utils
import
media_root
,
media_url
,
needs_update
,
filter_css
,
filter_js
,
get_output_filename
,
get_version
,
get_version_from_file
register
=
template
.
Library
()
...
...
@@ -45,7 +45,11 @@ class CompressedCSSNode(template.Node):
css
[
'source_filenames'
])
if
u
:
filter_css
(
css
)
else
:
filename_base
,
filename
=
os
.
path
.
split
(
css
[
'output_filename'
])
path_name
=
media_root
(
filename_base
)
version
=
get_version_from_file
(
path_name
,
filename
)
return
render_css
(
css
,
css
[
'output_filename'
],
version
)
else
:
# output source files
...
...
@@ -76,6 +80,10 @@ class CompressedJSNode(template.Node):
js
[
'source_filenames'
])
if
u
:
filter_js
(
js
)
else
:
filename_base
,
filename
=
os
.
path
.
split
(
js
[
'output_filename'
])
path_name
=
media_root
(
filename_base
)
version
=
get_version_from_file
(
path_name
,
filename
)
return
render_js
(
js
,
js
[
'output_filename'
],
version
)
else
:
...
...
compress/utils.py
View file @
af5e6672
...
...
@@ -51,7 +51,7 @@ def needs_update(output_file, source_files, verbosity=0):
if
not
os
.
path
.
exists
(
compressed_file_full
):
return
True
,
version
update_needed
=
getattr
(
get_class
(
settings
.
COMPRESS_VERSIONING
)(
verbose
=
(
verbosity
>=
2
)
),
'needs_update'
)(
output_file
,
source_files
,
version
)
update_needed
=
getattr
(
get_class
(
settings
.
COMPRESS_VERSIONING
)(),
'needs_update'
)(
output_file
,
source_files
,
version
)
return
update_needed
def
media_root
(
filename
):
...
...
@@ -90,8 +90,15 @@ def get_output_filename(filename, version):
return
filename
.
replace
(
settings
.
COMPRESS_VERSION_PLACEHOLDER
,
settings
.
COMPRESS_VERSION_DEFAULT
)
def
get_version
(
source_files
,
verbosity
=
0
):
version
=
getattr
(
get_class
(
settings
.
COMPRESS_VERSIONING
)(
verbose
=
(
verbosity
>=
2
)
),
'get_version'
)(
source_files
)
version
=
getattr
(
get_class
(
settings
.
COMPRESS_VERSIONING
)(),
'get_version'
)(
source_files
)
return
version
def
get_version_from_file
(
path
,
filename
):
regex
=
re
.
compile
(
r'^
%
s$'
%
(
os
.
path
.
basename
(
get_output_filename
(
settings
.
COMPRESS_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
COMPRESS_VERSION_PLACEHOLDER
)]),
r'([A-Za-z0-9]+)'
))))
for
f
in
os
.
listdir
(
path
):
result
=
regex
.
match
(
f
)
if
result
and
result
.
groups
():
return
result
.
groups
()[
0
]
def
remove_files
(
path
,
filename
,
verbosity
=
0
):
regex
=
re
.
compile
(
r'^
%
s$'
%
(
os
.
path
.
basename
(
get_output_filename
(
settings
.
COMPRESS_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
COMPRESS_VERSION_PLACEHOLDER
)]),
r'[A-Za-z0-9]+'
))))
...
...
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