Merge lp:~daker/loco-team-portal/pixie-plugin into lp:loco-team-portal

Proposed by Adnane Belmadiaf
Status: Merged
Merged at revision: 433
Proposed branch: lp:~daker/loco-team-portal/pixie-plugin
Merge into: lp:loco-team-portal
Diff against target: 178 lines (+80/-30)
4 files modified
loco_directory/common/context_processors.py (+13/-14)
loco_directory/media/js/jquery-pixie.js (+63/-0)
loco_directory/settings.py (+2/-0)
loco_directory/templates/teams/team_detail.html (+2/-16)
To merge this branch: bzr merge lp:~daker/loco-team-portal/pixie-plugin
Reviewer Review Type Date Requested Status
Ronnie (community) Approve
Review via email: mp+55981@code.launchpad.net

Commit message

Made a jquery plugin for pixie.

To post a comment you must log in.
Revision history for this message
Ronnie (ronnie.vd.c) wrote :

Works perfect here

Revision history for this message
Ronnie (ronnie.vd.c) :
review: Approve
Revision history for this message
Ronnie (ronnie.vd.c) wrote :

pix.ie key should be in settings.py

review: Disapprove
Revision history for this message
Ronnie (ronnie.vd.c) wrote :

Well done Adnane. Well tested and good to go. Approve!

review: Approve
Revision history for this message
Nigel Babu (nigelbabu) wrote :

Attempt to merge into lp:loco-directory failed due to conflicts:

text conflict in loco_directory/templates/teams/team_detail.html

Revision history for this message
Adnane Belmadiaf (daker) wrote :

