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+' and 'mailto://'.
Installation
-------------
::
$ pip install django-social-share
Add the app to ``INSTALLED_APPS``::
INSTALLED_APPS += ['django_social_share']
It's recommended to add ``django.core.context_processors.request`` to your `` TEMPLATE_CONTEXT_PROCESSORS`` list. This way the templatetags will use the correct scheme and hostname.
If ``django.core.context_processors.request`` is not present, it will simply concatenate the current site's domain (from ``django.contrib.sites``) and the object's relative URL together.
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_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.
::
{% 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+!" %}
{% 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``. You can override them to suit your mileage.
======================================
.. 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+' and 'mailto://'.
Installation
-------------
::
$ pip install django-social-share
Add the app to ``INSTALLED_APPS``::
INSTALLED_APPS += ['django_social_share']
It's recommended to add ``django.core.context_processors.request`` to your `` TEMPLATE_CONTEXT_PROCESSORS`` list. This way the templatetags will use the correct scheme and hostname.
If ``django.core.context_processors.request`` is not present, it will simply concatenate the current site's domain (from ``django.contrib.sites``) and the object's relative URL together.
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_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.
::
{% 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+!" %}
{% 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``. You can override them to suit your mileage.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-social-share-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d10f2e06857298b73fb1597069087906e0f7d201b2a4eb76383443473f620847 |
|
MD5 | 310138c04e029cf9d2f208203f440161 |
|
BLAKE2b-256 | ee7a6d288f238c983c5974a74cdd2898c0e4070bb8a9f7989adf6b0f2418b61f |
Close
Hashes for django_social_share-0.3.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d35a8fa792c44a628028d9349c575717b100343e9cdf71422c79ef4c6411d365 |
|
MD5 | 42c168637b8732d308ec0d6fa0418774 |
|
BLAKE2b-256 | df00ed6a2d2863db3a19da90d2cb8bb63f059d67a1c06ae2360b417aa2154d23 |