From 7d745cd5172fca2647011e3911eed08209fc30a8 Mon Sep 17 00:00:00 2001 From: pac7 <47831526-pac7@users.noreply.replit.com> Date: Sun, 21 Sep 2025 13:16:27 +0000 Subject: [PATCH] Integrate Django Cotton for modular frontend components Integrates django-cotton into the project by adding it to INSTALLED_APPS and pyproject.toml, and refactors base.html to use cotton components for the auth modal and toast container, creating new component files for these elements. Replit-Commit-Author: Agent Replit-Commit-Session-Id: eff39de1-3afa-446d-a965-acaf61837fc7 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d6d61dac-164d-45dd-929f-7dcdfd771b64/eff39de1-3afa-446d-a965-acaf61837fc7/jGCMVeA --- .replit | 6 +- backend/config/django/base.py | 1 + backend/pyproject.toml | 1 + backend/templates/base/base.html | 9 +- backend/templates/cotton/auth/modal.html | 377 +++++++++++++++++++++++ backend/templates/cotton/ui/toast.html | 76 +++++ backend/uv.lock | 16 +- 7 files changed, 480 insertions(+), 6 deletions(-) create mode 100644 backend/templates/cotton/auth/modal.html create mode 100644 backend/templates/cotton/ui/toast.html diff --git a/.replit b/.replit index d3cd2656..a7030e75 100644 --- a/.replit +++ b/.replit @@ -1,4 +1,4 @@ -modules = ["bash", "web", "nodejs-20", "python-3.13"] +modules = ["bash", "web", "nodejs-20", "python-3.13", "python3"] [nix] channel = "stable-25_05" @@ -39,6 +39,10 @@ externalPort = 80 localPort = 34277 externalPort = 3000 +[[ports]] +localPort = 41067 +externalPort = 3001 + [deployment] deploymentTarget = "autoscale" run = ["gunicorn", "--bind=0.0.0.0:5000", "--reuse-port", "thrillwiki.wsgi:application"] diff --git a/backend/config/django/base.py b/backend/config/django/base.py index 957b46cb..34b65ed6 100644 --- a/backend/config/django/base.py +++ b/backend/config/django/base.py @@ -96,6 +96,7 @@ THIRD_PARTY_APPS = [ "django_celery_beat", # Celery beat scheduler "django_celery_results", # Celery result backend "django_extensions", # Django Extensions for enhanced development tools + "django_cotton", # Django Cotton for component-based templates ] LOCAL_APPS = [ diff --git a/backend/pyproject.toml b/backend/pyproject.toml index d8977ac5..d103e556 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -62,6 +62,7 @@ dependencies = [ "djangorestframework-simplejwt>=5.5.1", "django-forwardemail>=1.0.0", "django-cloudflareimages-toolkit>=1.0.6", + "django-cotton>=2.1.3", ] [dependency-groups] diff --git a/backend/templates/base/base.html b/backend/templates/base/base.html index 0d3be08e..9f726a42 100644 --- a/backend/templates/base/base.html +++ b/backend/templates/base/base.html @@ -1,4 +1,5 @@ {% load static %} +{% load cotton %} @@ -127,11 +128,11 @@ - - {% include 'components/auth/auth-modal.html' %} + + - - {% include 'components/ui/toast-container.html' %} + + diff --git a/backend/templates/cotton/auth/modal.html b/backend/templates/cotton/auth/modal.html new file mode 100644 index 00000000..238fa6ae --- /dev/null +++ b/backend/templates/cotton/auth/modal.html @@ -0,0 +1,377 @@ +{% comment %} +Cotton Auth Modal Component +Converts the existing auth modal to use Django Cotton's component system +{% endcomment %} + +{% load static %} +{% load i18n %} +{% load account socialaccount %} + + + + + \ No newline at end of file diff --git a/backend/templates/cotton/ui/toast.html b/backend/templates/cotton/ui/toast.html new file mode 100644 index 00000000..1f6d67e9 --- /dev/null +++ b/backend/templates/cotton/ui/toast.html @@ -0,0 +1,76 @@ +{% comment %} +Cotton Toast Container Component +Converts the existing toast container to use Django Cotton's component system +{% endcomment %} + +{% load static %} + + + + +
+ +
\ No newline at end of file diff --git a/backend/uv.lock b/backend/uv.lock index 60fa43b9..2c29131e 100644 --- a/backend/uv.lock +++ b/backend/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.13" [[package]] @@ -642,6 +642,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/30/d8/19ed1e47badf477d17fb177c1c19b5a21da0fd2d9f093f23be3fb86c5fab/django_cors_headers-4.9.0-py3-none-any.whl", hash = "sha256:15c7f20727f90044dcee2216a9fd7303741a864865f0c3657e28b7056f61b449", size = 12809, upload-time = "2025-09-18T10:40:50.843Z" }, ] +[[package]] +name = "django-cotton" +version = "2.1.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "django" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c3/99/36e318ebd1ace3fc874541a02e7e4149def8e21aab85aceb7bb01e17607b/django_cotton-2.1.3.tar.gz", hash = "sha256:737f9c088549d7febbf78532856ddf1270799675a4bc9fa191a5db0e195a9c13", size = 23432, upload-time = "2025-06-30T17:31:29.29Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ad/ec/5e5318af0304962be43e3b912aef024d8ac08c0f9a9dfcc4f0cd55d0e74e/django_cotton-2.1.3-py3-none-any.whl", hash = "sha256:f33658d05a8f5ecf7448bdf1089e2ad27d2ce42e59c752216129701d7d153c89", size = 22214, upload-time = "2025-06-30T17:31:28.093Z" }, +] + [[package]] name = "django-debug-toolbar" version = "6.0.0" @@ -2238,6 +2250,7 @@ dependencies = [ { name = "django-cleanup" }, { name = "django-cloudflareimages-toolkit" }, { name = "django-cors-headers" }, + { name = "django-cotton" }, { name = "django-debug-toolbar" }, { name = "django-environ" }, { name = "django-extensions" }, @@ -2309,6 +2322,7 @@ requires-dist = [ { name = "django-cleanup", specifier = ">=8.0.0" }, { name = "django-cloudflareimages-toolkit", specifier = ">=1.0.6" }, { name = "django-cors-headers", specifier = ">=4.3.1" }, + { name = "django-cotton", specifier = ">=2.1.3" }, { name = "django-debug-toolbar", specifier = ">=4.0.0" }, { name = "django-environ", specifier = ">=0.12.0" }, { name = "django-extensions", specifier = ">=4.1" },