apostrophe-flickr
Advanced tools
Comparing version 0.5.8 to 0.5.9
83
index.js
@@ -76,3 +76,3 @@ //var Flickr = require('flickrapi'); | ||
// doesn't prevent us from seeing a change in the limit property right away | ||
var key = JSON.stringify({ setUrl: item.setUrl, limit: item.limit }); | ||
var key = JSON.stringify({ setId: item.setId, limit: item.limit }); | ||
if (cache.hasOwnProperty(key) && ((cache[key].when + lifetime) > now.getTime())) { | ||
@@ -94,3 +94,3 @@ item._photos = cache[key].data; | ||
+ "&photoset_id="+item.setId | ||
+ "&extras=url_l" | ||
+ "&extras=url_l,description" | ||
+ "&privacy_filter=1" | ||
@@ -104,3 +104,3 @@ + "&per_page="+ item.limit; | ||
var photoUrlString = (photo.url_l || "http://farm"+photo.farm+".staticflickr.com/"+photo.server+"/"+photo.id+"_"+photo.secret+".jpg"); | ||
item._photos.push(photoUrlString); | ||
item._photos.push({url: photoUrlString, description: photo.description}); | ||
}); | ||
@@ -113,79 +113,2 @@ cache[key] = { when: now.getTime(), data: item._photos }; | ||
// // var now = new Date(); | ||
// // // Take all properties into account, not just the feed, so the cache | ||
// // // doesn't prevent us from seeing a change in the limit property right away | ||
// // var key = JSON.stringify({ setUrl: item.setUrl, limit: item.limit }); | ||
// // if (cache.hasOwnProperty(key) && ((cache[key].when + lifetime) > now.getTime())) { | ||
// // item._photos = cache[key].data; | ||
// // return callback(); | ||
// // } | ||
// // | ||
// // if (self._apos._aposLocals.offline) { | ||
// // item._failed = true; | ||
// // return callback(null); | ||
// // } | ||
/// Let's build out the Flickr API request | ||
// // var flickrUrl = "https://api.flickr.com/services/rest/?" | ||
// // + "&method=flickr.photosets.getPhotos" | ||
// // + "&api_key="+options.flickrKey | ||
// // + "&format=json&nojsoncallback=1" | ||
// // + "&photoset_id="+item.setId | ||
// // + "&extras=url_l" | ||
// // + "&privacy_filter=1" | ||
// // + "&per_page="+ item.limit; | ||
// | ||
//efla unction(req, item, callback) { | ||
// // (1) Figure out the setId number | ||
// // (2) Load photos based on that set. | ||
// | ||
// te._hoos= ]; // | ||
// /Whydoe myregx sck? // // TODO: check for bad stuff happening here. | ||
// | ||
// var tepIdSring= itm.seUrl.atch(/sets\/([0-9]+)/); | ||
// if (!tempIdString) { | ||
// item._failed = true; | ||
// return callback(); | ||
// } | ||
// item.setId = tempIdString[1]; | ||
// | ||
// //console.lo("Cace is" cach); | ||
// | ||
// var now = new Date(; | ||
// // Tke allproperties into account, not just the feed, so the cache | ||
// // doesn't prevent us from seeing a change in the limit property right away | ||
// var key = JSON.stringify({ setUrl: item.setUrl, limit: item.limit }); | ||
// if (cache.hasOwnProperty(key) && ((cache[key].when + lifetime) > now.getTime())) { | ||
// item._photos = cache[key].data; | ||
// return callback(); | ||
// } | ||
// | ||
// if (self._apos._aposLocals.ffline){ | ||
// item._failed = true; | ||
// return callback(null); | ||
// } | ||
// | ||
// // Let's build out the Flickr API reuest | ||
// var flickrUrl = "https://api.flickr.com/services/rest/?" | ||
// + "&method=flickr.photosets.getPhotos" | ||
// + "&api_key="+options.flickrKey | ||
// + "&format=json&nojsoncallback=1" | ||
// + "&photoset_id="+item.setId | ||
// + "&extras=url_l" | ||
// + "&privacy_filter=1" | ||
// + "&per_page="+ item.limit; | ||
// | ||
// | ||
// request(flickrUrl, function(error, respone, body){ | ||
// if (!error && response.statusCode == 200) { | ||
// var flickrResponse = JSON.parse(body); | ||
// _.each((flickrResponse && flickrResponse.photoset && flickrResponse.photoset.photo) || [], function(photo){ | ||
// var photoUrlString = (photo.url_l || "http://farm"+photo.farm+".staticflickr.com/"+photo.server+"/"+photo.id+"_"+photo.secret+".jpg"); | ||
// item._photos.push(photoUrlString); | ||
// }); | ||
// cache[key] = { when: now.getTime(), data: item._photos }; | ||
// return callback(); | ||
// } | ||
// }); | ||
// }; | ||
self._apos.addWidgetType('flickr', self); | ||
@@ -192,0 +115,0 @@ |
{ | ||
"name": "apostrophe-flickr", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"description": "Adds a Flickr set widget to the Apostrophe content management system", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,15 +5,14 @@ apos.widgetPlayers.flickr = function($el) { | ||
var getSetId = function(url){ | ||
var tempId = url.match(/sets\/([0-9]+)/); | ||
var tempId; | ||
tempId = url.match(/sets\/([0-9]+)/); | ||
console.log(tempId); | ||
return tempId[1]; | ||
} | ||
var limit = data.limit; | ||
var id = getSetId(data.setUrl); | ||
$.ajax({ | ||
dataType: "json", | ||
url: '/apos-flickr/feed', | ||
data: {id: id, limit: limit}, | ||
data: {id: getSetId(data.setUrl), limit: data.limit}, | ||
success: function(photos){ | ||
console.log($el); | ||
//Define our photos object as well as the template and loader. | ||
@@ -39,2 +38,3 @@ var $photos = $el.find('[data-apos-flickr-photos]'), | ||
$template.$image = $template.find('[data-apos-flickr-image]'); | ||
$template.$description = $template.find('[data-apos-flickr-description]'); | ||
return $template; | ||
@@ -56,5 +56,12 @@ } | ||
//Add Photo background and image src. | ||
$photo.css('background-image', photo); | ||
$photo.$image.attr('src', photo); | ||
$photo.css('background-image', photo.url); | ||
$photo.$image.attr('src', photo.url); | ||
//Add Description if it's there | ||
if(photo.description && photo.description._content && photo.description._content.length){ | ||
$photo.$description.text(photo.description._content); | ||
} else { | ||
$photo.$description.remove(); | ||
} | ||
//If there's still a loader, kill it. | ||
@@ -61,0 +68,0 @@ $loader.remove(); |
12514
207