Skip to main content

A simple django app to use emojis on your website

Project description

Emoji is a port of the GitHub gem gemoji to Django.

It’ll try to replace items between :: with emojis, for instance : dog : (without the spaces) will become an emoji of a dog (:dog:).

Quick start

  1. Install django-emoji from PyPi:

    pip install django-emoji
  1. Add “emoji” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'emoji',
    )
  2. Include the emoji URLconf in your project urls.py like this if you want to be able to get a JSON list of emojis:

    url(r'^emoji/', include('emoji.urls')),
  3. Visit http://127.0.0.1:8000/emoji/all.json to get a json object with all emojis avilable

Usage

Replace an emoji using Python templates by loading the tags in your template:

{% load emoji_tags %}
blog_post.body|emoji_replace

Replace emojis using Javascript (to for instance show a preview before the user saves what it is they are writing):

{% load emoji_tags %}

<script src="{% static 'emoji/js/emoji.js' %}"></script>
{% emoji_load %}

Emoji.get('dog') // => url stub to dog emoji or falsy
Emoji.get() // => all emojis available

Emoji.replace("It's raining :cats: and :dogs:.") // => It's raining <img src="..." alt="cats" class="emoji"> and <img src="..." alt="dogs" class="emoji">

What emoji_load does is that it sets the endpoint to retrieve the listing of all the available emojis and thus only works if the emoji urls has been included.

It is the equivalent of doing:

Emoji.setDataUrl('{% url 'emoji:list.json' %}').load();

Which is also available as template stub:

{% include 'emoji/script.html' %}

Usage from inside Python where the Emoji class mimics some of the behavior of a dict:

from emoji import Emoji
Emoji['dog'] # => url stub to dog emoji or None
'dog' in Emoji # => True
Emoji.keys() # => a list of all emojis by name
Emoji.replace("It's raining :cats: and :dogs:") # => It's raining <img src="..." alt="cats" class="emoji"> and <img src="..." alt="dogs" class="emoji">

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-emoji-1.0.tar.gz (4.0 MB view details)

Uploaded Source

File details

Details for the file django-emoji-1.0.tar.gz.

File metadata

  • Download URL: django-emoji-1.0.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-emoji-1.0.tar.gz
Algorithm Hash digest
SHA256 644c1597dbde8ebd65695b1061cc45c991e458bd5586aac7916c51cccb426f06
MD5 9b769c026e9f6c5051b277433b957103
BLAKE2b-256 7f5d003504a1ee728b57dde2ba0e880485259fec715ab0750a7e8441ddcc34ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page