Repository: fcurella/django-social-share
Branch: master
Commit: 57834ed60f9f
Files: 33
Total size: 38.1 KB
Directory structure:
gitextract_08i4p9oj/
├── .bumpversion.cfg
├── .github/
│ ├── FUNDING.yml
│ └── workflows/
│ ├── gh-release.yml
│ └── pythonpackage.yml
├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.rst
├── VERSION
├── django_social_share/
│ ├── __init__.py
│ ├── models.py
│ ├── templates/
│ │ └── django_social_share/
│ │ └── templatetags/
│ │ ├── copy_script.html
│ │ ├── copy_to_clipboard.html
│ │ ├── pinterest_script.html
│ │ ├── post_to_facebook.html
│ │ ├── post_to_gplus.html
│ │ ├── post_to_linkedin.html
│ │ ├── post_to_reddit.html
│ │ ├── post_to_telegram.html
│ │ ├── post_to_twitter.html
│ │ ├── post_to_whatsapp.html
│ │ ├── save_to_pinterest.html
│ │ └── send_email.html
│ ├── templatetags/
│ │ ├── __init__.py
│ │ └── social_share.py
│ ├── tests/
│ │ ├── __init__.py
│ │ ├── runtests.py
│ │ └── tests.py
│ └── views.py
├── setup.cfg
└── setup.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .bumpversion.cfg
================================================
[bumpversion]
files = VERSION django_social_share/__init__.py
commit = True
tag = True
current_version = 2.3.0
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: @fcurella
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: pypi/django-social-hare
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
================================================
FILE: .github/workflows/gh-release.yml
================================================
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
================================================
FILE: .github/workflows/pythonpackage.yml
================================================
name: Python build
on: [push]
jobs:
tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8]
django-version:
- "Django>=2.0,<2.1"
- "Django>=2.1,<2.2"
- "Django>=2.2,<3.0"
- "Django>=3.0,<3.1"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -q "${{ matrix.django-version }}"
pip install -e .
pip install coveralls
- name: Test with pytest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
coverage run --source django_social_share setup.py test && coveralls
================================================
FILE: .gitignore
================================================
*.egg-info
*.pot
*.py[co]
*.out
.eggs
.cache
.coverage
parsetab.py
__pycache__
MANIFEST
dist/
docs/_build/
docs/locale/
node_modules/
tests/coverage_html/
tests/.coverage
build/
tests/report/
.idea
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at community@curella.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
================================================
FILE: LICENSE
================================================
Copyright (C) 2011 by Flavio Curella
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: MANIFEST.in
================================================
include README.rst
include LICENSE
include VERSION
recursive-include tests *.py
recursive-include django_social_share/templates *
================================================
FILE: Makefile
================================================
release:
rm -rf dist
python setup.py sdist bdist_wheel
twine upload dist/*
================================================
FILE: README.rst
================================================
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 `_'s ``domain`` to the hostname provided by ``ngrok``.
.. _ngrok: https://ngrok.com/
Usage
-----
First, add ``{% load social_share %}`` to your HTML template.
This tag should be placed at the top of most of your HTML document and should come before any other template tag unless otherwise.
`django-social-share` provides two types of template tags: "snippet" tags and "context" tags.
Snippet Tags
~~~~~~~~~~~~
Snippet tags returns HTML that you can just drop in your templates. This snippets are customizable, see templates_
.
Available Snippets Tags:
::
{% post_to_facebook %}
{% post_to_gplus %}
{% post_to_twitter %}
{% post_to_linkedin %}
{% post_to_reddit %}
{% post_to_telegram %}
{% post_to_whatsapp %}
{% save_to_pinterest %}
{% add_pinterest_script %}
```` may contain any valid Django Template code. Note that Facebook does not support this anymore.
```` 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.
```` is also optional. It defines the text used for the ``a`` element. Defaults to 'Post to Facebook' and 'Post to Twitter'.
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}}" %}
{% post_to_telegram "New Song: {{object.title}}" %}
{% 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.
.. _templates:
Templates
---------
Templates for snippet tags 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.
Context Tags
~~~~~~~~~~~~
Context Tags work by adding a variable to your template's context. This variable will containg just the URL to service's share feature, which you can use into your template as you wish.
Available Context Tags:
============================================================================= =================
Tag example Variable name
============================================================================= =================
``{% post_to_twitter_url %}`` ``tweet_url``
``{% post_to_facebook_url %}`` ``facebook_url``
``{% post_to_gplus_url %}`` ``gplus_url``
``{% send_email_url %}`` ``mailto_url``
``{% post_to_reddit_url %}`` ``reddit_url``
``{% post_to_telegram %}`` ``telegram_url``
``{% post_to_whatsapp_url %}`` ``whatsapp_url``
``{% save_to_pinterest_url %}`` ``pinterest_url``
``{% copy_to_clipboard %}`` ``copy_url``
```` may contain any valid Django Template code. Note that Facebook does not support this anymore.
```` 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.
```` is also optional. It defines the text used for the ``a`` element. Defaults to 'Post to Facebook' and 'Post to Twitter'.
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}}" %}
{% post_to_telegram "New Song: {{object.title}}" %}
{% 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.
Issues
------
If you have any issues, please use `GitHub's issues `_.
Please refrain from emailing the author.
================================================
FILE: VERSION
================================================
2.3.0
================================================
FILE: django_social_share/__init__.py
================================================
VERSION = tuple(map(int, "2.3.0".split('.')))
================================================
FILE: django_social_share/models.py
================================================
from django.db import models
================================================
FILE: django_social_share/templates/django_social_share/templatetags/copy_script.html
================================================
================================================
FILE: django_social_share/templates/django_social_share/templatetags/copy_to_clipboard.html
================================================