├── intercom
├── templatetags
│ ├── __init__.py
│ └── intercom_tags.py
├── __init__.py
└── templates
│ └── intercom
│ └── _intercom_js.html
├── MANIFEST.in
├── README.rst
├── .travis.yml
├── docs
├── installation.rst
├── changelog.rst
├── index.rst
├── conf.py
├── usage.rst
└── Makefile
├── LICENSE
└── setup.py
/intercom/templatetags/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/intercom/__init__.py:
--------------------------------------------------------------------------------
1 | __version__ = "1.0.0"
2 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include README.rst
2 | recursive-include intercom/templates *.html
3 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | ==================
2 | django-intercom-io
3 | ==================
4 |
5 | A pluggable app for adding `intercom.io `_ to your Django site.
6 |
7 | Documentation can be found at http://django-intercom-io.rtfd.org.
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: python
2 |
3 | python:
4 | - 2.7
5 |
6 | install:
7 | - pip install flake8
8 | - pip install -e .
9 |
10 | script:
11 | - flake8 --max-line-length=100 --max-complexity=10 --statistics --benchmark intercom
12 |
--------------------------------------------------------------------------------
/docs/installation.rst:
--------------------------------------------------------------------------------
1 | .. _installation:
2 |
3 | Installation
4 | ============
5 |
6 | * To install ::
7 |
8 | pip install django-intercom-io
9 |
10 | * Add ``"intercom"`` to your ``INSTALLED_APPS`` setting::
11 |
12 | INSTALLED_APPS = [
13 | # other apps
14 | "intercom",
15 | ]
16 |
--------------------------------------------------------------------------------
/docs/changelog.rst:
--------------------------------------------------------------------------------
1 | .. _changelog:
2 |
3 | ChangeLog
4 | =========
5 |
6 | 0.4
7 | ---
8 |
9 | - change has function to use user.pk instead of email address
10 |
11 | 0.3
12 | ---
13 |
14 | - add user id
15 |
16 |
17 | 0.2
18 | ---
19 |
20 | - pass user to context for rendering template
21 |
22 | 0.1
23 | ---
24 |
25 | - initial release
26 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | django-intercom-io
2 | ==================
3 |
4 | **django-intercom-io** makes it easy for you to add support for **intercom.io** to your Django website.
5 |
6 |
7 | Development
8 | -----------
9 |
10 | The source repository can be found at https://github.com/eldarion/django-intercom-io
11 |
12 |
13 | Contents
14 | ========
15 |
16 | .. toctree::
17 | :maxdepth: 1
18 |
19 | changelog
20 | installation
21 | usage
22 |
--------------------------------------------------------------------------------
/docs/conf.py:
--------------------------------------------------------------------------------
1 | import sys, os
2 |
3 | extensions = []
4 | templates_path = []
5 | source_suffix = '.rst'
6 | master_doc = 'index'
7 | project = u'django-intercom-io'
8 | copyright_holder = ''
9 | copyright = u'2013, %s' % copyright_holder
10 | exclude_patterns = ['_build']
11 | pygments_style = 'sphinx'
12 | html_theme = 'default'
13 | htmlhelp_basename = '%sdoc' % project
14 | latex_documents = [
15 | ('index', '%s.tex' % project, u'%s Documentation' % project,
16 | copyright_holder, 'manual'),
17 | ]
18 | man_pages = [
19 | ('index', project, u'%s Documentation' % project,
20 | [copyright_holder], 1)
21 | ]
22 |
23 | sys.path.insert(0, os.pardir)
24 | m = __import__("intercom")
25 |
26 | version = m.__version__
27 | release = version
28 |
--------------------------------------------------------------------------------
/intercom/templates/intercom/_intercom_js.html:
--------------------------------------------------------------------------------
1 | {% if email %}{% endif %}
13 |
--------------------------------------------------------------------------------
/intercom/templatetags/intercom_tags.py:
--------------------------------------------------------------------------------
1 | import json
2 | import hashlib
3 | import hmac
4 | import time
5 |
6 | from django import template
7 | from django.conf import settings
8 |
9 |
10 | register = template.Library()
11 |
12 |
13 | @register.inclusion_tag("intercom/_intercom_js.html")
14 | def intercom_js(user):
15 | if hasattr(settings, "INTERCOM_APP_ID") and user.is_authenticated():
16 | if hasattr(settings, "INTERCOM_USER_HASH_KEY"):
17 | user_hash = hmac.new(settings.INTERCOM_USER_HASH_KEY, str(user.pk), hashlib.sha256).hexdigest()
18 | else:
19 | user_hash = None
20 |
21 | custom_data = {}
22 | for app in getattr(settings, "INTERCOM_APPS", []):
23 | m = __import__(app + ".intercom", globals(), locals(), ["intercom"])
24 | custom_data.update(m.custom_data(user))
25 |
26 | return {
27 | "app_id": settings.INTERCOM_APP_ID,
28 | "email": user.email,
29 | "user_hash": user_hash,
30 | "user": user,
31 | "created_at": int(time.mktime(user.date_joined.timetuple())),
32 | "custom_data": json.dumps(custom_data, ensure_ascii=False)
33 | }
34 | else:
35 | return {}
36 |
--------------------------------------------------------------------------------
/docs/usage.rst:
--------------------------------------------------------------------------------
1 | .. _usage:
2 |
3 | Usage
4 | =====
5 |
6 | At the top of your base template add::
7 |
8 | {% load intercom_tags %}
9 |
10 |
11 | And just before the ``