Begin reimplementing compose

This commit is contained in:
2026-03-12 00:12:57 +00:00
parent 1570f79b62
commit 79766d279d
56 changed files with 2726 additions and 6271 deletions

View File

@@ -13,6 +13,8 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
import os
from pathlib import Path
TRUE_VALUES = {"1", "true", "yes", "on"}
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -36,8 +38,6 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"debug_toolbar",
"template_profiler_panel",
"django_htmx",
"crispy_forms",
"crispy_bulma",
@@ -57,6 +57,16 @@ INSTALLED_APPS = [
"cachalot",
]
DEBUG_TOOLBAR_ENABLED = os.getenv("DEBUG_TOOLBAR_ENABLED", "false").lower() in TRUE_VALUES
if DEBUG_TOOLBAR_ENABLED:
INSTALLED_APPS.extend(
[
"debug_toolbar",
"template_profiler_panel",
]
)
# Performance optimisations
CACHES = {
"default": {
@@ -81,7 +91,6 @@ CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
DJANGO_TABLES2_TEMPLATE = "django-tables2/bulma.html"
MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
# 'django.middleware.cache.UpdateCacheMiddleware',
@@ -95,6 +104,9 @@ MIDDLEWARE = [
"django_htmx.middleware.HtmxMiddleware",
]
if DEBUG_TOOLBAR_ENABLED:
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware")
ROOT_URLCONF = "app.urls"
ASGI_APPLICATION = "app.asgi.application"
COMPOSE_WS_ENABLED = os.environ.get("COMPOSE_WS_ENABLED", "false").lower() in {
@@ -104,20 +116,24 @@ COMPOSE_WS_ENABLED = os.environ.get("COMPOSE_WS_ENABLED", "false").lower() in {
"on",
}
TEMPLATE_CONTEXT_PROCESSORS = [
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"core.util.django_settings_export.settings_export",
"core.context_processors.settings_hierarchy_nav",
]
if DEBUG_TOOLBAR_ENABLED:
TEMPLATE_CONTEXT_PROCESSORS.insert(0, "django.template.context_processors.debug")
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "core/templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"core.util.django_settings_export.settings_export",
"core.context_processors.settings_hierarchy_nav",
],
"context_processors": TEMPLATE_CONTEXT_PROCESSORS,
},
},
]
@@ -230,7 +246,7 @@ if PROFILER: # noqa - trust me its there
def show_toolbar(request):
return DEBUG # noqa: from local imports
return DEBUG and DEBUG_TOOLBAR_ENABLED # noqa: from local imports
DEBUG_TOOLBAR_CONFIG = {

View File

@@ -49,7 +49,6 @@ from core.views import (
)
urlpatterns = [
path("__debug__/", include("debug_toolbar.urls")),
path(
"favicon.ico",
RedirectView.as_view(url=f"{settings.STATIC_URL}favicon.ico", permanent=False),
@@ -358,11 +357,6 @@ urlpatterns = [
compose.ComposeThread.as_view(),
name="compose_thread",
),
path(
"compose/history-sync/",
compose.ComposeHistorySync.as_view(),
name="compose_history_sync",
),
path(
"compose/commands/bp/bind/",
compose.ComposeBindBP.as_view(),
@@ -808,3 +802,6 @@ urlpatterns = [
name="queue_delete",
),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if getattr(settings, "DEBUG_TOOLBAR_ENABLED", False):
urlpatterns.insert(0, path("__debug__/", include("debug_toolbar.urls")))