2012-01-04 09:42:35 -08:00
|
|
|
NEWSBLUR.Models.User = Backbone.Model.extend({
|
|
|
|
|
2012-02-24 14:36:19 -08:00
|
|
|
get: function(attr) {
|
|
|
|
var value = Backbone.Model.prototype.get.call(this, attr);
|
|
|
|
if (attr == 'photo_url' && !value) {
|
|
|
|
value = NEWSBLUR.Globals.MEDIA_URL + 'img/reader/default_profile_photo.png';
|
|
|
|
}
|
|
|
|
return value;
|
2012-03-12 18:11:13 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
photo_url: function(options) {
|
|
|
|
options = options || {};
|
|
|
|
var url = this.get('photo_url');
|
2012-03-14 12:38:59 -07:00
|
|
|
if (options.size && _.string.include(url, 'graph.facebook.com')) {
|
2012-03-12 18:11:13 -07:00
|
|
|
url += '?type=' + options.size;
|
2012-05-09 13:51:48 -07:00
|
|
|
} else if (options.size == 'large' && _.string.include(url, 'twimg')) {
|
|
|
|
url = url.replace(/_normal.(\w+)/, '.$1');
|
2012-03-12 18:11:13 -07:00
|
|
|
}
|
|
|
|
return url;
|
2012-07-28 19:53:38 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
blurblog_url: function() {
|
2012-07-29 11:21:40 -07:00
|
|
|
return [
|
|
|
|
'http://',
|
|
|
|
Inflector.sluggify(this.get('username')),
|
|
|
|
'.',
|
|
|
|
window.location.host.replace('www.', '')
|
|
|
|
].join('');
|
2012-02-24 14:36:19 -08:00
|
|
|
}
|
2012-01-04 09:42:35 -08:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
NEWSBLUR.Collections.Users = Backbone.Collection.extend({
|
|
|
|
|
2012-01-11 09:35:52 -08:00
|
|
|
model : NEWSBLUR.Models.User,
|
|
|
|
|
|
|
|
find: function(user_id) {
|
|
|
|
return this.detect(function(user) { return user.get('user_id') == user_id; });
|
2013-01-14 12:50:00 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
comparator: function(model) {
|
|
|
|
return -1 * model.get('shared_stories_count');
|
2012-01-11 09:35:52 -08:00
|
|
|
}
|
2012-01-04 09:42:35 -08:00
|
|
|
|
|
|
|
});
|