-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
100 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Pinax Likes | ||
|
||
[![](http://slack.pinaxproject.com/badge.svg)](http://slack.pinaxproject.com/) | ||
[![](https://img.shields.io/travis/pinax/pinax-likes.svg)](https://travis-ci.org/pinax/pinax-likes) | ||
[![](https://img.shields.io/coveralls/pinax/pinax-likes.svg)](https://coveralls.io/r/pinax/pinax-likes) | ||
[![](https://img.shields.io/pypi/dm/pinax-likes.svg)](https://pypi.python.org/pypi/pinax-likes/) | ||
[![](https://img.shields.io/pypi/v/pinax-likes.svg)](https://pypi.python.org/pypi/pinax-likes/) | ||
[![](https://img.shields.io/badge/license-MIT-blue.svg)](https://pypi.python.org/pypi/pinax-likes/) | ||
|
||
## Pinax | ||
|
||
[Pinax](http://pinaxproject.com/pinax/) is an open-source platform built on the | ||
Django Web Framework. It is an ecosystem of reusable Django apps, themes, and | ||
starter project templates. | ||
|
||
This app is part of the Pinax ecosystem and is designed for use both with and | ||
independently of other Pinax apps. | ||
|
||
## pinax-likes | ||
|
||
``pinax-likes`` is a liking app for Django, allowing users to "like" and "unlike" | ||
any model instance in your project. Template tags provide the ability to see who | ||
liked an object, what objects a user liked, and more. | ||
|
||
## Getting Started and Documentation | ||
|
||
Follow steps outlined in [Pinax Likes Documentation](docs/index.md). | ||
|
||
## Contribute | ||
|
||
See [this blog post](http://blog.pinaxproject.com/2016/02/26/recap-february-pinax-hangout/) including a video, or our [How to Contribute](http://pinaxproject.com/pinax/how_to_contribute/) section for an overview on how contributing to Pinax works. For concrete contribution ideas, please see our [Ways to Contribute/What We Need Help With](http://pinaxproject.com/pinax/ways_to_contribute/) section. | ||
|
||
In case of any questions we recommend you [join our Pinax Slack team](http://slack.pinaxproject.com) and ping us there instead of creating an issue on GitHub. Creating issues on GitHub is of course also valid but we are usually able to help you faster if you ping us in Slack. | ||
|
||
We also highly recommend reading our [Open Source and Self-Care blog post](http://blog.pinaxproject.com/2016/01/19/open-source-and-self-care/). | ||
|
||
|
||
## Code of Conduct | ||
|
||
In order to foster a kind, inclusive, and harassment-free community, the Pinax Project has a code of conduct, which can be found here http://pinaxproject.com/pinax/code_of_conduct/. We ask you to treat everyone as a smart human programmer that shares an interest in Python, Django, and Pinax with you. | ||
|
||
|
||
## Pinax Project Blog and Twitter | ||
|
||
For updates and news regarding the Pinax Project, please follow us on Twitter at @pinaxproject and check out our blog http://blog.pinaxproject.com. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# ChangeLog | ||
|
||
## 2.0.2 | ||
|
||
- Improve documentation | ||
|
||
## 2.0.1 | ||
|
||
- Converted documentation to Markdown format | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,39 @@ | ||
# Requirements | ||
|
||
The view to handle the like toggling conforms to an `AJAX` response that | ||
[eldarion-ajax](https://github.com/eldarion/eldarion-ajax) understands. | ||
Furthermore, the templates that ship with this project will work | ||
seemlessly with `eldarion-ajax`. All you have to do is include the | ||
`eldarion-ajax` in your base template somewhere like: | ||
|
||
|
||
{% load staticfiles %} | ||
<script src="{% static "js/eldarion-ajax.min.js" %}"></script> | ||
|
||
|
||
and include `eldarion-ajax` somewhere in your site JavaScript: | ||
|
||
|
||
require('eldarion-ajax'); | ||
|
||
|
||
This of course is optional. You can roll your own JavaScript handling as | ||
the view also returns data in addition to rendered HTML. Furthermore, if | ||
you don't want `ajax` at all the view will handle a regular `POST` and | ||
perform a redirect. | ||
|
||
# Installation | ||
|
||
- To install likes: | ||
|
||
pip install pinax-likes | ||
|
||
- Add `pinax.likes` to your `INSTALLED_APPS` setting: | ||
|
||
|
||
INSTALLED_APPS = ( | ||
# other apps | ||
"pinax.likes", | ||
) | ||
To install pinax-likes: | ||
|
||
- Add the models that you want to be likable to | ||
`PINAX_LIKES_LIKABLE_MODELS`: | ||
pip install pinax-likes | ||
|
||
PINAX_LIKES_LIKABLE_MODELS = { | ||
"app.Model": {} # can override default config settings for each model here | ||
} | ||
Add `pinax.likes` to your `INSTALLED_APPS` setting: | ||
|
||
- Add `pinax.likes.auth_backends.CanLikeBackend` to your | ||
`AUTHENTICATION_BACKENDS` (or use your own custom version checking | ||
against the `pinax.likes.can_like` permission): | ||
INSTALLED_APPS = ( | ||
... | ||
"pinax.likes", | ||
... | ||
) | ||
|
||
Add the models that you want to be likable to `PINAX_LIKES_LIKABLE_MODELS`: | ||
|
||
AUTHENTICATION_BACKENDS = [ | ||
PINAX_LIKES_LIKABLE_MODELS = { | ||
"app.Model": {} # can override default config settings for each model here | ||
} | ||
|
||
pinax.likes.auth_backends.CanLikeBackend, | ||
Add `pinax.likes.auth_backends.CanLikeBackend` to your | ||
`AUTHENTICATION_BACKENDS` (or use your own custom version checking | ||
against the `pinax.likes.can_like` permission): | ||
|
||
] | ||
AUTHENTICATION_BACKENDS = [ | ||
... | ||
pinax.likes.auth_backends.CanLikeBackend, | ||
... | ||
] | ||
|
||
- Lastly you will want to add `pinax.likes.urls` to your urls definition: | ||
Lastly add `pinax.likes.urls` to your project urlpatterns: | ||
|
||
urlpatterns = [ | ||
... | ||
url(r"^likes/", include("pinax.likes.urls", namespace="pinax_likes")), | ||
... | ||
] | ||
|
||
See [Usage](./usage.md) for details about integrating pinax-likes with your project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,43 @@ | ||
# Usage | ||
|
||
## In your settings | ||
## Settings | ||
|
||
Add each model that you want to be likable to the `PINAX_LIKES_LIKABLE_MODELS` setting: | ||
|
||
|
||
PINAX_LIKES_LIKABLE_MODELS = { | ||
"profiles.Profile": {}, | ||
"videos.Video": {}, | ||
"biblion.Post": {}, | ||
} | ||
|
||
## Templates | ||
|
||
## In the templates | ||
Let's say you have a detail page for a blog post. First load the template tags: | ||
|
||
Let's say you have a detail page for a blog post. First you will want to | ||
load the tags: | ||
{% load pinax_likes_tags %} | ||
|
||
In the body where you want the liking widget to go, add: | ||
|
||
{% load pinax_likes_tags %} | ||
{% likes_widget request.user post %} | ||
|
||
Finally, ensure you have `eldarion-ajax` installed: | ||
|
||
In the body where you want the liking widget to go, add: | ||
### Eldarion AJAX | ||
|
||
The `likes_widget` templatetag above and the "toggle like" view both conform | ||
to an `AJAX` response that [eldarion-ajax](https://github.com/eldarion/eldarion-ajax) understands. | ||
Furthermore, the templates that ship with this project will work | ||
seemlessly with `eldarion-ajax`. All you have to do is include the | ||
eldarion-ajax.min.js Javascript package in your base template: | ||
|
||
{% likes_widget request.user post %} | ||
{% load staticfiles %} | ||
<script src="{% static "js/eldarion-ajax.min.js" %}"></script> | ||
|
||
and include `eldarion-ajax` in your site JavaScript: | ||
|
||
require('eldarion-ajax'); | ||
|
||
That's all you need to do to get the basics working. | ||
This of course is optional. You can roll your own JavaScript handling as | ||
the view also returns data in addition to rendered HTML. Furthermore, if | ||
you don't want `ajax` at all the view will handle a regular `POST` and | ||
perform a redirect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters