diff --git a/README.md b/README.md index a922024..12b1f38 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,5 @@ inv test ./src/manage.py createsuperuser ``` -## With preview mode - -```shell -caddy --config contrib/Caddyfile.local -./src/manage.py runserver -cd ~/Projects/charasheet-go -make run/live -``` - # Reuse If you do reuse my work, please consider linking back to this repository 🙂 diff --git a/contrib/Caddyfile.local b/contrib/Caddyfile.local deleted file mode 100644 index 6b2acbe..0000000 --- a/contrib/Caddyfile.local +++ /dev/null @@ -1,15 +0,0 @@ -{ - email gabriel@augendre.info - http_port 8000 -} - -http://localhost:8080 { - @preview { - header Cookie *preview=enabled;* - path /test /test/* /character/1/notes_change/ - } - route { - reverse_proxy @preview localhost:4444 - reverse_proxy localhost:8000 - } -} diff --git a/src/charasheet/context_processors.py b/src/charasheet/context_processors.py index e390646..956ba17 100644 --- a/src/charasheet/context_processors.py +++ b/src/charasheet/context_processors.py @@ -1,12 +1,5 @@ from django.conf import settings -from django.core.handlers.wsgi import WSGIRequest def app(_): return settings.APP - - -def preview(request: WSGIRequest): - return { - "preview_enabled": request.session.get("preview", False), - } diff --git a/src/charasheet/middleware.py b/src/charasheet/middleware.py index 5bdbc68..269825d 100644 --- a/src/charasheet/middleware.py +++ b/src/charasheet/middleware.py @@ -1,6 +1,4 @@ from django.conf import settings -from django.core.handlers.wsgi import WSGIRequest -from django.http import HttpResponse def debug_toolbar_bypass_internal_ips(_) -> bool: @@ -11,31 +9,3 @@ def debug_toolbar_bypass_internal_ips(_) -> bool: This is impossible to predict in a docker/k8s environment so we bypass this check. """ return settings.DEBUG_TOOLBAR - - -class PreviewMiddleware: - def __init__(self, get_response): - self.get_response = get_response - - def __call__(self, request: WSGIRequest): - enable_preview = "enable_preview" in request.GET - disable_preview = "disable_preview" in request.GET - - new_value = None - - if enable_preview: - new_value = True - elif disable_preview: - new_value = False - - if new_value is not None: - request.session["preview"] = new_value - - response: HttpResponse = self.get_response(request) - - if new_value is True: - response.set_cookie("preview", "enabled") - elif new_value is False: - response.delete_cookie("preview") - - return response diff --git a/src/charasheet/settings.py b/src/charasheet/settings.py index 783e965..9a3db4a 100644 --- a/src/charasheet/settings.py +++ b/src/charasheet/settings.py @@ -97,7 +97,6 @@ MIDDLEWARE = [ "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "django_htmx.middleware.HtmxMiddleware", - "charasheet.middleware.PreviewMiddleware", ] if DEBUG_TOOLBAR: MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") @@ -118,7 +117,6 @@ TEMPLATES = [ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "charasheet.context_processors.app", - "charasheet.context_processors.preview", ], }, }, diff --git a/src/common/templates/common/footer.html b/src/common/templates/common/footer.html index 3d6f182..bc4dd7a 100644 --- a/src/common/templates/common/footer.html +++ b/src/common/templates/common/footer.html @@ -3,11 +3,6 @@ Version : {{ build.describe }} • {{ build.date }} - {% if preview_enabled %} - • Disable preview - {% else %} - • Enable preview - {% endif %}