Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
spellcheck using v0.2.2
  • Loading branch information
Archmonger committed Nov 2, 2022
commit 40e1268749e3afdee38037a480bdfff016b9e3bf
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Using the following categories, list your changes in this order:
### Fixed

- Change type hint on `view_to_component` callable to have `request` argument be optional.
- Change type hint on `view_to_component` to represent it as a decorator with parenthesis (ex `@view_to_component(compatibility=True)`)
- Change type hint on `view_to_component` to represent it as a decorator with parenthesis (such as `@view_to_component(compatibility=True)`)

### Security

Expand Down Expand Up @@ -137,7 +137,7 @@ Using the following categories, list your changes in this order:

- Ability to declare the HTML class of the top-level component `div`
- `name = ...` parameter to IDOM HTTP paths for use with `django.urls.reverse()`
- Cache versioning to automatically invalidate old web module files from the cache backend
- Cache versioning to automatically invalidate old web module files from the cache back-end
- Automatic pre-population of the IDOM component registry
- Type hinting for `IdomWebsocket`

Expand All @@ -153,7 +153,7 @@ Using the following categories, list your changes in this order:

- `IDOM_WEB_MODULES_PATH` has been replaced with Django `include(...)`
- `IDOM_WS_MAX_RECONNECT_DELAY` has been renamed to `IDOM_WS_MAX_RECONNECT_TIMEOUT`
- `idom_web_modules` cache backend has been renamed to `idom`
- `idom_web_modules` cache back-end has been renamed to `idom`

### Fixed

Expand All @@ -162,7 +162,7 @@ Using the following categories, list your changes in this order:

### Security

- Fixed potential directory travesal attack on the IDOM web modules URL
- Fixed potential directory traversal attack on the IDOM web modules URL

## [0.0.1] - 2021-08-18

Expand Down
20 changes: 20 additions & 0 deletions docs/src/dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
django
nox
websocket
websockets
changelog
async
pre
prefetch
preloader
whitespace
refetch
refetched
refetching
html
jupyter
webserver
iframe
keyworded
stylesheet
stylesheets
unstyled
py
idom
asgi
24 changes: 12 additions & 12 deletions docs/src/features/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## View To Component

