Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All my previous pull requests, plus some bits #5

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.pyc
9 changes: 1 addition & 8 deletions README.rst
Expand Up @@ -2,11 +2,4 @@
Phileo
======

a liking app


Attribution
-----------

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/.
A generic liking, starring, bookmarking, sharing, etc app for django.
14 changes: 14 additions & 0 deletions docs/changelog.rst
Expand Up @@ -3,6 +3,20 @@
ChangeLog
=========

0.3
---
- Likeable models need to be registered in Phileo. This prevents users from liking
anything and everything, which could potentially lead to security problems (eg. liking
entries in permission tables, and thus seeing their content; liking administrative
users and thus getting their username).
- Removed {% likes_css %}. It is not the plugins job to dictate style.
- Turned the JavaScript code in to a jQuery plugin, removed most of the initialization
code from the individual widget templates to a external JavaScript file, and added a
{% phileo_js %} tag to load this plugin.
- Each like button gets a unique ID, so multiple like buttons can appear on a single
page
- The like form works without JavaScript.

0.2
---

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

likes_css
phileo_js
---------

This renders some css style sheets that will style the widget.::
This renders some script tags that are needed to make the widget work.::

{% likes_css %}
{% phileo_js %}

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


likes_widget
Expand All @@ -31,26 +31,11 @@ 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_link_id="likes" like_span_total_class="phileo-count" toggle_class="phileo-liked"] %}
{% likes_widget user object [widget_id="unique_id" like_type="likes" toggle_class="phileo-liked"] %}


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


likes_js
--------

This is a simple inclusion template tag that will render a bit
of javascript for doing the ajax toggling of a user's like for
a given object. The only two required parameters are the first
two which are the user doing the liking and the object that is
the subject of the liking.::

{% likes_js user object [like_link="#likes" like_span_total="phileo-count" toggle_class="phileo-liked"] %}

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


liked
-----

Expand Down
32 changes: 22 additions & 10 deletions docs/usage.rst
Expand Up @@ -3,28 +3,40 @@
Usage
=====

Phileo consists of template tags that you place within your project
to get different "liking" functionality.
In your models
--------------

You need to register the models that will be 'likeable' with phileo, before
you use phileo in templates::

# in models.py
from phileo.handlers import library as phileo_library

# Define your models ...

# Register a single model
phileo_library.register(Post)

# Register a bunch of models at once
phileo_library.register([Page, Entry, Comment, Photo])

In the views
------------

Let's say you have a detail page for a blog post. First you will want
to load the tags::

{% load phileo_tags %}


Then in the <head> section of your template load the css::
Load the required JavaScript file, wherever you load your JavaScript libraries::

{% likes_css %}
{% phileo_js %}


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

{% likes_widget request.user post %}


Then at the bottom of your page where include your javascript::

{% likes_js request.user post %}


That's all you need to do to get the basics working.
That's all you need to do to get the basics working.
22 changes: 22 additions & 0 deletions phileo/handlers.py
@@ -0,0 +1,22 @@
from django.db.models.base import ModelBase

class Registry(object):
def __init__(self):
self._registry = []

def register(self, models):

if isinstance(models, ModelBase):
models = [models]

for model in models:
self._registry.append(model)

def is_registered(self, model):
return not (model in self._registry)

def get_list(self):
return self._registry[:]

library = Registry()

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.