From 01cbb71c3249aa1285c3c25a09b688c713a4f932 Mon Sep 17 00:00:00 2001 From: Ashley Wilson Date: Fri, 16 Oct 2015 13:22:25 +0100 Subject: [PATCH 1/3] Capture attributes on HEAD tag --- responsive/middleware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/responsive/middleware.py b/responsive/middleware.py index 2821634..df3a17f 100644 --- a/responsive/middleware.py +++ b/responsive/middleware.py @@ -56,8 +56,8 @@ def process_response(self, request, response): 'cookie_age': 60 * 60 * 24 * settings.RESPONSIVE_COOKIE_AGE, # convert to secs 'cookie_expires': expires.strftime('%a, %d %b %Y %H:%M:%S GMT') }) - pattern = re.compile(b'', re.IGNORECASE) - response.content = pattern.sub(b'' + smart_bytes(snippet), response.content) + pattern = re.compile(r'', re.IGNORECASE) + response.content = pattern.sub(r'>' + smart_bytes(snippet), response.content) if response.get('Content-Length', None): response['Content-Length'] = len(response.content) From f3ee433020e0c7cbcecdfbe6e6b5b02cd612dcbb Mon Sep 17 00:00:00 2001 From: Ashley Wilson Date: Fri, 16 Oct 2015 14:56:44 +0100 Subject: [PATCH 2/3] Change raw string to bytestring Fixes support for Python 3 --- responsive/middleware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/responsive/middleware.py b/responsive/middleware.py index df3a17f..ce0e1c0 100644 --- a/responsive/middleware.py +++ b/responsive/middleware.py @@ -56,8 +56,8 @@ def process_response(self, request, response): 'cookie_age': 60 * 60 * 24 * settings.RESPONSIVE_COOKIE_AGE, # convert to secs 'cookie_expires': expires.strftime('%a, %d %b %Y %H:%M:%S GMT') }) - pattern = re.compile(r'', re.IGNORECASE) - response.content = pattern.sub(r'>' + smart_bytes(snippet), response.content) + pattern = re.compile(b'', re.IGNORECASE) + response.content = pattern.sub(b'>' + smart_bytes(snippet), response.content) if response.get('Content-Length', None): response['Content-Length'] = len(response.content) From f9ae1cfc0cf5522182f6c44e56ac071fc6c25f70 Mon Sep 17 00:00:00 2001 From: Ashley Wilson Date: Fri, 16 Oct 2015 14:57:28 +0100 Subject: [PATCH 3/3] Add me to the contributors --- AUTHORS.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index f7561a6..e852d78 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -16,5 +16,4 @@ Development Lead Contributors ------------ -None yet. Why not be the first? - +* Ashley Wilson