django-chit-chat


Namedjango-chit-chat JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/ckc-org/django-chit-chat
Summarychat for projects we help maintain @ ckc
upload_time2022-08-30 22:26:18
maintainer
docs_urlNone
authorBailey Trefts
requires_python>=3.8
license
keywords django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            django-chit-chat [<img src="https://ckcollab.com/assets/images/badges/badge.svg" alt="CKC" height="20">](https://ckcollab.com)
==========
chat for projects we help maintain @ [ckc](https://ckcollab.com)


## installing

```bash
pip install django-chit-chat
```

```python
# settings.py
INSTALLED_APPS = (
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.staticfiles",

    # ... add chit_chat
    "chit_chat",
)
```

```python
# routing.py
from channels.auth import AuthMiddlewareStack
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter

import chit_chat.routing


application = ProtocolTypeRouter({
    'http': get_asgi_application(),
    'websocket': AuthMiddlewareStack(
        URLRouter(
            chit_chat.routing.websocket_urlpatterns
        )
    ),
})
```

```python
# urls.py
from rest_framework import routers

from chit_chat.viewsets import RoomViewSet


router = routers.SimpleRouter()
router.register('chatrooms', RoomViewSet)

urlpatterns = router.urls
```

```html
<!-- chat.html -->

<script>
    // Open a connection to django-chit-chat
    YourWebsocketThing.open(`wss://${window.location.host}/ws/chatroom/`)
    
    // Write messages to screen as they're sent/received
    YourWebsocketThing.onmessage(msg => writeMessageToScreen(JSON.parse(msg.data)))
    
    // You can do a GET to "/api/chatrooms/" for a list of chatrooms + messages
    $.get("/api/chat/rooms").success(d => ...)
    
    // Send a message
    function send_message(text) {
        WSClient.send(JSON.stringify({
            message_type: "chat",
            room: 1, // ID of chat room
            text: text
        }))
    }
</script>
```


## tests

```bash
$ docker build -t django-chit-chat . && docker run django-chit-chat pytest
```


## Releasing

1. Update version number in `setup.cfg`.
2. [Create release using Github's UI](https://github.com/ckc-org/django-chit-chat/releases/new). 
   - Click the `Choose a tag` dropdown and create a new tag with the new version number.
   - Click the `Generate release notes` button to automatically create release notes.
   - This will trigger an action to build and push the release to PyPi.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ckc-org/django-chit-chat",
    "name": "django-chit-chat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "django",
    "author": "Bailey Trefts",
    "author_email": "bailey@ckcollab.com",
    "download_url": "https://files.pythonhosted.org/packages/d9/d2/7e784c90833e4abd471a2e47a685fca439744ccdd5e534402cad06c556f6/django-chit-chat-0.0.9.tar.gz",
    "platform": null,
    "description": "django-chit-chat [<img src=\"https://ckcollab.com/assets/images/badges/badge.svg\" alt=\"CKC\" height=\"20\">](https://ckcollab.com)\n==========\nchat for projects we help maintain @ [ckc](https://ckcollab.com)\n\n\n## installing\n\n```bash\npip install django-chit-chat\n```\n\n```python\n# settings.py\nINSTALLED_APPS = (\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.staticfiles\",\n\n    # ... add chit_chat\n    \"chit_chat\",\n)\n```\n\n```python\n# routing.py\nfrom channels.auth import AuthMiddlewareStack\nfrom django.core.asgi import get_asgi_application\nfrom channels.routing import ProtocolTypeRouter, URLRouter\n\nimport chit_chat.routing\n\n\napplication = ProtocolTypeRouter({\n    'http': get_asgi_application(),\n    'websocket': AuthMiddlewareStack(\n        URLRouter(\n            chit_chat.routing.websocket_urlpatterns\n        )\n    ),\n})\n```\n\n```python\n# urls.py\nfrom rest_framework import routers\n\nfrom chit_chat.viewsets import RoomViewSet\n\n\nrouter = routers.SimpleRouter()\nrouter.register('chatrooms', RoomViewSet)\n\nurlpatterns = router.urls\n```\n\n```html\n<!-- chat.html -->\n\n<script>\n    // Open a connection to django-chit-chat\n    YourWebsocketThing.open(`wss://${window.location.host}/ws/chatroom/`)\n    \n    // Write messages to screen as they're sent/received\n    YourWebsocketThing.onmessage(msg => writeMessageToScreen(JSON.parse(msg.data)))\n    \n    // You can do a GET to \"/api/chatrooms/\" for a list of chatrooms + messages\n    $.get(\"/api/chat/rooms\").success(d => ...)\n    \n    // Send a message\n    function send_message(text) {\n        WSClient.send(JSON.stringify({\n            message_type: \"chat\",\n            room: 1, // ID of chat room\n            text: text\n        }))\n    }\n</script>\n```\n\n\n## tests\n\n```bash\n$ docker build -t django-chit-chat . && docker run django-chit-chat pytest\n```\n\n\n## Releasing\n\n1. Update version number in `setup.cfg`.\n2. [Create release using Github's UI](https://github.com/ckc-org/django-chit-chat/releases/new). \n   - Click the `Choose a tag` dropdown and create a new tag with the new version number.\n   - Click the `Generate release notes` button to automatically create release notes.\n   - This will trigger an action to build and push the release to PyPi.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "chat for projects we help maintain @ ckc",
    "version": "0.0.9",
    "split_keywords": [
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "d0cd82ef7f4e1c4f2610ce644d7851cb",
                "sha256": "ff8a78a5e555465273730fcfc9c62291264e23fef7c4400f0bd31b7ac56df314"
            },
            "downloads": -1,
            "filename": "django_chit_chat-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0cd82ef7f4e1c4f2610ce644d7851cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19419,
            "upload_time": "2022-08-30T22:26:16",
            "upload_time_iso_8601": "2022-08-30T22:26:16.629522Z",
            "url": "https://files.pythonhosted.org/packages/53/60/0046be4a61b85b603a562530603d65d0d77de849dd9edf77739cb7472f04/django_chit_chat-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "b4a9dc783a4369b58021d1a077e57808",
                "sha256": "fc562895ee287e1f540c53a432ba11a54cd70a3e31e4f4180935e773e6f9158a"
            },
            "downloads": -1,
            "filename": "django-chit-chat-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "b4a9dc783a4369b58021d1a077e57808",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14140,
            "upload_time": "2022-08-30T22:26:18",
            "upload_time_iso_8601": "2022-08-30T22:26:18.235820Z",
            "url": "https://files.pythonhosted.org/packages/d9/d2/7e784c90833e4abd471a2e47a685fca439744ccdd5e534402cad06c556f6/django-chit-chat-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-08-30 22:26:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ckc-org",
    "github_project": "django-chit-chat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "django-chit-chat"
}
        
Elapsed time: 0.41580s