djhtmx 1.2.1__py3-none-any.whl → 1.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- djhtmx/__init__.py +1 -1
- djhtmx/repo.py +3 -14
- djhtmx/static/htmx/django.js +0 -11
- djhtmx/templates/htmx/headers.html +0 -2
- djhtmx/templatetags/htmx.py +6 -1
- djhtmx/urls.py +2 -1
- {djhtmx-1.2.1.dist-info → djhtmx-1.2.3.dist-info}/METADATA +1 -1
- {djhtmx-1.2.1.dist-info → djhtmx-1.2.3.dist-info}/RECORD +10 -10
- {djhtmx-1.2.1.dist-info → djhtmx-1.2.3.dist-info}/WHEEL +0 -0
- {djhtmx-1.2.1.dist-info → djhtmx-1.2.3.dist-info}/licenses/LICENSE +0 -0
djhtmx/__init__.py
CHANGED
djhtmx/repo.py
CHANGED
|
@@ -438,7 +438,7 @@ class Repository:
|
|
|
438
438
|
):
|
|
439
439
|
self.session.store(component)
|
|
440
440
|
|
|
441
|
-
|
|
441
|
+
final_context = {
|
|
442
442
|
"htmx_repo": self,
|
|
443
443
|
"hx_oob": oob == "true",
|
|
444
444
|
"this": component,
|
|
@@ -446,20 +446,9 @@ class Repository:
|
|
|
446
446
|
|
|
447
447
|
if lazy:
|
|
448
448
|
template = template or component._template_name_lazy
|
|
449
|
-
|
|
449
|
+
final_context |= {"hx_lazy": True} | component._get_lazy_context() | (context or {})
|
|
450
450
|
else:
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
# If context is provided, it should override the component context
|
|
454
|
-
if context is not None:
|
|
455
|
-
# Keep base_context (htmx_repo, hx_oob, this) but let provided context override everything else
|
|
456
|
-
final_context = {
|
|
457
|
-
"htmx_repo": self,
|
|
458
|
-
"hx_oob": oob == "true",
|
|
459
|
-
"this": component,
|
|
460
|
-
} | context
|
|
461
|
-
else:
|
|
462
|
-
final_context = base_context
|
|
451
|
+
final_context |= component._get_context() if context is None else context
|
|
463
452
|
|
|
464
453
|
html = mark_safe(component._get_template(template)(final_context).strip())
|
|
465
454
|
|
djhtmx/static/htmx/django.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
(function () {
|
|
2
|
-
document.body.addEventListener("htmx:configRequest", (event) => {
|
|
3
|
-
const csrf_header = document
|
|
4
|
-
.querySelector("meta[name=django-csrf-header-name]")
|
|
5
|
-
.getAttribute("content");
|
|
6
|
-
const csrf_token = document
|
|
7
|
-
.querySelector("meta[name=django-csrf-token]")
|
|
8
|
-
.getAttribute("content");
|
|
9
|
-
|
|
10
|
-
event.detail.headers[csrf_header] = csrf_token;
|
|
11
|
-
});
|
|
12
|
-
|
|
13
2
|
// WebSocket Management
|
|
14
3
|
let sentComponents = new Set();
|
|
15
4
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{% load static %}
|
|
2
2
|
|
|
3
3
|
{% if enabled %}
|
|
4
|
-
<meta name="django-csrf-header-name" content="{{ CSRF_HEADER_NAME }}" />
|
|
5
|
-
<meta name="django-csrf-token" content="{{ csrf_token }}" />
|
|
6
4
|
{% for script_url in SCRIPT_URLS %}
|
|
7
5
|
<script defer src="{% static script_url %}"></script>
|
|
8
6
|
{% endfor %}
|
djhtmx/templatetags/htmx.py
CHANGED
|
@@ -138,7 +138,12 @@ def hx_tag(context: Context):
|
|
|
138
138
|
def oob(context: Context, suffix: str):
|
|
139
139
|
oob = context.get("hx_oob")
|
|
140
140
|
context["hx_oob"] = False
|
|
141
|
-
|
|
141
|
+
if (component := context.get("this")):
|
|
142
|
+
component_id = component.id
|
|
143
|
+
else:
|
|
144
|
+
component_id = None
|
|
145
|
+
|
|
146
|
+
id = "-".join(filter(None, (component_id, suffix)))
|
|
142
147
|
return format_html_attrs({"id": id, "hx-swap-oob": "true" if oob else None})
|
|
143
148
|
|
|
144
149
|
|
djhtmx/urls.py
CHANGED
|
@@ -8,6 +8,7 @@ from django.http.request import HttpRequest
|
|
|
8
8
|
from django.http.response import HttpResponse
|
|
9
9
|
from django.urls import path, re_path
|
|
10
10
|
from django.utils.html import format_html
|
|
11
|
+
from django.views.decorators.csrf import csrf_exempt
|
|
11
12
|
|
|
12
13
|
from .commands import PushURL, ReplaceURL, SendHtml
|
|
13
14
|
from .component import REGISTRY, Destroy, DispatchDOMEvent, Focus, Open, Redirect, Triggers
|
|
@@ -95,7 +96,7 @@ def app_name_of_component(cls: type):
|
|
|
95
96
|
urlpatterns = [
|
|
96
97
|
path(
|
|
97
98
|
f"{app_name_of_component(component)}/{component_name}/<component_id>/<event_handler>",
|
|
98
|
-
partial(endpoint, component_name=component_name),
|
|
99
|
+
csrf_exempt(partial(endpoint, component_name=component_name)),
|
|
99
100
|
name=f"djhtmx.{component_name}",
|
|
100
101
|
)
|
|
101
102
|
for component_name, component in REGISTRY.items()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
djhtmx/__init__.py,sha256=
|
|
1
|
+
djhtmx/__init__.py,sha256=hbGM57sddqXSUuq33t8onRR9gAZHabW9HMdpyZVjtRA,84
|
|
2
2
|
djhtmx/apps.py,sha256=hAyjzmInEstxLY9k8Qn58LvNlezgQLx5_NqyVL1WwYs,323
|
|
3
3
|
djhtmx/command_queue.py,sha256=kiYbQFPyjnhMSR7KgO1Nu-lWiapnH511P2Pyg-Zrdq4,4862
|
|
4
4
|
djhtmx/commands.py,sha256=UxXbARd4Teetjh_zjvAWgI2KNbvdETH-WrGf4qD9Xr8,1206
|
|
@@ -11,14 +11,14 @@ djhtmx/introspection.py,sha256=flVolO6xZiXsxMm876ZCEcWRmVfFsJWpAVmIdfcJNf8,13734
|
|
|
11
11
|
djhtmx/json.py,sha256=7cjwWIJj7e0dk54INKYZJe6zKkIW7wlsNSlD05cbXfY,1374
|
|
12
12
|
djhtmx/middleware.py,sha256=JuMtv9ZnpungTvQ1qD2Lg6LiFPB3knQlA1ERgH4iGl0,1274
|
|
13
13
|
djhtmx/query.py,sha256=UyjN1jokh4wTwQJxcRwA9f-Zn-A7A4GLToeGrCnPhKA,6674
|
|
14
|
-
djhtmx/repo.py,sha256=
|
|
14
|
+
djhtmx/repo.py,sha256=SpJK6KpxK9MraN29RvShaFt3ksifBAkv_gHUrxVkzIQ,22374
|
|
15
15
|
djhtmx/settings.py,sha256=ymFUMvrcXDkYU9KkhPOjRZSQMWz5GcUjlgh07x09-1s,1242
|
|
16
16
|
djhtmx/testing.py,sha256=AdZKsT6sNTsyqSKx6EmfthOIHzSAPkTquheMfg9znbk,8301
|
|
17
17
|
djhtmx/tracing.py,sha256=xkCXb7t_3yCj1PGzmQfHPu9sYQftDKwtALaEbFVnQ1E,1260
|
|
18
|
-
djhtmx/urls.py,sha256=
|
|
18
|
+
djhtmx/urls.py,sha256=7u3Oj5coQR3aDwE3_DlEc52EKIbN8AMXoM--Zcuet0I,3960
|
|
19
19
|
djhtmx/utils.py,sha256=BcCdJHe0AqkRT_Kj-XJT_sHCpOyXtumo9mQGN2WqHek,4646
|
|
20
20
|
djhtmx/management/commands/htmx.py,sha256=tEtiJn_Z6byOFzBNIzTbdluA4T5q21zFwGvJ7yt90bw,3642
|
|
21
|
-
djhtmx/static/htmx/django.js,sha256=
|
|
21
|
+
djhtmx/static/htmx/django.js,sha256=XQgOfcqpF0Jtl9AZlrQ_tEBrNBdBj0OQ8hMFv3dLpoQ,6677
|
|
22
22
|
djhtmx/static/htmx/2.0.4/htmx.amd.js,sha256=Hgmm_X5zw7ek0pjBaxhzH7OHx6Xfce5UYVa9ICWlWR0,165593
|
|
23
23
|
djhtmx/static/htmx/2.0.4/htmx.cjs.js,sha256=4P3vh1eGwULBCT7wsKQ2bu4HiNQ_Kmnv2fP1RQ6_QW8,165586
|
|
24
24
|
djhtmx/static/htmx/2.0.4/htmx.esm.d.ts,sha256=hV0FewMl4vWgZFCX_wIpSATGkXou7o1DXOLnVhvgvJI,7330
|
|
@@ -26,11 +26,11 @@ djhtmx/static/htmx/2.0.4/htmx.esm.js,sha256=tHolTyBDgr3AbbT_ajWo1dGJCArqvxKRu55r
|
|
|
26
26
|
djhtmx/static/htmx/2.0.4/htmx.js,sha256=ywqZv5HDa9054MnUZ3xXnoIC-aWNtfDFnJAIXqDkEnU,165563
|
|
27
27
|
djhtmx/static/htmx/2.0.4/htmx.min.js,sha256=4gndpcgjVHnzFm3vx3UOHbzVpcGAi3eS_C5nM3aPtEc,50917
|
|
28
28
|
djhtmx/static/htmx/2.0.4/ext/ws.js,sha256=HwUYFqEZBvs7Tx0_O0Bi-Dcmg5UOMlbMdkJ2FWeVpDA,14609
|
|
29
|
-
djhtmx/templates/htmx/headers.html,sha256=
|
|
29
|
+
djhtmx/templates/htmx/headers.html,sha256=z7r9klwBDXDyjbHrzatZeHDvXB2DaZhgu55CFbbD3d4,159
|
|
30
30
|
djhtmx/templates/htmx/lazy.html,sha256=LfAThtKmFj-lCUZ7JWF_sC1Y6XsIpEz8A3IgWASn-J8,52
|
|
31
31
|
djhtmx/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
-
djhtmx/templatetags/htmx.py,sha256=
|
|
33
|
-
djhtmx-1.2.
|
|
34
|
-
djhtmx-1.2.
|
|
35
|
-
djhtmx-1.2.
|
|
36
|
-
djhtmx-1.2.
|
|
32
|
+
djhtmx/templatetags/htmx.py,sha256=p9y9hZ2mAq7F-9lXTY4pMmOdML7jNOwGwf-eRNdDv4g,8176
|
|
33
|
+
djhtmx-1.2.3.dist-info/METADATA,sha256=i95CIpDVornagEsXtxmri90a86BoT3ywUFcByzNcnhc,32245
|
|
34
|
+
djhtmx-1.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
35
|
+
djhtmx-1.2.3.dist-info/licenses/LICENSE,sha256=kCi_iSBUGsRZInQn96w7LXYzjiRjZ8FXl6vP--mFRPk,1085
|
|
36
|
+
djhtmx-1.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|