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
96d6d9fd
Commit
96d6d9fd
authored
Jul 27, 2011
by
Kyle MacFarlane
Committed by
Timothée Peignier
Jul 27, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improving windows support
Signed-off-by: Timothée Peignier <timothee.peignier@tryphon.org>
parent
e91abcb2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
45 deletions
+37
-45
pipeline/compilers/less/__init__.py
+15
-19
pipeline/compressors/__init__.py
+6
-1
pipeline/compressors/csstidy/__init__.py
+12
-21
pipeline/conf/settings.py
+3
-3
pipeline/templatetags/compressed.py
+1
-1
No files found.
pipeline/compilers/less/__init__.py
View file @
96d6d9fd
...
@@ -2,33 +2,29 @@ import os
...
@@ -2,33 +2,29 @@ import os
import
tempfile
import
tempfile
from
pipeline.conf
import
settings
from
pipeline.conf
import
settings
from
pipeline.compilers
import
CompilerBase
from
pipeline.compilers
import
SubProcessCompiler
class
LessCompiler
(
CompilerBase
):
class
LessCompiler
(
SubProcessCompiler
):
output_extension
=
'css'
output_extension
=
'css'
def
match_file
(
self
,
filename
):
def
match_file
(
self
,
filename
):
return
filename
.
endswith
(
'.less'
)
return
filename
.
endswith
(
'.less'
)
def
compile_file
(
self
,
content
):
def
compile_file
(
self
,
content
):
tmp_file
=
tempfile
.
NamedTemporaryFile
(
mode
=
'w+b'
)
in_file
,
in_filename
=
tempfile
.
mkstemp
(
)
tmp_file
.
write
(
content
)
in_file
=
os
.
fdopen
(
in_file
,
'w+b'
)
tmp_file
.
flush
(
)
in_file
.
write
(
content
)
in_file
.
flush
()
output_file
=
tempfile
.
NamedTemporaryFile
(
mode
=
'w+b'
)
command
=
'
%
s
%
s
%
s'
%
(
command
=
'
%
s
%
s
%
s
%
s'
%
(
settings
.
PIPELINE_LESS_BINARY
,
settings
.
PIPELINE_LESS_BINARY
,
tmp_file
.
name
,
in_file
name
,
settings
.
PIPELINE_LESS_ARGUMENTS
,
output_file
.
name
settings
.
PIPELINE_LESS_ARGUMENTS
)
)
content
=
self
.
execute_command
(
command
,
content
)
command_output
=
os
.
popen
(
command
)
.
read
()
in_file
.
close
()
os
.
remove
(
in_filename
)
compiled_content
=
output_file
.
read
()
output_file
.
close
()
tmp_file
.
close
()
if
self
.
verbose
:
return
content
print
command_output
return
compiled_content
pipeline/compressors/__init__.py
View file @
96d6d9fd
...
@@ -4,6 +4,8 @@ import re
...
@@ -4,6 +4,8 @@ import re
import
subprocess
import
subprocess
import
urlparse
import
urlparse
from
django.utils.encoding
import
filepath_to_uri
from
pipeline.conf
import
settings
from
pipeline.conf
import
settings
from
pipeline.storage
import
storage
from
pipeline.storage
import
storage
from
pipeline.utils
import
to_class
from
pipeline.utils
import
to_class
...
@@ -128,7 +130,10 @@ class Compressor(object):
...
@@ -128,7 +130,10 @@ class Compressor(object):
return
"__EMBED__
%
s"
%
public_path
return
"__EMBED__
%
s"
%
public_path
if
not
os
.
path
.
isabs
(
asset_path
):
if
not
os
.
path
.
isabs
(
asset_path
):
asset_path
=
self
.
relative_path
(
public_path
)
asset_path
=
self
.
relative_path
(
public_path
)
return
urlparse
.
urljoin
(
settings
.
PIPELINE_URL
,
asset_path
[
1
:])
return
urlparse
.
urljoin
(
settings
.
PIPELINE_URL
,
filepath_to_uri
(
asset_path
[
1
:])
)
def
embeddable
(
self
,
path
,
variant
):
def
embeddable
(
self
,
path
,
variant
):
"""Is the asset embeddable ?"""
"""Is the asset embeddable ?"""
...
...
pipeline/compressors/csstidy/__init__.py
View file @
96d6d9fd
import
os
import
os
import
warnings
import
tempfile
import
tempfile
from
pipeline.conf
import
settings
from
pipeline.conf
import
settings
from
pipeline.compressors
import
CompressorBase
from
pipeline.compressors
import
SubProcessCompressor
warnings
.
simplefilter
(
'ignore'
,
RuntimeWarning
)
class
CSSTidyCompressor
(
SubProcessCompressor
):
class
CSSTidyCompressor
(
CompressorBase
):
def
compress_css
(
self
,
css
):
def
compress_css
(
self
,
css
):
tmp_file
=
tempfile
.
NamedTemporaryFile
(
mode
=
'w+b'
)
out_file
,
out_filename
=
tempfile
.
mkstemp
()
tmp_file
.
write
(
css
)
out_file
=
os
.
fdopen
(
out_file
,
'rb'
)
tmp_file
.
flush
()
output_file
=
tempfile
.
NamedTemporaryFile
(
mode
=
'w+b'
)
command
=
'
%
s
%
s
%
s
%
s'
%
(
command
=
'
%
s -
%
s
%
s'
%
(
settings
.
PIPELINE_CSSTIDY_BINARY
,
tmp_file
.
name
,
settings
.
PIPELINE_CSSTIDY_BINARY
,
settings
.
PIPELINE_CSSTIDY_ARGUMENTS
,
output_file
.
name
settings
.
PIPELINE_CSSTIDY_ARGUMENTS
,
out_filename
)
)
self
.
execute_command
(
command
,
css
)
command_output
=
os
.
popen
(
command
)
.
read
()
filtered_css
=
out_file
.
read
()
out_file
.
close
()
filtered_css
=
output_file
.
read
()
os
.
remove
(
out_filename
)
output_file
.
close
()
tmp_file
.
close
()
if
self
.
verbose
:
print
command_output
return
filtered_css
return
filtered_css
pipeline/conf/settings.py
View file @
96d6d9fd
...
@@ -33,8 +33,8 @@ PIPELINE_TEMPLATE_NAMESPACE = getattr(settings, 'PIPELINE_TEMPLATE_NAMESPACE', "
...
@@ -33,8 +33,8 @@ PIPELINE_TEMPLATE_NAMESPACE = getattr(settings, 'PIPELINE_TEMPLATE_NAMESPACE', "
PIPELINE_TEMPLATE_EXT
=
getattr
(
settings
,
'PIPELINE_TEMPLATE_EXT'
,
".jst"
)
PIPELINE_TEMPLATE_EXT
=
getattr
(
settings
,
'PIPELINE_TEMPLATE_EXT'
,
".jst"
)
PIPELINE_TEMPLATE_FUNC
=
getattr
(
settings
,
'PIPELINE_TEMPLATE_FUNC'
,
"_.template"
)
PIPELINE_TEMPLATE_FUNC
=
getattr
(
settings
,
'PIPELINE_TEMPLATE_FUNC'
,
"_.template"
)
PIPELINE_CSSTIDY_BINARY
=
'/usr/local/bin/csstidy'
PIPELINE_CSSTIDY_BINARY
=
getattr
(
settings
,
'PIPELINE_CSSTIDY_BINARY'
,
'/usr/local/bin/csstidy'
)
PIPELINE_CSSTIDY_ARGUMENTS
=
'--template=highest'
PIPELINE_CSSTIDY_ARGUMENTS
=
getattr
(
settings
,
'PIPELINE_CSSTIDY_ARGUMENTS'
,
'--template=highest'
)
PIPELINE_YUI_BINARY
=
getattr
(
settings
,
'PIPELINE_YUI_BINARY'
,
'/usr/local/bin/yuicompressor'
)
PIPELINE_YUI_BINARY
=
getattr
(
settings
,
'PIPELINE_YUI_BINARY'
,
'/usr/local/bin/yuicompressor'
)
PIPELINE_YUI_CSS_ARGUMENTS
=
getattr
(
settings
,
'PIPELINE_YUI_CSS_ARGUMENTS'
,
''
)
PIPELINE_YUI_CSS_ARGUMENTS
=
getattr
(
settings
,
'PIPELINE_YUI_CSS_ARGUMENTS'
,
''
)
...
@@ -53,7 +53,7 @@ PIPELINE_SASS_BINARY = getattr(settings, 'PIPELINE_SASS_BINARY', '/usr/local/bin
...
@@ -53,7 +53,7 @@ PIPELINE_SASS_BINARY = getattr(settings, 'PIPELINE_SASS_BINARY', '/usr/local/bin
PIPELINE_SASS_ARGUMENTS
=
getattr
(
settings
,
'PIPELINE_SASS_ARGUMENTS'
,
''
)
PIPELINE_SASS_ARGUMENTS
=
getattr
(
settings
,
'PIPELINE_SASS_ARGUMENTS'
,
''
)
PIPELINE_LESS_BINARY
=
getattr
(
settings
,
'PIPELINE_LESS_BINARY'
,
'/usr/local/bin/lessc'
)
PIPELINE_LESS_BINARY
=
getattr
(
settings
,
'PIPELINE_LESS_BINARY'
,
'/usr/local/bin/lessc'
)
PIPELINE_LESS_ARGUMENTS
=
getattr
(
settings
,
'PIPELINE_LESS_ARGUMENTS'
,
''
)
PIPELINE_LESS_ARGUMENTS
=
getattr
(
settings
,
'PIPELINE_LESS_ARGUMENTS'
,
'
-x
'
)
if
PIPELINE_COMPILERS
is
None
:
if
PIPELINE_COMPILERS
is
None
:
PIPELINE_COMPILERS
=
[]
PIPELINE_COMPILERS
=
[]
pipeline/templatetags/compressed.py
View file @
96d6d9fd
...
@@ -30,7 +30,7 @@ class CompressedCSSNode(template.Node):
...
@@ -30,7 +30,7 @@ class CompressedCSSNode(template.Node):
context
=
{}
context
=
{}
if
not
'template'
in
package
:
if
not
'template'
in
package
:
package
[
'template'
]
=
"pipeline/css.html"
package
[
'template'
]
=
"pipeline/css.html"
if
not
'context'
in
package
:
if
'context'
in
package
:
context
=
package
[
'context'
]
context
=
package
[
'context'
]
context
.
update
({
context
.
update
({
'url'
:
self
.
packager
.
individual_url
(
path
)
'url'
:
self
.
packager
.
individual_url
(
path
)
...
...
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