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
9779559a
Commit
9779559a
authored
Jun 13, 2012
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #120 from pdr/master
make embed max size and embed path configurable
parents
2fe0dad3
d892b009
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
docs/configuration.rst
+17
-0
pipeline/compressors/__init__.py
+3
-5
pipeline/conf/settings.py
+3
-1
No files found.
docs/configuration.rst
View file @
9779559a
...
...
@@ -188,6 +188,23 @@ Images and fonts are embedded following these rules :
at all in Internet Explorer 8.
- If asset path contains a directory named "**embed**".
You can override these rules using the following settings:
``PIPELINE_EMBED_MAX_IMAGE_SIZE``
..........................
Setting that controls the maximum image size (in bytes) to embed in CSS using Data-URIs.
Internet Explorer 8 has issues with assets under 32 kilobytes.
Defaults to ``32700``
``PIPELINE_EMBED_PATH``
..........................
Setting the directory that an asset needs to be in so that it is embedded
Defaults to ``r'[/]?embed/'``
Rewriting CSS urls
==================
...
...
pipeline/compressors/__init__.py
View file @
9779559a
...
...
@@ -16,9 +16,6 @@ from pipeline.conf import settings
from
pipeline.utils
import
to_class
,
relpath
from
pipeline.storage
import
default_storage
MAX_IMAGE_SIZE
=
32700
EMBEDDABLE
=
r'[/]?embed/'
URL_DETECTOR
=
r'url\([\'"]?([^\s)]+\.[a-z]+[\?\#\d\w]*)[\'"]?\)'
URL_REPLACER
=
r'url\(__EMBED__(.+?)(\?\d+)?\)'
...
...
@@ -157,13 +154,14 @@ class Compressor(object):
"""Is the asset embeddable ?"""
name
,
ext
=
os
.
path
.
splitext
(
path
)
font
=
ext
in
FONT_EXTS
if
not
variant
:
return
False
if
not
(
re
.
search
(
EMBEDDABLE
,
path
)
and
self
.
storage
.
exists
(
path
)):
if
not
(
re
.
search
(
settings
.
PIPELINE_EMBED_PATH
,
path
)
and
self
.
storage
.
exists
(
path
)):
return
False
if
not
ext
in
EMBED_EXTS
:
return
False
if
not
(
font
or
len
(
self
.
encoded_content
(
path
))
<
MAX_IMAGE_SIZE
):
if
not
(
font
or
len
(
self
.
encoded_content
(
path
))
<
settings
.
PIPELINE_EMBED_
MAX_IMAGE_SIZE
):
return
False
return
True
...
...
pipeline/conf/settings.py
View file @
9779559a
from
django.conf
import
settings
PIPELINE
=
getattr
(
settings
,
'PIPELINE'
,
not
settings
.
DEBUG
)
PIPELINE_ROOT
=
getattr
(
settings
,
'PIPELINE_ROOT'
,
settings
.
STATIC_ROOT
)
PIPELINE_URL
=
getattr
(
settings
,
'PIPELINE_URL'
,
settings
.
STATIC_URL
)
...
...
@@ -56,5 +55,8 @@ PIPELINE_MIMETYPES = getattr(settings, 'PIPELINE_MIMETYPES', (
(
'text/javascript'
,
'.js'
)
))
PIPELINE_EMBED_MAX_IMAGE_SIZE
=
getattr
(
settings
,
'PIPELINE_EMBED_MAX_IMAGE_SIZE'
,
32700
)
PIPELINE_EMBED_PATH
=
getattr
(
settings
,
'PIPELINE_EMBED_PATH'
,
r'[/]?embed/'
)
if
PIPELINE_COMPILERS
is
None
:
PIPELINE_COMPILERS
=
[]
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