-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3.0.0a1: Bump IDOM to 1.0.0 pre-release (#125)
- Modify docs to use the upcoming IDOM-Core docs styling - Move docs python examples to individual files so we can run tests on them - CI for type checking + linting docs examples - Minor wording and section naming changes to feel more React-like - Bump IDOM to 1.0.0 pre-release - Use the new `idom.html` API - Update package.json to be compatible with `idom>=1.0.0` - Make the main `requirements.txt` be fully inclusive of all dev/user/docs dependencies to simplify development workflow - Update `setup.py` to automatically install the latest NPM, and be easier to debug when things fail
- Loading branch information
1 parent
da083ac
commit 9fd30aa
Showing
86 changed files
with
1,896 additions
and
1,067 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ settings.json | |
*$py.class | ||
|
||
# Distribution / packaging | ||
build/ | ||
.Python build/ | ||
develop-eggs/ | ||
dist/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Now, you can create/modify the Django-IDOM source code, and Pull Request (PR) your changes to our GitHub repository. | ||
|
||
To learn how to create GitHub PRs, [click here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
{{ super() }} | ||
|
||
{% if git_page_authors %} | ||
<div class="md-source-date"> | ||
<small> | ||
Authors: {{ git_page_authors | default('enable mkdocs-git-authors-plugin') }} | ||
</small> | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from idom import component, html | ||
|
||
from django_idom.decorators import auth_required | ||
|
||
|
||
@component | ||
@auth_required(auth_attribute="is_staff") | ||
def my_component(): | ||
return html.div("I am logged in!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from idom import component, html | ||
|
||
from django_idom.decorators import auth_required | ||
|
||
|
||
@component | ||
def my_component_fallback(): | ||
return html.div("I am NOT logged in!") | ||
|
||
|
||
@component | ||
@auth_required(fallback=my_component_fallback) | ||
def my_component(): | ||
return html.div("I am logged in!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.contrib.auth.models import AbstractBaseUser | ||
|
||
|
||
class CustomUserModel(AbstractBaseUser): | ||
@property | ||
def is_really_cool(self): | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from idom import component, html | ||
|
||
from django_idom.decorators import auth_required | ||
|
||
|
||
@component | ||
@auth_required(auth_attribute="is_really_cool") | ||
def my_component(): | ||
return html.div("I am logged in!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from idom import component, html | ||
|
||
from django_idom.decorators import auth_required | ||
|
||
|
||
@component | ||
@auth_required(fallback=html.div("I am NOT logged in!")) | ||
def my_component(): | ||
return html.div("I am logged in!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from idom import component, html | ||
|
||
from django_idom.decorators import auth_required | ||
|
||
|
||
@component | ||
@auth_required | ||
def my_component(): | ||
return html.div("I am logged in!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
|
||
# Ensure DJANGO_SETTINGS_MODULE is set properly based on your project name! | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings") | ||
|
||
# Fetch ASGI application before importing dependencies that require ORM models. | ||
django_asgi_app = get_asgi_application() | ||
|
||
|
||
from channels.auth import AuthMiddlewareStack # noqa: E402 | ||
from channels.routing import ProtocolTypeRouter, URLRouter # noqa: E402 | ||
from channels.sessions import SessionMiddlewareStack # noqa: E402 | ||
|
||
from django_idom import IDOM_WEBSOCKET_PATH # noqa: E402 | ||
|
||
|
||
application = ProtocolTypeRouter( | ||
{ | ||
"http": django_asgi_app, | ||
"websocket": SessionMiddlewareStack( | ||
AuthMiddlewareStack(URLRouter([IDOM_WEBSOCKET_PATH])) | ||
), | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
INSTALLED_APPS = [ | ||
"daphne", | ||
..., | ||
] | ||
ASGI_APPLICATION = "example_project.asgi.application" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INSTALLED_APPS = [ | ||
"django_idom", | ||
..., | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import include, path | ||
|
||
|
||
urlpatterns = [ | ||
path("idom/", include("django_idom.http.urls")), | ||
..., | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from idom import component, html | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
html.link( | ||
{"rel": "stylesheet", "href": "https://example.com/external-styles.css"} | ||
), | ||
html.button("My Button!"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.templatetags.static import static | ||
from idom import component, html | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
html.link({"rel": "stylesheet", "href": static("css/buttons.css")}), | ||
html.button("My Button!"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from idom import component, html | ||
|
||
from django_idom.components import django_css | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
django_css("css/buttons.css"), | ||
html.button("My Button!"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.templatetags.static import static | ||
from idom import component, html | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
html.script({"src": static("js/scripts.js")}), | ||
html.button("My Button!"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from idom import component, html | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
html.script({"src": "https://example.com/external-scripts.js"}), | ||
html.button("My Button!"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from idom import component, html | ||
|
||
from django_idom.components import django_js | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
html.button("My Button!"), | ||
django_js("js/scripts.js"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from example.models import TodoItem | ||
from idom import component | ||
|
||
from django_idom.hooks import use_query | ||
from django_idom.types import QueryOptions | ||
from django_idom.utils import django_query_postprocessor | ||
|
||
|
||
def get_items(): | ||
return TodoItem.objects.all() | ||
|
||
|
||
@component | ||
def todo_list(): | ||
# These `QueryOptions` are functionally equivalent to Django-IDOM's default values | ||
item_query = use_query( | ||
QueryOptions( | ||
postprocessor=django_query_postprocessor, | ||
postprocessor_kwargs={"many_to_many": True, "many_to_one": True}, | ||
), | ||
get_items, | ||
) | ||
|
||
return item_query.data |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.db.models import CharField, Model | ||
|
||
|
||
class TodoItem(Model): | ||
text: CharField = CharField(max_length=255) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import path | ||
from example import views | ||
|
||
|
||
urlpatterns = [ | ||
path("example/", views.index), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.shortcuts import render | ||
|
||
|
||
def index(request): | ||
return render(request, "my-template.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# If "idom" cache is not configured, then "default" will be used | ||
# IDOM works best with a multiprocessing-safe and thread-safe cache backend. | ||
CACHES = { | ||
"idom": {"BACKEND": ...}, | ||
} | ||
|
||
# Maximum seconds between reconnection attempts before giving up. | ||
# Use `0` to prevent component reconnection. | ||
IDOM_RECONNECT_MAX = 259200 | ||
|
||
# The URL for IDOM to serve the component rendering websocket | ||
IDOM_WEBSOCKET_URL = "idom/" | ||
|
||
# Dotted path to the default postprocessor function, or `None` | ||
IDOM_DEFAULT_QUERY_POSTPROCESSOR = "example_project.utils.my_postprocessor" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from idom import component | ||
|
||
|
||
@component | ||
def frog_greeter(number, name, species=""): | ||
return f"Hello #{number}, {name} the {species}!" |
Oops, something went wrong.