Skip to main content

Templatetags for 'tweet this' and 'share on facebook'

Project description

Django Social Share
======================================

.. image:: https://travis-ci.org/fcurella/django-social-share.svg?branch=master
:target: https://travis-ci.org/fcurella/django-social-share

.. image:: https://coveralls.io/repos/github/fcurella/django-social-share/badge.svg?branch=master
:target: https://coveralls.io/github/fcurella/django-social-share?branch=master

Provides tempatetags for 'Tweet This', 'Share this on Facebook', 'Share on Google+', 'Share on LinkedIn', and 'mailto://'.

Installation
-------------

::

$ pip install django-social-share

Add the app to ``INSTALLED_APPS``::

INSTALLED_APPS += ['django_social_share']

You will also have to add ``django.core.context_processors.request`` to your ``context_processors`` list. This way the templatetags will use the correct scheme and hostname::

TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
],
}
},
]

Usage
-----
::

{% post_to_facebook <object_or_url> <link_text> %}

{% post_to_gplus <object_or_url> <link_text> %}

{% post_to_twitter <text_to_post> <object_or_url> <link_text> %}

{% post_to_linkedin <subject> <object_or_url> <link_text> %}

{% post_to_mail <email_subject> <text_to_post> <object_or_url> <link_text> %}

{% send_email <subject> <text_to_post> <object_or_url> <link_text> %}

``<text_to_post>`` may contain any valid Django Template code. Note that Facebook does not support this anymore.

``<object_or_url>`` is optional. If you pass a django model instance, it will use its ``get_absolute_url`` method. Additionally, if you have ``django_bitly`` installed, it will use its shortUrl on Twitter.

``<link_text>`` is also optional. It defines the text used for the ``a`` element. Defaults to 'Post to Facebook' and 'Post to Twitter'.

``<subject>`` may contain any valid Django Template code.

::

{% post_to_twitter_url <text_to_post> <object_or_url> %}

Will add a ``tweet_url`` variable to the context, containing the URL for the Twitter sharer popup.

::

{% post_to_facebook_url <object_or_url> %}

Will add a ``facebook_url`` variable to the context, containing the URL for the Facebook sharer popup.

::

{% post_to_gplus_url <object_or_url> %}

Will add a ``gplus_url`` variable to the context, containing the URL for the Google+ sharer popup.

::

{% post_to_linkedin_url <subject> <object_or_url> %}

Will add a ``linked_url`` variable to the context, containing the URL for the LinkedIn sharer popup.

::

{% send_email_url <subject> <text_to_post> <object_or_url> <link_text> %}

Will add a ``mailto_url`` variable to the context, containing the URL for the ``mailto``anchor.

Example::

{% load social_share %}

{% post_to_facebook object_or_url "Post to Facebook!" %}
{% post_to_twitter "New Song: {{object.title}}. Check it out!" object_or_url "Post to Twitter" %}
{% post_to_gplus object_or_url "Post to Google+!" %}
{% post_to_linkedin object.title object_or_url "Post to LinkedIn" %}
{% send_email object.title "New Song: {{object.title}}. Check it out!" object_or_url "Share via email" %}

Templates are in ``django_social_share/templatetags/post_to_twitter.html``, ``django_social_share/templatetags/post_to_facebook.html`` and ``django_social_share/templatetags/post_to_gplus.html``, ``django_social_share/templatetags/send_email.html``, ``django_social_share/templatetags/post_to_linkedin.html``. You can override them to suit your mileage.


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-social-share-1.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

django_social_share-1.1.0-py2.py3-none-any.whl (10.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-social-share-1.1.0.tar.gz.

File metadata

File hashes

Hashes for django-social-share-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6dc278c325b0dd27dbf4ecfc331b2360c0d546c67158e637898d6d994f17081b
MD5 a4f9fad945368db78c378d42a6fcca0b
BLAKE2b-256 fd450621eb8e98967556518bb1e6a299fce1b1acf17463341e69f4b28ee22ae3

See more details on using hashes here.

Provenance

File details

Details for the file django_social_share-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_social_share-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b2dbbafc374983b52c837ab9972ed7a30891797c63add25cf9e9113e536f6b44
MD5 e0c3a801aa1261dc55ea220aefbc4af1
BLAKE2b-256 d0bf4c6b5971dc36d64e8445b19f607ef041b16a0039aa6563a2116bb26feb24

See more details on using hashes here.

Provenance

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