Coder Social home page Coder Social logo

richardssen / django-conversejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tracywebtech/django-conversejs

0.0 1.0 0.0 809 KB

Convese.js now it's also in Django!

License: Apache License 2.0

Python 42.24% HTML 51.34% JavaScript 6.41%

django-conversejs's Introduction

django-conversejs

This app aims to make easier to integrate Converse.js into Django.

Currently django-conversejs provides:

  • A minified distribution of converse.js
  • Template tags to help you to include converse.js on your Django project
  • A database model to store the XMPP user and password for each user
  • Converse.js configurations through settings.py
  • Single-sign-on (SSO) like experience

Installing and configuring

Install django-conversejs:

pip install git+https://github.com/TracyWebTech/django-conversejs

Add conversejs to installed apps in your settings.py:

INSTALLED_APPS = {
    ...
    'conversejs',
    ...
}

Configure the BOSH service URL in your settings.py:

CONVERSEJS_BOSH_SERVICE_URL = 'https://my-bosh-service.com'

Load the static files in your templates using django-conversejs custom tags:

{% load conversejs %}
...
<head>
  ...
  {% conversejs_static %}
  ...
</head>

Load the chat panel and the Javascript initilizalizer also using our custom tags:

{% load conversejs %}
...

  {% conversejs_chatpanel %}
  {% conversejs_initialize %}
</body>

Update database schema:

python manage.py syncdb
python manage.py migrate # optional

Adding an XMPP account

  • Log in the Django Admin
  • Add an XMPP account by clicking in the '+ Add' button
  • Choose the user from the select box and them type the JabberID and password for the account

Now everytime the select user your logs in your site he will be automatically logged in the XMPP server using the credentials you provided.

Enabling XMPP auto registration

By enabling auto registration django-conversejs will attempt to create a new XMPP account for every user that doesn't have one as soon as they login in your site.

To enable you just need to add the CONVERSEJS_AUTO_REGISTER option to your settings.py setting it to the domain of your XMPP service. Notice that the XMPP server and the BOSH service URL are two different things.

For example:

CONVERSEJS_BOSH_SERVICE_URL = 'https://my-bosh-service.com'

CONVERSEJS_AUTO_REGISTER = 'xmpp.mycompany.com'

In the example above Django will get the username from request.user.username and try to register under the xmpp domain xmpp.mycompany.com, so if an user john logs in it would try to register [email protected].

If registration fails for any reason django-conversejs will attempt again on every request. That's something to be improved.

Forms

If you want to create custom forms to keep the look and feel of your site you can use conversejs.forms as a start point.

Converse.js Version

We currently ship Converse.js v0.6.4 (patched).

If you need a newer version, please open an issue or a pull request.

TODO

  • Write tests
  • Allow user reset XMPP account password. That's useful to allow the use of other xmpp clients.
  • Allow user to set avatar
  • Auto update XMPP name and email when those are updated in django (using signals)

django-conversejs's People

Contributors

gustjc avatar luanp avatar seocam avatar vhf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.