Skip to content

Django IDOM #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [rmorshea]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Documentation
url: https://idom-docs.herokuapp.com/
about: Refer to the documentation before starting a discussion
- name: Community Support
url: https://github.com/idom-team/idom/discussions
about: Report issues, request features, and ask questions
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * *"

jobs:
test-python-versions:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- uses: nanasess/setup-chromedriver@master
- uses: actions/setup-node@v2-beta
with:
node-version: "14"
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: pip install -r requirements/test-run.txt
- name: Run Tests
run: |
npm install -g [email protected]
nox -s test
128 changes: 128 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Django #
logs
*.log
*.pot
*.pyc
.dccachea
__pycache__
db.sqlite3
media
cache
static-deploy
data
settings.json

# Backup files #
*.bak

# If you are using PyCharm #
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/gradle.xml
.idea/**/libraries
*.iws /out/

# Python #
*.py[cod]
*$py.class

# Distribution / packaging
.Python build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery
celerybeat-schedule.*

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Sublime Text #
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project

# sftp configuration file
sftp-config.json

# Package control specific files Package
Control.last-run
Control.ca-list
Control.ca-bundle
Control.system-ca-bundle
GitHub.sublime-settings

# Visual Studio Code #
.vscode
.vscode/*
.vscode/settings.json
.vscode/tasks.json
.vscode/launch.json
.vscode/extensions.json
.history
%SystemDrive%

# Mac file system
.DS_Store
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
# Django IDOM

Support for IDOM in Django
<a href="https://github.com/idom-team/django-idom/actions?query=workflow%3ATest">
<img alt="Tests" src="https://github.com/idom-team/django-idom/workflows/Test/badge.svg?event=push" />
</a>
<a href="https://pypi.python.org/pypi/django-idom">
<img alt="Version Info" src="https://img.shields.io/pypi/v/idom.svg"/>
</a>
<a href="https://github.com/idom-team/django-idom/blob/main/LICENSE">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-purple.svg">
</a>

A package for building highly interactive user interfaces in pure Python inspired by
[ReactJS](https://reactjs.org/).

**Be sure to [read the IDOM Documentation](https://idom-docs.herokuapp.com)!**

If you have ideas or find a bug, be sure to post an
[issue](https://github.com/idom-team/django-idom/issues)
or create a
[pull request](https://github.com/idom-team/django-idom/pulls). Thanks in advance!

<h3>
<a
target="_blank"
href="https://mybinder.org/v2/gh/idom-team/idom-jupyter/main?filepath=notebooks%2Fintroduction.ipynb"
>
Try it Now
<img alt="Binder" valign="bottom" height="25px"
src="https://mybinder.org/badge_logo.svg"
/>
</a>
</h3>

Click the badge above to get started! It will take you to a [Jupyter Notebooks](https://jupyter.org/)
hosted by [Binder](https://mybinder.org/) with some great examples.

### Or Install it Now

```bash
pip install django-idom
```

# Django Integration

This version of IDOM can be directly integrated into Django. For example

```python
# Example code goes here
```

For examples on how to use IDOM, [read the IDOM Documentation](https://idom-docs.herokuapp.com).
75 changes: 75 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from __future__ import annotations

import os
import re
import subprocess
from pathlib import Path
from typing import List, Tuple

import nox
from nox.sessions import Session


HERE = Path(__file__).parent
POSARGS_PATTERN = re.compile(r"^(\w+)\[(.+)\]$")


@nox.session(reuse_venv=True)
def manage(session: Session) -> None:
session.install("-r", "requirements.txt")
session.install("idom[stable]")
session.install("-e", ".")
session.chdir("tests")

build_js_on_commands = ["runserver"]
if set(session.posargs).intersection(build_js_on_commands):
session.run("python", "manage.py", "build_js")

session.run("python", "manage.py", *session.posargs)


@nox.session(reuse_venv=True)
def format(session: Session) -> None:
install_requirements_file(session, "check-style")
session.run("black", ".")
session.run("isort", ".")


@nox.session
def test(session: Session) -> None:
"""Run the complete test suite"""
session.install("--upgrade", "pip", "setuptools", "wheel")
session.notify("test_suite")
session.notify("test_style")


@nox.session
def test_suite(session: Session) -> None:
"""Run the Python-based test suite"""
session.env["IDOM_DEBUG_MODE"] = "1"
install_requirements_file(session, "test-env")
session.install(".[all]")
session.chdir("tests")
session.run("figure-it-out")


@nox.session
def test_style(session: Session) -> None:
"""Check that style guidelines are being followed"""
install_requirements_file(session, "check-style")
session.run("flake8", "src/django_idom", "tests")
black_default_exclude = r"\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist"
session.run(
"black",
".",
"--check",
"--exclude",
rf"/({black_default_exclude}|venv|node_modules)/",
)
session.run("isort", ".", "--check-only")


def install_requirements_file(session: Session, name: str) -> None:
file_path = HERE / "requirements" / (name + ".txt")
assert file_path.exists(), f"requirements file {file_path} does not exist"
session.install("-r", str(file_path))
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

[tool.isort]
multi_line_output = 3
force_grid_wrap = 0
use_parentheses = "True"
ensure_newline_before_comments = "True"
include_trailing_comma = "True"
line_length = 88
lines_after_imports = 2
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r requirements/pkg-deps.txt
-r requirements/check-style.txt
-r requirements/test-env.txt
-r requirements/test-run.txt
3 changes: 3 additions & 0 deletions requirements/check-style.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
black
flake8
isort
2 changes: 2 additions & 0 deletions requirements/pkg-deps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
channels<4.0.0 # Django websocket features
idom<1.0.0 # Python React
1 change: 1 addition & 0 deletions requirements/test-env.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
django
1 change: 1 addition & 0 deletions requirements/test-run.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nox
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[bdist_wheel]
universal=1

[flake8]
ignore = E203, E266, E501, W503, F811, N802
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B9,N,ROH
exclude =
.eggs/*
.nox/*
Loading