All my previous pull requests, plus some bits #5

Closed
wants to merge 9 commits into
from
+234 −653
Split
View
@@ -0,0 +1 @@
+*.pyc
View
@@ -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.
View
@@ -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
---
View
@@ -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
@@ -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
-----
View
@@ -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.
View
@@ -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()
+
@@ -1,97 +0,0 @@
-@font-face {
- font-family: 'IconicStroke';
- src: url("iconic_stroke.eot");
- src: local('IconicStroke'),
- url("iconic_stroke.svg#iconic") format('svg'),
- url("iconic_stroke.otf") format('opentype');
-}
-
-.iconic {
- color:inherit;
- font-family: "IconicStroke";
-}
-
-a.iconic:hover {
- color:inherit;
-}
-
-.iconic.home:before { content: '!'; }
-.iconic.at:before { content: "@"; }
-.iconic.quote:before { content: '"'; }
-.iconic.quote-alt:before { content: "'"; }
-.iconic.arrow-up:before { content: "3"; }
-.iconic.arrow-right:before { content: "4"; }
-.iconic.arrow-bottom:before { content: "5"; }
-.iconic.arrow-left:before { content: "6"; }
-.iconic.arrow-up-alt:before { content: "#"; }
-.iconic.arrow-right-alt:before { content: "$"; }
-.iconic.arrow-bottom-alt:before { content: "%"; }
-.iconic.arrow-left-alt:before { content: "^"; }
-.iconic.move:before { content: "9"; }
-.iconic.move-vertical:before { content: "8"; }
-.iconic.move-horizontal:before { content: "7"; }
-.iconic.move-alt:before { content: "("; }
-.iconic.move-vertical-alt:before { content: "*"; }
-.iconic.move-horizontal-alt:before { content: "&"; }
-.iconic.cursor:before { content: ")"; }
-.iconic.plus:before { content: "+"; }
-.iconic.plus-alt:before { content: "="; }
-.iconic.minus:before { content: "-"; }
-.iconic.minus-alt:before { content: "_"; }
-.iconic.new-window:before { content: "1"; }
-.iconic.dial:before { content: "2"; }
-.iconic.lightbulb:before { content: "0"; }
-.iconic.link:before { content: "/"; }
-.iconic.image:before { content: "?"; }
-.iconic.article:before { content: ">"; }
-.iconic.read-more:before { content: "."; }
-.iconic.headphones:before { content: ","; }
-.iconic.equalizer:before { content: "<"; }
-.iconic.fullscreen:before { content: ":"; }
-.iconic.exit-fullscreen:before { content: ";"; }
-.iconic.spin:before { content: "["; }
-.iconic.spin-alt:before { content: "{"; }
-.iconic.moon:before { content: "]"; }
-.iconic.sun:before { content: "}"; }
-.iconic.map-pin:before { content: "\\"; }
-.iconic.pin:before { content: "|"; }
-.iconic.eyedropper:before { content: "~"; }
-.iconic.denied:before { content: "`"; }
-.iconic.calendar:before { content: "a"; }
-.iconic.calendar-alt:before { content: "A"; }
-.iconic.bolt:before { content: "b"; }
-.iconic.clock:before { content: "c"; }
-.iconic.document:before { content: "d"; }
-.iconic.book:before { content: "e"; }
-.iconic.book-alt:before { content: "E"; }
-.iconic.magnifying-glass:before { content: "f"; }
-.iconic.tag:before { content: "g"; }
-.iconic.heart:before { content: "h"; }
-.iconic.info:before { content: "i"; }
-.iconic.chat:before { content: "j"; }
-.iconic.chat-alt:before { content: "J"; }
-.iconic.key:before { content: "k"; }
-.iconic.unlocked:before { content: "l"; }
-.iconic.locked:before { content: "L"; }
-.iconic.mail:before { content: "m"; }
-.iconic.mail-alt:before { content: "M"; }
-.iconic.phone:before { content: "n"; }
-.iconic.box:before { content: "o"; }
-.iconic.pencil:before { content: "p"; }
-.iconic.pencil-alt:before { content: "P"; }
-.iconic.comment:before { content: "q"; }
-.iconic.comment-alt:before { content: "Q"; }
-.iconic.rss:before { content: "r"; }
-.iconic.star:before { content: "s"; }
-.iconic.trash:before { content: "t"; }
-.iconic.user:before { content: "u"; }
-.iconic.volume:before { content: "v"; }
-.iconic.mute:before { content: "V"; }
-.iconic.cog:before { content: "w"; }
-.iconic.cog-alt:before { content: "W"; }
-.iconic.x:before { content: "x"; }
-.iconic.x-alt:before { content: "X"; }
-.iconic.check:before { content: "y"; }
-.iconic.check-alt:before { content: "Y"; }
-.iconic.beaker:before { content: "z"; }
-.iconic.beaker-alt:before { content: "Z"; }
Binary file not shown.
Binary file not shown.
Oops, something went wrong.