Django Social Share
======================================
.. image:: https://github.com/fcurella/django-social-share/workflows/Python%20build/badge.svg
.. 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 templatetags for:
* 'Tweet This'
* 'Share this on Facebook'
* 'Share on Google+'
* 'Share on LinkedIn'
* 'Share on Telegram'
* 'Share on WhatsApp'
* 'mailto://'.
* 'Save to Pinterest'
* 'Copy to Clipboard'
Plain HTML templates_ are provided for your convenience, but you can override them to provide your own look and feel.
Installation
-------------
::
$ python -m pip install django-social-share
Add the app to ``INSTALLED_APPS``::
INSTALLED_APPS += ['django_social_share']
You will also have to add ``django.template.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',
],
}
},
]
Note in most cases sharing will not work if you are using ``localhost`` or your domain is otherwise not accessible from the public internet. For testing local development, you can use a service like ngrok_, and set your `Site instance <https://docs.djangoproject.com/en/3.0/ref/contrib/sites/>`_'s ``domain`` to the hostname provided by ``ngrok``.
.. _ngrok: https://ngrok.com/
Usage
-----
::
{% post_to_facebook <object_or_url> <link_text> <link_class> %}
{% post_to_gplus <object_or_url> <link_text> <link_class> %}
{% post_to_twitter <text_to_post> <object_or_url> <link_text> <link_class> %}
{% post_to_linkedin <object_or_url> <link_class> %}
{% send_email <subject> <text_to_post> <object_or_url> <link_text> <link_class> %}
{% post_to_reddit <text_to_post> <object_or_url> <link_text> <link_class> %}
{% post_to_telegram <text_to_post> <object_or_url> <link_text> <link_class> %}
{% post_to_whatsapp <object_or_url> <link_text> <link_class> %}
{% save_to_pinterest <object_or_url> <link_class> %}
{% add_pinterest_script %}
{% copy_to_clipboard <object_or_url> <link_text> <link_class> %}
{% add_copy_script %}
``<text_to_post>`` may contain any valid Django Template code. Note that Facebook does not support this anymore.
``<object_or_url>`` is optional (except Telegram). 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.
::
{% post_to_reddit_url <text> <object_or_url> %}
Will add a ``reddit_url`` variable to the context, containing the URL for the Reddit poster page.
::
{% post_to_telegram <text> <object_or_url> %}
Will add a ``telegram_url`` variable to the context, containing the URL for the Telegram sharer popup.
::
{% post_to_whatsapp_url <object_or_url> %}
Will add a ``whatsapp_url`` variable to the context, containing the URL for the WhatsApp sharer.
::
{% save_to_pinterest_url <object_or_url> %}
Will add a ``pinterest_url`` variable to the context, containing the URL for the Pinterest sharer.
::
{% copy_to_clipboard <object_or_url> <link_text> <link_class> %}
will add a ``copy_url`` variable to the context, containing the URL for the link to copy.
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_or_url %}
{% send_email object.title "New Song: {{object.title}}. Check it out!" object_or_url "Share via email" %}
{% post_to_reddit "New Song: {{object.title}}" <object_or_url> %}
{% post_to_telegram "New Song: {{object.title}}" <object_or_url> %}
{% post_to_whatsapp object_or_url "Share via WhatsApp" %}
{% save_to_pinterest object_or_url %}
{% add_pinterest_script %} // Required for save_to_pinterest. Add to the end of body tag.
{% copy_to_clipboard object_or_url "Copy to clipboard!" %}
{% add_copy_script %} // Required for copy_to_clipboard. Add to the end of body tag.
.. _templates:
Templates
---------
Templates are in:
* ``django_social_share/templatetags/post_to_twitter.html``
* ``django_social_share/templatetags/post_to_facebook.html``
* ``django_social_share/templatetags/post_to_gplus.html``
* ``django_social_share/templatetags/send_email.html``
* ``django_social_share/templatetags/post_to_linkedin.html``
* ``django_social_share/templatetags/post_to_reddit.html``.
* ``django_social_share/templatetags/post_to_telegram.html``.
* ``django_social_share/templatetags/post_to_whatsapp.html``.
* ``django_social_share/templatetags/save_to_pinterest.html``.
* ``django_social_share/templatetags/pinterest_script.html``.
* ``django_social_share/templatetags/copy_to_clipboard.html``.
* ``django_social_share/templatetags/copy_script.html``.
You can override them to suit your mileage.
Issues
------
If you have any issues, please use `GitHub's issues <https://github.com/fcurella/django-social-share/issues>`_.
Please refrain from emailing the author.
Raw data
{
"_id": null,
"home_page": "https://github.com/fcurella/django-social-share",
"name": "django-social-share",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Flavio Curella",
"author_email": "flavio.curella@curella.org",
"download_url": "https://files.pythonhosted.org/packages/06/82/5bb1e496a85b00fdcc0f6220a73d670d0c7a722424a689d370f51c0cf3c9/django-social-share-2.3.0.tar.gz",
"platform": null,
"description": "Django Social Share\n======================================\n\n.. image:: https://github.com/fcurella/django-social-share/workflows/Python%20build/badge.svg\n\n.. image:: https://coveralls.io/repos/github/fcurella/django-social-share/badge.svg?branch=master\n :target: https://coveralls.io/github/fcurella/django-social-share?branch=master\n\nProvides templatetags for:\n\n* 'Tweet This'\n* 'Share this on Facebook'\n* 'Share on Google+'\n* 'Share on LinkedIn'\n* 'Share on Telegram'\n* 'Share on WhatsApp'\n* 'mailto://'.\n* 'Save to Pinterest'\n* 'Copy to Clipboard'\n\nPlain HTML templates_ are provided for your convenience, but you can override them to provide your own look and feel.\n\nInstallation\n-------------\n\n::\n\n $ python -m pip install django-social-share\n\nAdd the app to ``INSTALLED_APPS``::\n\n INSTALLED_APPS += ['django_social_share']\n\nYou will also have to add ``django.template.context_processors.request`` to your ``context_processors`` list. This way the templatetags will use the correct scheme and hostname::\n\n TEMPLATES=[\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\n 'DIRS': [\n os.path.join(BASE_DIR, 'templates'),\n ],\n 'OPTIONS': {\n 'context_processors': [\n 'django.template.context_processors.request',\n ],\n }\n },\n ]\n\nNote in most cases sharing will not work if you are using ``localhost`` or your domain is otherwise not accessible from the public internet. For testing local development, you can use a service like ngrok_, and set your `Site instance <https://docs.djangoproject.com/en/3.0/ref/contrib/sites/>`_'s ``domain`` to the hostname provided by ``ngrok``.\n\n.. _ngrok: https://ngrok.com/\n\nUsage\n-----\n::\n\n {% post_to_facebook <object_or_url> <link_text> <link_class> %}\n\n {% post_to_gplus <object_or_url> <link_text> <link_class> %}\n\n {% post_to_twitter <text_to_post> <object_or_url> <link_text> <link_class> %}\n\n {% post_to_linkedin <object_or_url> <link_class> %}\n\n {% send_email <subject> <text_to_post> <object_or_url> <link_text> <link_class> %}\n\n {% post_to_reddit <text_to_post> <object_or_url> <link_text> <link_class> %}\n\n {% post_to_telegram <text_to_post> <object_or_url> <link_text> <link_class> %}\n\n {% post_to_whatsapp <object_or_url> <link_text> <link_class> %}\n\n {% save_to_pinterest <object_or_url> <link_class> %}\n\n {% add_pinterest_script %}\n\n {% copy_to_clipboard <object_or_url> <link_text> <link_class> %}\n\n {% add_copy_script %}\n\n``<text_to_post>`` may contain any valid Django Template code. Note that Facebook does not support this anymore.\n\n``<object_or_url>`` is optional (except Telegram). 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.\n\n``<link_text>`` is also optional. It defines the text used for the ``a`` element. Defaults to 'Post to Facebook' and 'Post to Twitter'.\n\n``<subject>`` may contain any valid Django Template code.\n\n::\n\n {% post_to_twitter_url <text_to_post> <object_or_url> %}\n\nWill add a ``tweet_url`` variable to the context, containing the URL for the Twitter sharer popup.\n\n::\n\n {% post_to_facebook_url <object_or_url> %}\n\nWill add a ``facebook_url`` variable to the context, containing the URL for the Facebook sharer popup.\n\n::\n\n {% post_to_gplus_url <object_or_url> %}\n\nWill add a ``gplus_url`` variable to the context, containing the URL for the Google+ sharer popup.\n\n::\n\n {% send_email_url <subject> <text_to_post> <object_or_url> <link_text> %}\n\nWill add a ``mailto_url`` variable to the context, containing the URL for the ``mailto`` anchor.\n\n::\n\n {% post_to_reddit_url <text> <object_or_url> %}\n\nWill add a ``reddit_url`` variable to the context, containing the URL for the Reddit poster page.\n\n::\n\n {% post_to_telegram <text> <object_or_url> %}\n\nWill add a ``telegram_url`` variable to the context, containing the URL for the Telegram sharer popup.\n\n::\n\n {% post_to_whatsapp_url <object_or_url> %}\n\nWill add a ``whatsapp_url`` variable to the context, containing the URL for the WhatsApp sharer.\n\n::\n\n {% save_to_pinterest_url <object_or_url> %}\n\nWill add a ``pinterest_url`` variable to the context, containing the URL for the Pinterest sharer.\n\n::\n\n {% copy_to_clipboard <object_or_url> <link_text> <link_class> %}\n\nwill add a ``copy_url`` variable to the context, containing the URL for the link to copy.\n\nExample::\n\n {% load social_share %}\n\n {% post_to_facebook object_or_url \"Post to Facebook!\" %}\n {% post_to_twitter \"New Song: {{object.title}}. Check it out!\" object_or_url \"Post to Twitter\" %}\n {% post_to_gplus object_or_url \"Post to Google+!\" %}\n {% post_to_linkedin object_or_url %}\n {% send_email object.title \"New Song: {{object.title}}. Check it out!\" object_or_url \"Share via email\" %}\n {% post_to_reddit \"New Song: {{object.title}}\" <object_or_url> %}\n {% post_to_telegram \"New Song: {{object.title}}\" <object_or_url> %}\n {% post_to_whatsapp object_or_url \"Share via WhatsApp\" %}\n {% save_to_pinterest object_or_url %}\n {% add_pinterest_script %} // Required for save_to_pinterest. Add to the end of body tag.\n {% copy_to_clipboard object_or_url \"Copy to clipboard!\" %}\n {% add_copy_script %} // Required for copy_to_clipboard. Add to the end of body tag.\n\n.. _templates:\n\nTemplates\n---------\n\nTemplates are in:\n\n* ``django_social_share/templatetags/post_to_twitter.html``\n* ``django_social_share/templatetags/post_to_facebook.html``\n* ``django_social_share/templatetags/post_to_gplus.html``\n* ``django_social_share/templatetags/send_email.html``\n* ``django_social_share/templatetags/post_to_linkedin.html``\n* ``django_social_share/templatetags/post_to_reddit.html``.\n* ``django_social_share/templatetags/post_to_telegram.html``.\n* ``django_social_share/templatetags/post_to_whatsapp.html``.\n* ``django_social_share/templatetags/save_to_pinterest.html``.\n* ``django_social_share/templatetags/pinterest_script.html``.\n* ``django_social_share/templatetags/copy_to_clipboard.html``.\n* ``django_social_share/templatetags/copy_script.html``.\n\nYou can override them to suit your mileage.\n\nIssues\n------\n\nIf you have any issues, please use `GitHub's issues <https://github.com/fcurella/django-social-share/issues>`_.\nPlease refrain from emailing the author.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Templatetags for 'tweet this' and 'share on facebook'",
"version": "2.3.0",
"project_urls": {
"Homepage": "https://github.com/fcurella/django-social-share"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "be8cfab0089cb1f161435d082d9ee5945d8d2a678da15be8bda5181e6aa4de60",
"md5": "6bf1edfea8f9e347f5c3f27f8ee80ccf",
"sha256": "13d0a1fbb2a90e3a6e7eb556315ececd1e93a906574a3284affbe2f43e2f7398"
},
"downloads": -1,
"filename": "django_social_share-2.3.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "6bf1edfea8f9e347f5c3f27f8ee80ccf",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 14385,
"upload_time": "2022-07-26T14:56:47",
"upload_time_iso_8601": "2022-07-26T14:56:47.718462Z",
"url": "https://files.pythonhosted.org/packages/be/8c/fab0089cb1f161435d082d9ee5945d8d2a678da15be8bda5181e6aa4de60/django_social_share-2.3.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "06825bb1e496a85b00fdcc0f6220a73d670d0c7a722424a689d370f51c0cf3c9",
"md5": "f7140fd90070e7f2f8b09866906cae94",
"sha256": "37844f3b4f88a2008604ece7eaedd52fd5914f111f13525200ce1101b750757f"
},
"downloads": -1,
"filename": "django-social-share-2.3.0.tar.gz",
"has_sig": false,
"md5_digest": "f7140fd90070e7f2f8b09866906cae94",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11177,
"upload_time": "2022-07-26T14:56:48",
"upload_time_iso_8601": "2022-07-26T14:56:48.871372Z",
"url": "https://files.pythonhosted.org/packages/06/82/5bb1e496a85b00fdcc0f6220a73d670d0c7a722424a689d370f51c0cf3c9/django-social-share-2.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-07-26 14:56:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fcurella",
"github_project": "django-social-share",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-social-share"
}