diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9551633 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +run: + docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env up -d + +build: + docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env build + +stop: + docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env down + +log: + docker-compose -f docker/docker-compose.prod.yml --env-file=stack.env logs -f diff --git a/core/static/django-htmx.js b/core/static/django-htmx.js index aaf8eec..12c70d5 100644 --- a/core/static/django-htmx.js +++ b/core/static/django-htmx.js @@ -1,22 +1,22 @@ { - const data = document.currentScript.dataset; - const isDebug = data.debug === "True"; + const data = document.currentScript.dataset; + const isDebug = data.debug === "True"; - if (isDebug) { - document.addEventListener("htmx:beforeOnLoad", function (event) { - const xhr = event.detail.xhr; - if (xhr.status == 500 || xhr.status == 404) { - // Tell htmx to stop processing this response - event.stopPropagation(); + if (isDebug) { + document.addEventListener("htmx:beforeOnLoad", function (event) { + const xhr = event.detail.xhr; + if (xhr.status == 500 || xhr.status == 404) { + // Tell htmx to stop processing this response + event.stopPropagation(); - document.children[0].innerHTML = xhr.response; + document.children[0].innerHTML = xhr.response; - // Run Django’s inline script - // (1, eval) wtf - see https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript - (1, eval)(document.scripts[0].innerText); - // Need to directly call Django’s onload function since browser won’t - window.onload(); - } - }); - } + // Run Django’s inline script + // (1, eval) wtf - see https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript + (1, eval)(document.scripts[0].innerText); + // Need to directly call Django’s onload function since browser won’t + window.onload(); + } + }); + } } diff --git a/core/views/base.py b/core/views/base.py index 6de8835..b14d2e7 100644 --- a/core/views/base.py +++ b/core/views/base.py @@ -23,7 +23,7 @@ class Home(View): template_name = "index.html" async def get(self, request): - # await sleep(1) + await sleep(1) return render(request, self.template_name) diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 5e78251..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM python:3 - -RUN useradd -d /code xf -RUN mkdir /code -RUN chown xf:xf /code - -RUN mkdir /venv -RUN chown xf:xf /venv - -USER xf -ENV PYTHONDONTWRITEBYTECODE=1 -ENV PYTHONUNBUFFERED=1 -WORKDIR /code -COPY requirements.dev.txt /code/ -RUN python -m venv /venv -RUN . /venv/bin/activate && pip install -r requirements.dev.txt -CMD . /venv/bin/activate && exec python manage.py runserver 0.0.0.0:8000 \ No newline at end of file diff --git a/docker/requirements.dev.txt b/docker/requirements.dev.txt deleted file mode 100644 index ac71e4a..0000000 --- a/docker/requirements.dev.txt +++ /dev/null @@ -1,12 +0,0 @@ -wheel -django -pre-commit -django-crispy-forms -crispy-bulma -stripe -django-rest-framework -django-htmx -cryptography -django-debug-toolbar -django-debug-toolbar-template-profiler -orjson