ok i have fixed the text conflict.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/common/context_processors.py'
2--- loco_directory/common/context_processors.py 2010-11-20 17:25:50 +0000
3+++ loco_directory/common/context_processors.py 2011-04-15 15:09:49 +0000
4@@ -8,11 +8,8 @@
5 """
6 add the loco version to template context processor.
7 """
8- try:
9- version = settings.VERSION_STRING
10- except AttributeError:
11- version = "unknown"
12-
13+
14+ version = getattr(settings, 'VERSION_STRING', 'unknown')
15 return {'loco_version': version}
16
17 def google_api_key(request):
18@@ -20,22 +17,24 @@
19 Return the Google API Key or "" if none is defined.
20 """
21
22- try:
23- google_api_key = settings.GOOGLE_API_KEY
24- except AttributeError:
25- google_api_key = ""
26+ google_api_key = getattr(settings, 'GOOGLE_API_KEY', '')
27 return {'google_api_key': google_api_key}
28
29 def flickr_api_key(request):
30 """
31 Return the Flickr API Key or "" if none is defined.
32 """
33-
34- try:
35- flickr_api_key = settings.FLICKR_API_KEY
36- except AttributeError:
37- flickr_api_key = ""
38+
39+ flickr_api_key = getattr(settings, 'FLICKR_API_KEY', '')
40 return {'flickr_api_key': flickr_api_key}
41+
42+def pixie_api_key(request):
43+ """
44+ Return the Pix.ie API Key or "" if none is defined.
45+ """
46+
47+ pixie_api_key = getattr(settings, 'PIXIE_API_KEY', '')
48+ return {'pixie_api_key': pixie_api_key}
49
50 def login_redirect(request):
51 return {'login_next': request.get_full_path()}
52
53=== added file 'loco_directory/media/js/jquery-pixie.js'
54--- loco_directory/media/js/jquery-pixie.js 1970-01-01 00:00:00 +0000
55+++ loco_directory/media/js/jquery-pixie.js 2011-04-15 15:09:49 +0000
56@@ -0,0 +1,63 @@
57+/*
58+ * jQuery Pixie plugin 0.1.0 (Based on jQuery Flickr plugin)
59+ * Requires jQuery 1.4.2
60+ *
61+ * Copyright 2011, Adnane Belmadiaf
62+ * Dual licensed under the MIT or GPL Version 2 licenses.
63+ * http://jquery.org/license
64+ */
65+
66+(function ($) {
67+ $.fn.extend({
68+ //This is where you write your plugin's name
69+ pixie: function (options) {
70+ var defaults = {
71+ key: null,
72+ id: null,
73+ amount: 16,
74+ lightbox_class: 'lightbox'
75+ },
76+ html_elements = this,
77+ data = {
78+ oauth_consumer_key: options.key,
79+ page: '1',
80+ perpage: options.amount,
81+ sortby: 'recent',
82+ extras: 'items_item_owner,items_item_Description,items_item_sizes_all',
83+ callback: ''
84+ };
85+ options = $.extend(defaults, options);
86+
87+ function parseResponse(data) {
88+ var images = [], image, link;
89+ $.each(data.items, function (i, rPhoto) {
90+ image = $('<img>').attr({
91+ src: rPhoto.sizes[1].url,
92+ alt: rPhoto.title
93+ });
94+ link = $('<a>').addClass(options.lightbox_class).attr({
95+ title: rPhoto.title,
96+ href: rPhoto.sizes[4].url
97+ }).append(image);
98+ images.push(link);
99+ });
100+
101+ $(html_elements).each(function (i, html_element) {
102+ var index;
103+ for (index in images) {
104+ if (images.hasOwnProperty(index)) {
105+ $(html_element).append(images[index]);
106+ }
107+ }
108+ });
109+ // Reinitiale the lightbox with the new photo's
110+ $('a.' + options.lightbox_class).lightBox();
111+ }
112+
113+ $.getJSON('http://api.pix.ie/v0.81/account/' + options.id + '/photos.json?' + $.param(data) + '&jsonp=?', parseResponse);
114+
115+ // Return the html objects untouched (the photo's are added when loaded)
116+ return this;
117+ } // End of pixie command
118+ });
119+}(jQuery));
120
121=== modified file 'loco_directory/settings.py'
122--- loco_directory/settings.py 2010-12-07 21:42:01 +0000
123+++ loco_directory/settings.py 2011-04-15 15:09:49 +0000
124@@ -90,6 +90,7 @@
125 "common.context_processors.loco_version",
126 "common.context_processors.google_api_key",
127 "common.context_processors.flickr_api_key",
128+ "common.context_processors.pixie_api_key",
129 "common.context_processors.login_redirect",
130 "common.context_processors.url_base",
131 "common.context_processors.site_search",
132@@ -158,6 +159,7 @@
133
134
135 FLICKR_API_KEY = '8c969a1e8a49629bb89b411930ab1cc8'
136+PIXIE_API_KEY = '1dcc8233-a6da-46b0-acb0-4e29aa612b30'
137
138 import logging
139 try:
140
141=== modified file 'loco_directory/templates/teams/team_detail.html'
142--- loco_directory/templates/teams/team_detail.html 2011-03-02 22:34:34 +0000
143+++ loco_directory/templates/teams/team_detail.html 2011-04-15 15:09:49 +0000
144@@ -20,6 +20,7 @@
145 <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.lightbox-0.5.min.js"></script>
146 <link rel="stylesheet" href="{{MEDIA_URL}}css/jquery.lightbox-0.5.css" type="text/css" media="screen" />
147 <script type="text/javascript" src="{{MEDIA_URL}}js/jquery-flickr.js"></script>
148+<script type="text/javascript" src="{{MEDIA_URL}}js/jquery-pixie.js"></script>
149 <script type="text/javascript">
150 $(function() {
151 var perPage = '16';
152@@ -49,25 +50,10 @@
153 });
154 {% endif %}
155 {% if team.pixie_id %}
156- var pixie_userId = '{{ team.pixie_id }}';
157- $.getJSON('http://api.pix.ie/v0.81/account/'+ pixie_userId +'/photos.json?oauth_consumer_key=1dcc8233-a6da-46b0-acb0-4e29aa612b30&page=1&perpage=' + perPage
158- + '&sortby=recent&extras=items_item_owner,items_item_Description,items_item_sizes_all&jsonp=?',
159- function(data){
160- $.each(data.items, function(i, Photo){
161- var photoStringStart = '<a class="lightbox" ';
162- var photoStringEnd = 'title="' + Photo.title + '" href="'+
163- Photo.sizes[4].url +'"><img width="75" height="75" src="' + Photo.sizes[1].url + '" alt="' +
164- Photo.title + '"/></a>';
165- var photoString = photoStringStart + photoStringEnd;
166-
167- $(photoString).appendTo("#pixie");
168- });
169- $("a.lightbox").lightBox();
170- });
171+ $('#pixie').pixie({ key: "{{ pixie_api_key }}", id: "{{ team.pixie_id }}", amount: perPage });
172 {% endif %}
173 {% if team.flickr_id or team.picasa_id or team.pixie_id %}
174 });
175-
176 </script>
177 <style type="text/css">
178 div#flickr a.lightbox img {

Subscribers

People subscribed via source and target branches