django-critiqs 0.4.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Noah Jung
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.5
2
+ Name: django-critiqs
3
+ Version: 0.4.0
4
+ Summary: Critiqs for Django: reviewers comment directly on a running prototype, discuss feedback, and find its context.
5
+ Project-URL: Homepage, https://github.com/noahsjung/critiqs/tree/main/packages/django#readme
6
+ Project-URL: Issues, https://github.com/noahsjung/critiqs/issues
7
+ Project-URL: Source, https://github.com/noahsjung/critiqs
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: comments,design review,django,feedback,prototype,review
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 5.2
13
+ Classifier: Framework :: Django :: 6.0
14
+ Classifier: Framework :: Django :: 6.1
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: django>=5.2
19
+ Provides-Extra: test
20
+ Requires-Dist: pytest>=8; extra == 'test'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Critiqs for Django
24
+
25
+ Reviewers comment directly on a running prototype, discuss feedback, and find
26
+ its original context as the prototype changes. Critiqs brings its own toolbar,
27
+ sidebar, sign-in, and styles; it draws above your pages in its own shadow root
28
+ and needs no JavaScript build. Django 5.2 or later, Python 3.10 or later.
29
+
30
+ ## Set up
31
+
32
+ ```sh
33
+ pip install django-critiqs
34
+ ```
35
+
36
+ Add the app, after `django.contrib.staticfiles`:
37
+
38
+ ```python
39
+ INSTALLED_APPS = [
40
+ # ...
41
+ "django.contrib.staticfiles",
42
+ "django_critiqs",
43
+ ]
44
+ ```
45
+
46
+ Render Critiqs in the template every page extends, usually
47
+ `templates/base.html`, just before `</body>`:
48
+
49
+ ```django
50
+ {% load critiqs %}
51
+ <!DOCTYPE html>
52
+ <html>
53
+ <body>
54
+ {% block content %}{% endblock %}
55
+ {% critiqs %}
56
+ </body>
57
+ </html>
58
+ ```
59
+
60
+ Set the project ID in each deployment's environment:
61
+
62
+ ```sh
63
+ CRITIQS_PROJECT_ID=<project ID>
64
+ ```
65
+
66
+ Django reads it on each request. Where it is unset, `{% critiqs %}` renders
67
+ nothing, so production or any copy without a project shows no Critiqs. The
68
+ project ID is public configuration, not a secret. For the development server,
69
+ `npx critiqs init` adds a default to `manage.py`, beside Django's own
70
+ `DJANGO_SETTINGS_MODULE` one, which an environment variable still overrides:
71
+
72
+ ```python
73
+ os.environ.setdefault("CRITIQS_PROJECT_ID", "<project ID>")
74
+ ```
75
+
76
+ A deployment's WSGI or ASGI server doesn't run `manage.py`, so it still
77
+ shows Critiqs only where `CRITIQS_PROJECT_ID` is set.
78
+
79
+ Critiqs's script is a static file (`critiqs/element.js`), so run
80
+ `python manage.py collectstatic` when you deploy, as for your own static files.
81
+
82
+ ## Settings
83
+
84
+ All optional, in a `CRITIQS` dict in your settings:
85
+
86
+ ```python
87
+ CRITIQS = {
88
+ "PROJECT_ID": "<project ID>", # instead of CRITIQS_PROJECT_ID
89
+ "REQUIRE_PROJECT_ID": True, # False: show project setup where no ID is set
90
+ "BACKEND": "https://<deployment>.convex.cloud", # your team's own backend
91
+ "VERSION": "v1.4.0", # recorded with each message, such as a Git commit
92
+ }
93
+ ```
94
+
95
+ `PROJECT_ID` set to `None` means no project, even when `CRITIQS_PROJECT_ID`
96
+ is set. Django's system checks warn about keys Critiqs doesn't read.
97
+
98
+ ## Screens and routes
99
+
100
+ Each page tells Critiqs which screen it shows, so a thread left on one user's
101
+ page names the page `users/:id` rather than `/users/42`. By default the screen
102
+ is the matched `path()` pattern with converters as `:name` (`<path:…>` as
103
+ `:name*`), the root is `/`, and the route's parameters become view state, such
104
+ as `route.id = "42"`. Name the screen yourself when the pattern isn't the right
105
+ one, or for `re_path()` routes, which report no screen of their own:
106
+
107
+ ```django
108
+ {% critiqs screen="user-details" %}
109
+ ```
110
+
111
+ An empty or undefined `screen` falls back to the pattern.
112
+
113
+ Opening a thread on a server-rendered app is a full page load, so there is
114
+ nothing to set up for it. An app that wants the page's path back from a thread
115
+ can build it with `routePath` from the `critiqs` npm package.
116
+
117
+ ## Content Security Policy
118
+
119
+ Critiqs's two scripts (its bundle, and the inline one that reports the
120
+ screen) carry your page's nonce when you use Django's own CSP support (Django
121
+ 6.0 or later, with the `csp` context processor or the CSP middleware) or
122
+ django-csp. Without a nonce, a policy that blocks inline scripts stops only
123
+ the screen report: threads then name the URL path. Allow `connect-src` to your
124
+ Critiqs backend.
125
+
126
+ ## License
127
+
128
+ MIT
@@ -0,0 +1,106 @@
1
+ # Critiqs for Django
2
+
3
+ Reviewers comment directly on a running prototype, discuss feedback, and find
4
+ its original context as the prototype changes. Critiqs brings its own toolbar,
5
+ sidebar, sign-in, and styles; it draws above your pages in its own shadow root
6
+ and needs no JavaScript build. Django 5.2 or later, Python 3.10 or later.
7
+
8
+ ## Set up
9
+
10
+ ```sh
11
+ pip install django-critiqs
12
+ ```
13
+
14
+ Add the app, after `django.contrib.staticfiles`:
15
+
16
+ ```python
17
+ INSTALLED_APPS = [
18
+ # ...
19
+ "django.contrib.staticfiles",
20
+ "django_critiqs",
21
+ ]
22
+ ```
23
+
24
+ Render Critiqs in the template every page extends, usually
25
+ `templates/base.html`, just before `</body>`:
26
+
27
+ ```django
28
+ {% load critiqs %}
29
+ <!DOCTYPE html>
30
+ <html>
31
+ <body>
32
+ {% block content %}{% endblock %}
33
+ {% critiqs %}
34
+ </body>
35
+ </html>
36
+ ```
37
+
38
+ Set the project ID in each deployment's environment:
39
+
40
+ ```sh
41
+ CRITIQS_PROJECT_ID=<project ID>
42
+ ```
43
+
44
+ Django reads it on each request. Where it is unset, `{% critiqs %}` renders
45
+ nothing, so production or any copy without a project shows no Critiqs. The
46
+ project ID is public configuration, not a secret. For the development server,
47
+ `npx critiqs init` adds a default to `manage.py`, beside Django's own
48
+ `DJANGO_SETTINGS_MODULE` one, which an environment variable still overrides:
49
+
50
+ ```python
51
+ os.environ.setdefault("CRITIQS_PROJECT_ID", "<project ID>")
52
+ ```
53
+
54
+ A deployment's WSGI or ASGI server doesn't run `manage.py`, so it still
55
+ shows Critiqs only where `CRITIQS_PROJECT_ID` is set.
56
+
57
+ Critiqs's script is a static file (`critiqs/element.js`), so run
58
+ `python manage.py collectstatic` when you deploy, as for your own static files.
59
+
60
+ ## Settings
61
+
62
+ All optional, in a `CRITIQS` dict in your settings:
63
+
64
+ ```python
65
+ CRITIQS = {
66
+ "PROJECT_ID": "<project ID>", # instead of CRITIQS_PROJECT_ID
67
+ "REQUIRE_PROJECT_ID": True, # False: show project setup where no ID is set
68
+ "BACKEND": "https://<deployment>.convex.cloud", # your team's own backend
69
+ "VERSION": "v1.4.0", # recorded with each message, such as a Git commit
70
+ }
71
+ ```
72
+
73
+ `PROJECT_ID` set to `None` means no project, even when `CRITIQS_PROJECT_ID`
74
+ is set. Django's system checks warn about keys Critiqs doesn't read.
75
+
76
+ ## Screens and routes
77
+
78
+ Each page tells Critiqs which screen it shows, so a thread left on one user's
79
+ page names the page `users/:id` rather than `/users/42`. By default the screen
80
+ is the matched `path()` pattern with converters as `:name` (`<path:…>` as
81
+ `:name*`), the root is `/`, and the route's parameters become view state, such
82
+ as `route.id = "42"`. Name the screen yourself when the pattern isn't the right
83
+ one, or for `re_path()` routes, which report no screen of their own:
84
+
85
+ ```django
86
+ {% critiqs screen="user-details" %}
87
+ ```
88
+
89
+ An empty or undefined `screen` falls back to the pattern.
90
+
91
+ Opening a thread on a server-rendered app is a full page load, so there is
92
+ nothing to set up for it. An app that wants the page's path back from a thread
93
+ can build it with `routePath` from the `critiqs` npm package.
94
+
95
+ ## Content Security Policy
96
+
97
+ Critiqs's two scripts (its bundle, and the inline one that reports the
98
+ screen) carry your page's nonce when you use Django's own CSP support (Django
99
+ 6.0 or later, with the `csp` context processor or the CSP middleware) or
100
+ django-csp. Without a nonce, a policy that blocks inline scripts stops only
101
+ the screen report: threads then name the URL path. Allow `connect-src` to your
102
+ Critiqs backend.
103
+
104
+ ## License
105
+
106
+ MIT
@@ -0,0 +1,29 @@
1
+ """Puts Critiqs's browser bundle (element.js from the `critiqs` npm package)
2
+ in the package as a static file. In the repository it comes from
3
+ packages/critiqs/dist, which `bun run build` makes; an sdist already holds it.
4
+ """
5
+
6
+ from pathlib import Path
7
+
8
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
9
+
10
+ BUNDLE = "django_critiqs/static/critiqs/element.js"
11
+
12
+
13
+ class CustomBuildHook(BuildHookInterface):
14
+ def initialize(self, version, build_data):
15
+ if version == "editable":
16
+ return
17
+ root = Path(self.root)
18
+ # hatchling adds the nearest .gitignore to every sdist; here that is the
19
+ # repository's, which says nothing about this package.
20
+ for path in [path for path in build_data["force_include"] if Path(path).name == ".gitignore" and Path(path).parent != root]:
21
+ del build_data["force_include"][path]
22
+ built = root.parent / "critiqs" / "dist" / "element.js"
23
+ if built.is_file():
24
+ target = BUNDLE if self.target_name == "wheel" else f"src/{BUNDLE}"
25
+ build_data["force_include"][str(built)] = target
26
+ elif not (root / "src" / BUNDLE).is_file():
27
+ raise FileNotFoundError(
28
+ f"Critiqs's browser bundle is missing: build it first with `bun run build` in {root.parent / 'critiqs'}."
29
+ )
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "critiqs-django",
3
+ "version": "0.4.0",
4
+ "private": true,
5
+ "description": "Workspace marker for the django-critiqs Python package: Changesets bumps this version and pyproject.toml reads it.",
6
+ "critiqsRelease": {
7
+ "registry": "pypi"
8
+ },
9
+ "scripts": {
10
+ "test": "bun scripts/tasks.ts test",
11
+ "release:build": "bun scripts/tasks.ts release",
12
+ "check:consumer": "bun scripts/check-consumer.ts"
13
+ }
14
+ }
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "django-critiqs"
7
+ dynamic = ["version"]
8
+ description = "Critiqs for Django: reviewers comment directly on a running prototype, discuss feedback, and find its context."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ dependencies = ["Django>=5.2"]
14
+ keywords = ["feedback", "comments", "review", "prototype", "design review", "django"]
15
+ classifiers = [
16
+ "Framework :: Django",
17
+ "Framework :: Django :: 5.2",
18
+ "Framework :: Django :: 6.0",
19
+ "Framework :: Django :: 6.1",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ ]
23
+
24
+ [project.optional-dependencies]
25
+ test = ["pytest>=8"]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/noahsjung/critiqs/tree/main/packages/django#readme"
29
+ Issues = "https://github.com/noahsjung/critiqs/issues"
30
+ Source = "https://github.com/noahsjung/critiqs"
31
+
32
+ # The version lives in package.json, which Changesets bumps with every other
33
+ # Critiqs package; hatchling's built-in regex source reads it.
34
+ [tool.hatch.version]
35
+ path = "package.json"
36
+ pattern = '"version":\s*"(?P<version>[^"]+)"'
37
+
38
+ # hatch_build.py puts Critiqs's browser bundle in the package.
39
+ [tool.hatch.build.hooks.custom]
40
+
41
+ [tool.hatch.build.targets.wheel]
42
+ packages = ["src/django_critiqs"]
43
+
44
+ [tool.hatch.build.targets.sdist]
45
+ include = ["/src", "/tests", "/hatch_build.py", "/package.json", "/README.md", "/LICENSE"]
46
+
47
+ [tool.pytest.ini_options]
48
+ pythonpath = ["src", "."]
49
+ testpaths = ["tests"]
@@ -0,0 +1,2 @@
1
+ """Critiqs for Django: add "django_critiqs" to INSTALLED_APPS, then
2
+ {% load critiqs %}{% critiqs %} in the base template."""
@@ -0,0 +1,12 @@
1
+ from django.apps import AppConfig
2
+ from django.core import checks
3
+
4
+ from .conf import check_settings
5
+
6
+
7
+ class CritiqsConfig(AppConfig):
8
+ name = "django_critiqs"
9
+ verbose_name = "Critiqs"
10
+
11
+ def ready(self):
12
+ checks.register(check_settings)
@@ -0,0 +1,52 @@
1
+ """Critiqs's settings: the CRITIQS dict in Django settings, with the project
2
+ ID read from the CRITIQS_PROJECT_ID environment variable when the dict doesn't
3
+ name one."""
4
+
5
+ import os
6
+ from dataclasses import dataclass
7
+
8
+ from django.conf import settings
9
+ from django.core import checks
10
+
11
+ ENV_VARIABLE = "CRITIQS_PROJECT_ID"
12
+ KEYS = {"PROJECT_ID", "REQUIRE_PROJECT_ID", "BACKEND", "VERSION"}
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class CritiqsSettings:
17
+ # None renders nothing when required, and project setup otherwise.
18
+ project_id: str | None
19
+ require_project_id: bool
20
+ backend: str | None
21
+ version: str | None
22
+
23
+
24
+ def _text(value):
25
+ return None if value is None or str(value) == "" else str(value)
26
+
27
+
28
+ def read_settings():
29
+ configured = getattr(settings, "CRITIQS", None) or {}
30
+ project_id = configured["PROJECT_ID"] if "PROJECT_ID" in configured else os.environ.get(ENV_VARIABLE)
31
+ return CritiqsSettings(
32
+ project_id=_text(project_id),
33
+ require_project_id=bool(configured.get("REQUIRE_PROJECT_ID", True)),
34
+ backend=_text(configured.get("BACKEND")),
35
+ version=_text(configured.get("VERSION")),
36
+ )
37
+
38
+
39
+ def check_settings(app_configs=None, **kwargs):
40
+ configured = getattr(settings, "CRITIQS", None)
41
+ if configured is None:
42
+ return []
43
+ if not isinstance(configured, dict):
44
+ return [checks.Error("CRITIQS must be a dict.", id="django_critiqs.E001")]
45
+ return [
46
+ checks.Warning(
47
+ f"CRITIQS has an unknown key {key!r}.",
48
+ hint=f"Critiqs reads {', '.join(sorted(KEYS))}.",
49
+ id="django_critiqs.W001",
50
+ )
51
+ for key in sorted(set(configured) - KEYS, key=str)
52
+ ]