Convert any Django view into a IDOM component by usng this decorator. Compatible with [Function Based Views](https://docs.djangoproject.com/en/dev/topics/http/views/) and [Class Based Views](https://docs.djangoproject.com/en/dev/topics/class-based-views/). Views can be sync or async.
Convert any Django view into a IDOM component by using this decorator. Compatible with [Function Based Views](https://docs.djangoproject.com/en/dev/topics/http/views/) and [Class Based Views](https://docs.djangoproject.com/en/dev/topics/class-based-views/). Views can be sync or async.

=== "components.py"

Expand All @@ -30,10 +30,10 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| view | `Callable | View` | The view function or class to convert. | N/A |
| compatibility | `bool` | If True, the component will be rendered in an iframe. When using compatibility mode `tranforms`, `strict_parsing`, `request`, `args`, and `kwargs` arguments will be ignored. | `False` |
| transforms | `Sequence[Callable[[VdomDict], Any]]` | A list of functions that transforms the newly generated VDOM. The functions will be called on each VDOM node. | `tuple` |
| strict_parsing | `bool` | If True, an exception will be generated if the HTML does not perfectly adhere to HTML5. | `True` |
| `view` | `Callable | View` | The view function or class to convert. | N/A |
| `compatibility` | `bool` | If True, the component will be rendered in an iframe. When using compatibility mode `tranforms`, `strict_parsing`, `request`, `args`, and `kwargs` arguments will be ignored. | `False` |
| `transforms` | `Sequence[Callable[[VdomDict], Any]]` | A list of functions that transforms the newly generated VDOM. The functions will be called on each VDOM node. | `tuple` |
| `strict_parsing` | `bool` | If True, an exception will be generated if the HTML does not perfectly adhere to HTML5. | `True` |

<font size="4">**Returns**</font>

Expand All @@ -47,7 +47,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible

It is your responsibility to ensure privileged information is not leaked via this method.

This can be done via directly writing conditionals into your view, or by adding decorators such as [user_passes_test](https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.decorators.user_passes_test) to your views prior to using `view_to_component`.
This can be done via directly writing conditionals into your view, or by adding decorators such as [`user_passes_test`](https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.decorators.user_passes_test) to your views prior to using `view_to_component`.

=== "Function Based View"

Expand Down Expand Up @@ -78,7 +78,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
- Requires manual intervention to change request methods beyond `GET`.
- IDOM events cannot conveniently be attached to converted view HTML.
- Does not currently load any HTML contained with a `<head>` tag
- Has no option to automatically intercept local anchor link (ex. `#!html <a href='example/'></a>`) click events
- Has no option to automatically intercept local anchor link (such as `#!html <a href='example/'></a>`) click events

_Please note these limitations do not exist when using `compatibility` mode._

Expand Down Expand Up @@ -303,8 +303,8 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| static_path | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
| key | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |
| `static_path` | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
| `key` | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |

<font size="4">**Returns**</font>

Expand All @@ -318,7 +318,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.

??? question "Can I load static CSS using `html.link` instead?"

While you can load stylesheets with `html.link`, keep in mind that loading this way **does not** ensure load order. Thus, your stylesheet will be loaded after your component is displayed. This would likely cause some visual jankiness, so use this at your own discretion.
While you can load stylesheets with `html.link`, keep in mind that loading this way **does not** ensure load order. Thus, your stylesheet will be loaded after your component is displayed. This would likely cause unintended visual behavior, so use this at your own discretion.

Here's an example on what you should avoid doing for Django static files:

Expand Down Expand Up @@ -381,8 +381,8 @@ Allows you to defer loading JavaScript until a component begins rendering. This

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| static_path | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
| key | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |
| `static_path` | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
| `key` | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |

<font size="4">**Returns**</font>

Expand Down
4 changes: 2 additions & 2 deletions docs/src/features/decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ This decorator can be used with or without parentheses.

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| auth_attribute | `str` | The value to check within the user object. This is checked in the form of `UserModel.<auth_attribute>`. | `#!python "is_active"` |
| fallback | `ComponentType`, `VdomDict`, `None` | The `component` or `idom.html` snippet to render if the user is not authenticated. | `None` |
| `auth_attribute` | `str` | The value to check within the user object. This is checked in the form of `UserModel.<auth_attribute>`. | `#!python "is_active"` |
| `fallback` | `ComponentType`, `VdomDict`, `None` | The `component` or `idom.html` snippet to render if the user is not authenticated. | `None` |

<font size="4">**Returns**</font>

Expand Down
18 changes: 9 additions & 9 deletions docs/src/features/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ The function you provide into this hook must return either a `Model` or `QuerySe

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| query | `Callable[_Params, _Result | None]` | A callable that returns a Django `Model` or `QuerySet`. | N/A |
| *args | `_Params.args` | Positional arguments to pass into `query`. | N/A |
| **kwargs | `_Params.kwargs` | Keyword arguments to pass into `query`. | N/A |
| `query` | `Callable[_Params, _Result | None]` | A callable that returns a Django `Model` or `QuerySet`. | N/A |
| `*args` | `_Params.args` | Positional arguments to pass into `query`. | N/A |
| `**kwargs` | `_Params.kwargs` | Keyword arguments to pass into `query`. | N/A |

<font size="4">**Returns**</font>

| Type | Description |
| --- | --- |
| `Query[_Result | None]` | A dataclass containing `loading`/`error` states, your `data` (if the query has successfully executed), and a `refetch` callable that can be used to re-run the query. |
| `Query[_Result | None]` | An object containing `loading`/`error` states, your `data` (if the query has successfully executed), and a `refetch` callable that can be used to re-run the query. |

??? question "Can I make ORM calls without hooks?"

Due to Django's ORM design, database queries must be deferred using hooks. Otherwise, you will see a `SynchronousOnlyOperation` exception.

This may be resolved in a future version of Django with a natively asynchronous ORM.
This may be resolved in a future version of Django containing an asynchronous ORM.

??? question "Why does the example `get_items` function return a `Model` or `QuerySet`?"

Expand Down Expand Up @@ -128,14 +128,14 @@ The function you provide into this hook will have no return value.

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| mutate | `Callable[_Params, bool | None]` | A callable that performs Django ORM create, update, or delete functionality. If this function returns `False`, then your `refetch` function will not be used. | N/A |
| refetch | `Callable[..., Any] | Sequence[Callable[..., Any]] | None` | A `query` function (used by the `use_query` hook) or a sequence of `query` functions that will be called if the mutation succeeds. This is useful for refetching data after a mutation has been performed. | `None` |
| `mutate` | `Callable[_Params, bool | None]` | A callable that performs Django ORM create, update, or delete functionality. If this function returns `False`, then your `refetch` function will not be used. | N/A |
| `refetch` | `Callable[..., Any] | Sequence[Callable[..., Any]] | None` | A `query` function (used by the `use_query` hook) or a sequence of `query` functions that will be called if the mutation succeeds. This is useful for refetching data after a mutation has been performed. | `None` |

<font size="4">**Returns**</font>

| Type | Description |
| --- | --- |
| `Mutation[_Params]` | A dataclass containing `loading`/`error` states, a `reset` callable that will set `loading`/`error` states to defaults, and a `execute` callable that will run the query. |
| `Mutation[_Params]` | An object containing `loading`/`error` states, a `reset` callable that will set `loading`/`error` states to defaults, and a `execute` callable that will run the query. |

??? question "Can `use_mutation` trigger a refetch of `use_query`?"

Expand Down Expand Up @@ -240,7 +240,7 @@ The function you provide into this hook will have no return value.

Due to Django's ORM design, database queries must be deferred using hooks. Otherwise, you will see a `SynchronousOnlyOperation` exception.

This may be resolved in a future version of Django with a natively asynchronous ORM.
This may be resolved in a future version of Django containing an asynchronous ORM.

However, even when resolved it is best practice to perform ORM queries within the `use_query` in order to handle `loading` and `error` states.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/features/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!--settings-start-->

```python linenums="1"
# If "idom" cache is not configured, then we'll use "default" instead
# If "idom" cache is not configured, then we will use "default" instead
CACHES = {
"idom": {"BACKEND": ...},
}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/features/templatetag.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| dotted_path | `str` | The dotted path to the component to render. | N/A |
| **kwargs | `Any` | The keyword arguments to pass to the component. | N/A |
| `dotted_path` | `str` | The dotted path to the component to render. | N/A |
| `**kwargs` | `Any` | The keyword arguments to pass to the component. | N/A |

<font size="4">**Returns**</font>

Expand Down
2 changes: 1 addition & 1 deletion docs/src/getting-started/initial-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For the examples within this section, we will assume you have placed the files [

Django-IDOM has no project structure requirements. Organize everything as you wish, just like any **Django project**.

??? question "I've never used Django, what do I need to learn?"
??? question "I have never used Django, what do I need to learn?"

{% include-markdown "../installation/index.md" start="<!--dj-proj-start-->" end="<!--dj-proj-end-->" %}

Expand Down
4 changes: 2 additions & 2 deletions docs/src/installation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pip install django-idom
```

You'll also need to modify a few files in your **Django project**...
You will also need to modify a few files in your **Django project**...

---

Expand Down Expand Up @@ -97,6 +97,6 @@ Register IDOM's Websocket using `IDOM_WEBSOCKET_PATH`.
)
```

??? question "Where is my asgi.py?"
??? question "Where is my `asgi.py`?"

If you do not have an `asgi.py`, follow the [`channels` installation guide](https://channels.readthedocs.io/en/stable/installation.html).