Skip to content

Commit

Permalink
Refactor how the phileo widget works
Browse files Browse the repository at this point in the history
  • Loading branch information
paltman committed Aug 20, 2012
1 parent 68d607f commit 065ccae
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 720 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
@@ -1,3 +1,2 @@
include README.rst
recursive-include phileo/static *
recursive-include phileo/templates *
9 changes: 5 additions & 4 deletions README.rst
Expand Up @@ -5,8 +5,9 @@ Phileo
a liking app


Attribution
-----------
Commercial Support
------------------

The default liking AJAX liking widget that ships with this package uses the Iconic icons packaged
into a typeface from http://somerandomdude.com/work/iconic/.
This app, and many others like it, have been built in support of many of Eldarion's
own sites, and sites of our clients. We would love to help you on your next project
so get in touch by dropping us a note at info@eldarion.com.
6 changes: 5 additions & 1 deletion docs/changelog.rst
Expand Up @@ -7,14 +7,18 @@ ChangeLog
---

- Added permission checking

- Added rendering of HTML in the ajax response to liking
- Got rid of all the js/css cruft; up to site owner now but ships with bootstrap/bootstrap-ajax enabled templates

Backward Incompatibilities
^^^^^^^^^^^^^^^^^^^^^^^^^^

- Added an auth_backend to check permissions, you can just add the `phileo.auth_backends.PermCheckBackend`
and do nothing else, or you can implement you own backend checking the `phileo.can_like`
permission against the object and user according to your own business logic.
- No more ``phileo_css``, ``phileo_js``, or ``phileo_widget_js`` tags.
- ``PHILEO_LIKABLE_MODELS`` has changed from a ``list`` to a ``dict``
- ``phileo_widget`` optional parameters have been removed and instead put into per model settings


0.3
Expand Down
6 changes: 6 additions & 0 deletions docs/installation.rst
Expand Up @@ -14,6 +14,12 @@ Installation
"phileo",
)

* Add the models that you want to be likeable to ``PHILEO_LIKABLE_MODELS``:

PHILEO_LIKABLE_MODELS = {
"app.Model": {} # can override default config settings for each model here
}

* Add ``'phileo.auth_backends.CanLikeBackend'`` to your ``AUTHENTICATION_BACKENDS``
(or use your own custom version checking against the ``phileo.can_like`` permission):

Expand Down
33 changes: 2 additions & 31 deletions docs/templatetags.rst
Expand Up @@ -14,16 +14,6 @@ This simple returns the count of likes for a given object::
Template Tags
=============

likes_css
---------

This renders some css style sheets that will style the widget.::

{% phileo_css %}

It renders "phileo/_css.html" and can be overridden as desired.


render_like
-----------

Expand All @@ -47,38 +37,19 @@ basis:
* phileo/_like.html


phileo_js
---------

This renders some script tags that are needed to make the widget work.::

{% phileo_js %}

It renders "phileo/_js.html" and can be overridden as desired.


phileo_widget
------------
-------------

This renders a fragement of html that will be what the user will click
on to unlike or like objects. It only has two required parameters, which
are the user and the object.::

{% likes_widget user object like_text="Like|Unlike" counts_text="like|likes" [widget_id="unique_id" like_type="likes" toggle_class="phileo-liked"] %}
{% likes_widget user object %}


It renders "phileo/_widget.html" and can be overridden as desired.


phileo_widget_js
----------------

This renders a script tag that will use the jquery plugin that `phileo_js`
includes into the page.

It renders "phileo/_widget_js.html" and can be overriden as desired.


liked
-----

Expand Down
10 changes: 0 additions & 10 deletions docs/usage.rst
Expand Up @@ -25,16 +25,6 @@ to load the tags::
{% load phileo_tags %}


Then in the <head> section of your template load the css::

{% phileo_css %}


Load the required JavaScript file, wherever you load your JavaScript libraries::

{% phileo_js %}


In the body where you want the liking widget to go, add::

{% phileo_widget request.user post %}
Expand Down
21 changes: 21 additions & 0 deletions phileo/settings.py
@@ -0,0 +1,21 @@
from collections import defaultdict

from django.conf import settings


DEFAULT_LIKE_CONFIG = getattr(settings, "PHILEO_DEFAULT_LIKE_CONFIG", {
"css_class_on": "icon-heart",
"css_class_off": "icon-heart-empty",
"like_text_on": "Unlike",
"like_text_off": "Like",
"count_text_singular": "like",
"count_text_plural": "likes"
})

LIKABLE_MODELS = getattr(settings, "PHILEO_LIKABLE_MODELS", defaultdict(dict))

for model in LIKABLE_MODELS:
custom_data = LIKABLE_MODELS[model].copy()
default_data = DEFAULT_LIKE_CONFIG.copy()
LIKABLE_MODELS[model] = default_data
LIKABLE_MODELS[model].update(custom_data)
97 changes: 0 additions & 97 deletions phileo/static/phileo/css/iconic.css

This file was deleted.

Binary file removed phileo/static/phileo/css/iconic_stroke.eot
Binary file not shown.
Binary file removed phileo/static/phileo/css/iconic_stroke.otf
Binary file not shown.

0 comments on commit 065ccae

Please sign in to comment.