##// END OF EJS Templates
Moved signatures block to the model block. All the signed content is in the 'content' block now. Removed edit time, previous and next posts links from the XML sync output because they can be computed from the post itself and can be changed locally for foreign posts (which breaks the signature)
Moved signatures block to the model block. All the signed content is in the 'content' block now. Removed edit time, previous and next posts links from the XML sync output because they can be computed from the post itself and can be changed locally for foreign posts (which breaks the signature)

File last commit:

r721:1814d7a8 default
r838:2b96b9e7 decentral
Show More
middlewares.py
45 lines | 1.3 KiB | text/x-python | PythonLexer
from django.shortcuts import redirect
from boards import utils
from boards.models import Ban
from django.utils.html import strip_spaces_between_tags
from django.conf import settings
from boards.views.banned import BannedView
RESPONSE_CONTENT_TYPE = 'Content-Type'
TYPE_HTML = 'text/html'
class BanMiddleware:
"""
This is run before showing the thread. Banned users don't need to see
anything
"""
def __init__(self):
pass
def process_view(self, request, view_func, view_args, view_kwargs):
if view_func != BannedView.as_view:
ip = utils.get_client_ip(request)
bans = Ban.objects.filter(ip=ip)
if bans.exists():
ban = bans[0]
if not ban.can_read:
return redirect('banned')
class MinifyHTMLMiddleware(object):
def process_response(self, request, response):
try:
compress_html = settings.COMPRESS_HTML
except AttributeError:
compress_html = False
if RESPONSE_CONTENT_TYPE in response\
and TYPE_HTML in response[RESPONSE_CONTENT_TYPE]\
and compress_html:
response.content = strip_spaces_between_tags(
response.content.strip())
return response