Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added username flickrOption in .search() method to support search within specified flickr user #223

Open
wants to merge 2 commits into from

2 participants

@abhiomkar

Hi,

I just added username flickrOption in .search() method to support search within specified flickr user. By this feature, we can get specific flickr user's interesting photos in galleria.

I've also updated the Docs accordingly. Please let me know if the changes looks ok.

Cheers,
Abhinay

@davidhellsing

This looks pretty good, but I’m not sure how I feel about adding an option that only applies for one API call... any thoughts on that?

Thanks David! Yes, this option applies to only .search() method. Even if we provide username option to .user() method, it'll be ignored.

Sadly, flickr.people.getPublicPhotos doesn't support sort option. This change can also serve as alternative to flickr.people.getPublicPhotos in interestingness descending order.

Hello David, any thoughts on this yet?

@davidhellsing

This is pretty handy, but I think we should supply a separate API call for this instead of using an option that only applies for a single API call. Ideas?

@abhiomkar

Hey David, I've added interestingness-desc and interestingness-asc sort option support to .user() method. And also with the previous commit the user should be able to search the photos with the given phrase and username options.

So, by default .user() method shows the user's public photos in interestingness-desc order as per the default options of galleria flickr plugin.

please have a look at the changes and let me know what do you think.

@abhiomkar

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 21, 2011
  1. @abhiomkar
Commits on Aug 9, 2012
  1. @abhiomkar
This page is out of date. Refresh to see the latest.
Showing with 42 additions and 12 deletions.
  1. +8 −0 docs/plugins/flickr.rst
  2. +34 −12 src/plugins/flickr/galleria.flickr.js
View
8 docs/plugins/flickr.rst
@@ -176,4 +176,12 @@ description
The plugin fetches the title per default. If you also wish to fetch the description, set this option to true.
+username
+--------
+
+ | type: **String**
+ | default: ''
+
+The flickr username to search within. Applicable only for .search() method.
+
View
46 src/plugins/flickr/galleria.flickr.js
@@ -43,7 +43,8 @@ Galleria.Flickr = function( api_key ) {
sort: 'interestingness-desc', // sort option ( date-posted-asc, date-posted-desc, date-taken-asc, date-taken-desc, interestingness-desc, interestingness-asc, relevance )
description: false, // set this to true to get description as caption
complete: function(){}, // callback to be called inside the Galleria.prototype.load
- backlink: false // set this to true if you want to pass a link back to the original image
+ backlink: false, // set this to true if you want to pass a link back to the original image
+ username: '' // flickr username to search within
};
};
@@ -63,9 +64,22 @@ Galleria.Flickr.prototype = {
*/
search: function( phrase, callback ) {
- return this._find({
- text: phrase
- }, callback );
+ if(this.options.username) {
+ return this._call({
+ method: 'flickr.urls.lookupUser',
+ url: 'flickr.com/photos/' + this.options.username
+ }, function( data ) {
+ this._find({
+ text: phrase,
+ user_id: data.user.id
+ }, callback);
+ })
+ }
+ else {
+ return this._find({
+ text: phrase
+ }, callback);
+ }
},
/**
@@ -94,14 +108,22 @@ Galleria.Flickr.prototype = {
user: function( username, callback ) {
return this._call({
- method: 'flickr.urls.lookupUser',
- url: 'flickr.com/photos/' + username
+ method: 'flickr.urls.lookupUser',
+ url: 'flickr.com/photos/' + username
}, function( data ) {
- this._find({
- user_id: data.user.id,
- method: 'flickr.people.getPublicPhotos'
- }, callback);
- });
+ if(this.options.sort.match(/interestingness-(desc|asc)/)) {
+ this._find({
+ text: '',
+ user_id: data.user.id
+ }, callback);
+ }
+ else {
+ this._find({
+ user_id: data.user.id,
+ method: 'flickr.people.getPublicPhotos'
+ }, callback);
+ }
+ })
},
/**
@@ -378,4 +400,4 @@ Galleria.prototype.load = function() {
}
};
-}( jQuery ) );
+}( jQuery ) );
Something went wrong with that request. Please try again.