mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-21 22:18:04 +01:00
remove preview mode
This commit is contained in:
parent
d6c5e059d2
commit
c3ae7a5a1b
6 changed files with 0 additions and 68 deletions
|
@ -14,14 +14,5 @@ inv test
|
||||||
./src/manage.py createsuperuser
|
./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
|
# Reuse
|
||||||
If you do reuse my work, please consider linking back to this repository 🙂
|
If you do reuse my work, please consider linking back to this repository 🙂
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +1,5 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
|
||||||
|
|
||||||
|
|
||||||
def app(_):
|
def app(_):
|
||||||
return settings.APP
|
return settings.APP
|
||||||
|
|
||||||
|
|
||||||
def preview(request: WSGIRequest):
|
|
||||||
return {
|
|
||||||
"preview_enabled": request.session.get("preview", False),
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
|
||||||
from django.http import HttpResponse
|
|
||||||
|
|
||||||
|
|
||||||
def debug_toolbar_bypass_internal_ips(_) -> bool:
|
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.
|
This is impossible to predict in a docker/k8s environment so we bypass this check.
|
||||||
"""
|
"""
|
||||||
return settings.DEBUG_TOOLBAR
|
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
|
|
||||||
|
|
|
@ -97,7 +97,6 @@ MIDDLEWARE = [
|
||||||
"django.contrib.messages.middleware.MessageMiddleware",
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
"django_htmx.middleware.HtmxMiddleware",
|
"django_htmx.middleware.HtmxMiddleware",
|
||||||
"charasheet.middleware.PreviewMiddleware",
|
|
||||||
]
|
]
|
||||||
if DEBUG_TOOLBAR:
|
if DEBUG_TOOLBAR:
|
||||||
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware")
|
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware")
|
||||||
|
@ -118,7 +117,6 @@ TEMPLATES = [
|
||||||
"django.contrib.auth.context_processors.auth",
|
"django.contrib.auth.context_processors.auth",
|
||||||
"django.contrib.messages.context_processors.messages",
|
"django.contrib.messages.context_processors.messages",
|
||||||
"charasheet.context_processors.app",
|
"charasheet.context_processors.app",
|
||||||
"charasheet.context_processors.preview",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,11 +3,6 @@
|
||||||
<span>
|
<span>
|
||||||
Version : {{ build.describe }}
|
Version : {{ build.describe }}
|
||||||
• {{ build.date }}
|
• {{ build.date }}
|
||||||
{% if preview_enabled %}
|
|
||||||
• <a class="text-muted" href="?disable_preview">Disable preview</a>
|
|
||||||
{% else %}
|
|
||||||
• <a class="text-muted" href="?enable_preview">Enable preview</a>
|
|
||||||
{% endif %}
|
|
||||||
</span>
|
</span>
|
||||||
<div>
|
<div>
|
||||||
<a href="https://github.com/Crocmagnon/charasheet" class="text-muted"><i class="fa-brands fa-github"></i></a>
|
<a href="https://github.com/Crocmagnon/charasheet" class="text-muted"><i class="fa-brands fa-github"></i></a>
|
||||||
|
|
Loading…
Reference in a new issue