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
1839e954
Commit
1839e954
authored
May 20, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add html minifier middleware (thanks aaronbassett)
parent
dd9d59ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
compress/middleware.py
+12
-0
docs/usage.rst
+14
-0
No files found.
compress/middleware.py
0 → 100644
View file @
1839e954
from
django.utils.encoding
import
DjangoUnicodeDecodeError
from
django.utils.html
import
strip_spaces_between_tags
as
minify_html
class
MinifyHTMLMiddleware
(
object
):
def
process_response
(
self
,
request
,
response
):
if
'text/html'
in
response
[
'Content-Type'
]:
try
:
response
.
content
=
minify_html
(
response
.
content
.
strip
())
except
DjangoUnicodeDecodeError
:
pass
return
response
docs/usage.rst
View file @
1839e954
...
@@ -53,3 +53,17 @@ with the name “scripts”, you would use the following code to output them all
...
@@ -53,3 +53,17 @@ with the name “scripts”, you would use the following code to output them all
{% compressed_css 'screen' %}
{% compressed_css 'screen' %}
{% compressed_css 'print' %}
{% compressed_css 'print' %}
{% compressed_js 'scripts' %}
{% compressed_js 'scripts' %}
Middleware
==========
To enable HTML compression add ``compress.middleware.MinifyHTMLMiddleware``,
to your ``MIDDLEWARE_CLASSES`` settings.
Ensure that it comes after any middleware which modify your HTML, like ``GZipMiddleware`` ::
MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'compress.middleware.MinifyHTMLMiddleware',
)
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