Another Step in the Quest to clean up the code base.

This commit is contained in:
2017-09-08 07:19:50 +02:00
parent ce218080b2
commit b3ab9798b5
229 changed files with 1915 additions and 15175 deletions

View File

@@ -1,20 +1,33 @@
# -*- coding: utf-8 -*-
"""
Created on 23.05.2011
@author: christian
"""
"""This Middleware compresses the HTML Output at the End. It strips the Spaces
between Tags, an at the beginning and the end of the content."""
from django.utils.html import strip_spaces_between_tags
class CompressHtmlMiddleware(object):
"""
This Middleware compresses the HTML Output at the End. It strips the Spaces
between Tags, an at the beginning and the end of the content.
"""
"""This Middleware compresses strips the spaces between tags, and at the
beginning and the end of the content."""
# TODO: Port to django 1.10 and upward
def process_response(self, request, response):
def __init__(self, get_response):
"""
:param get_response:
"""
self.get_response = get_response
regex = ">[\s]*<"
def __call__(self, request):
"""
:param request:
:return:
"""
# Code to be executed for each request before
# the view (and later middleware) are called.
response = self.get_response(request)
if 'text/html' in response['Content-Type']:
response.content = strip_spaces_between_tags(response.content)
response.content = response.content.strip()
response.content = strip_spaces_between_tags(
response.content).strip()
return response