##// END OF EJS Templates
Added post cache
Added post cache

File last commit:

r542:8b7899f5 1.7-dev
r557:235b44eb default
Show More
middlewares.py
40 lines | 1.2 KiB | text/x-python | PythonLexer
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210 from django.shortcuts import redirect
from boards import views, utils
from boards.models import Ban
neko259
Added a middleware to remove spaces between tags in HTML code
r444 from django.utils.html import strip_spaces_between_tags
from django.conf import settings
RESPONSE_CONTENT_TYPE = 'Content-Type'
TYPE_HTML = 'text/html'
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210
class BanMiddleware:
neko259
Added a middleware to remove spaces between tags in HTML code
r444 """
This is run before showing the thread. Banned users don't need to see
anything
"""
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210
def process_view(self, request, view_func, view_args, view_kwargs):
if view_func != views.you_are_banned:
ip = utils.get_client_ip(request)
neko259
Added ban reasons. Added write-only bans.
r340 bans = Ban.objects.filter(ip=ip)
neko259
Added ban middleware. Now banned user's won't cause load to the server.
r210
neko259
Added ban reasons. Added write-only bans.
r340 if bans.exists():
ban = bans[0]
if not ban.can_read:
neko259
Added a middleware to remove spaces between tags in HTML code
r444 return redirect(views.you_are_banned)
class MinifyHTMLMiddleware(object):
def process_response(self, request, response):
try:
compress_html = settings.COMPRESS_HTML
except AttributeError:
compress_html = False
neko259
Added style for page selectors and mode selector to the white theme. Fixed middleware issue with static files
r459 if RESPONSE_CONTENT_TYPE in response\
and TYPE_HTML in response[RESPONSE_CONTENT_TYPE] and compress_html:
neko259
Added a middleware to remove spaces between tags in HTML code
r444 response.content = strip_spaces_between_tags(
response.content.strip())
return response