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
d74aefe1
Commit
d74aefe1
authored
Apr 17, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add coffee script compiler
parent
37641e12
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletions
+50
-1
compress/compilers/__init__.py
+34
-1
compress/compilers/coffee/__init__.py
+13
-0
compress/conf/settings.py
+3
-0
No files found.
compress/compilers/__init__.py
View file @
d74aefe1
import
subprocess
class
CompilerBase
(
object
):
pass
def
__init__
(
self
,
verbose
):
self
.
verbose
=
verbose
def
match_file
(
self
,
filename
):
raise
NotImplementedError
def
compile_file
(
self
,
content
):
raise
NotImplementedError
class
CompilerError
(
Exception
):
pass
class
SubProcessCompiler
(
CompilerBase
):
def
execute_command
(
self
,
command
,
content
):
pipe
=
subprocess
.
Popen
(
command
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
pipe
.
stdin
.
write
(
content
)
pipe
.
stdin
.
close
()
compressed_content
=
pipe
.
stdout
.
read
()
pipe
.
stdout
.
close
()
error
=
pipe
.
stderr
.
read
()
pipe
.
stderr
.
close
()
if
pipe
.
wait
()
!=
0
:
if
not
error
:
error
=
"Unable to apply
%
s filter"
%
self
.
__class__
.
__name__
raise
FilterError
(
error
)
if
self
.
verbose
:
print
error
return
compressed_content
compress/compilers/coffee/__init__.py
View file @
d74aefe1
from
compress.conf
import
settings
from
compress.compilers
import
SubProcessCompiler
class
CoffeeScriptCompiler
(
SubProcessCompiler
):
def
match_file
(
self
,
filename
):
return
filename
.
endswith
(
'.coffee'
)
def
compile_file
(
self
,
content
):
command
=
"
%
s
%
s"
%
(
settings
.
COFFEE_SCRIPT_BINARY
,
settings
.
COFFEE_SCRIPT_ARGUMENTS
)
if
self
.
verbose
:
command
+=
'--verbose'
return
self
.
execute_command
(
command
,
content
)
compress/conf/settings.py
View file @
d74aefe1
...
...
@@ -35,6 +35,9 @@ COMPRESS_CLOSURE_ARGUMENTS = getattr(settings, 'COMPRESS_CLOSURE_ARGUMENTS', '')
COMPRESS_UGLIFYJS_BINARY
=
getattr
(
settings
,
'COMPRESS_UGLIFYJS_BINARY'
,
'/usr/local/bin/uglifyjs'
)
COMPRESS_UGLIFYJS_ARGUMENTS
=
getattr
(
settings
,
'COMPRESS_UGLIFYJS_ARGUMENTS'
,
'-nc'
)
COMPRESS_COFFEE_SCRIPT_BINARY
=
getattr
(
settings
,
'COMPRESS_COFFEE_SCRIPT_BINARY'
,
'/usr/local/bin/coffee'
)
COFFEE_SCRIPT_ARGUMENTS
=
getattr
(
settings
,
'COFFEE_SCRIPT_ARGUMENTS'
,
'-sc'
)
if
COMPRESS_CSS_COMPRESSORS
is
None
:
COMPRESS_CSS_COMPRESSORS
=
[]
...
...
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