GithubHelp home page GithubHelp logo

pkoszalka / django-social-share Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fcurella/django-social-share

0.0 2.0 0.0 181 KB

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

License: MIT License

Python 93.78% HTML 6.22%

django-social-share's Introduction

Django Social Share

Provides tempatetags for 'Tweet This', 'Share this on Facebook', and 'Share on Google+'.

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> %}

<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'

{% 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.

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+!" %}

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. You can override them to suit your mileage.

django-social-share's People

Contributors

fcurella avatar xyene avatar

Watchers

James Cloos avatar Paweł Koszałka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.