summaryrefslogtreecommitdiffstats
path: root/askbot/middleware
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-09-16 22:48:36 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-09-16 22:48:36 -0400
commit8325c5f8e01ddf5b63c816e49f62d574b1cbb9cf (patch)
tree3009509cb43f2b55bd114581501d14697e1cea50 /askbot/middleware
parent3b928e835597a156e2d1b1155bcb2859f98c0b83 (diff)
downloadaskbot-8325c5f8e01ddf5b63c816e49f62d574b1cbb9cf.tar.gz
askbot-8325c5f8e01ddf5b63c816e49f62d574b1cbb9cf.tar.bz2
askbot-8325c5f8e01ddf5b63c816e49f62d574b1cbb9cf.zip
added username/password, facebook, twitter and linkedin logins, ability to add and delete login methods
Diffstat (limited to 'askbot/middleware')
-rw-r--r--askbot/middleware/spaceless.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/askbot/middleware/spaceless.py b/askbot/middleware/spaceless.py
index 16b11522..9e6b5503 100644
--- a/askbot/middleware/spaceless.py
+++ b/askbot/middleware/spaceless.py
@@ -3,13 +3,24 @@ Middleware that strips whitespace between html tags
copied from David Cramer's blog
http://www.davidcramer.net/code/369/spaceless-html-in-django.html
"""
-from django.utils.html import strip_spaces_between_tags as short
-
+import re
+from django.utils.functional import allow_lazy
+from django.utils.encoding import force_unicode
+
+def reduce_spaces_between_tags(value):
+ """Returns the given HTML with all spaces between tags removed.
+ ,but one. One space is left so that consecutive links and other things
+ do not appear glued together
+ slight mod of django.utils.html import strip_spaces_between_tags
+ """
+ return re.sub(r'>\s+<', '> <', force_unicode(value))
+reduce_spaces_between_tags = allow_lazy(reduce_spaces_between_tags, unicode)
+
class SpacelessMiddleware(object):
def process_response(self, request, response):
"""strips whitespace from all documents
whose content type is text/html
"""
if 'text/html' in response['Content-Type']:
- response.content = short(response.content)
+ response.content = reduce_spaces_between_tags(response.content)
return response