mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-31 22:20:12 +00:00
Moving towards folders as collections and an intermediary model that chooses between feeds or more folders. Still needs rendering.
This commit is contained in:
parent
bfe7ee1634
commit
fe5c286de7
9 changed files with 73 additions and 13 deletions
|
@ -275,11 +275,13 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
var pre_callback = function(feeds, subscriptions) {
|
var pre_callback = function(feeds, subscriptions) {
|
||||||
NEWSBLUR.log(['subscriptions', feeds, subscriptions]);
|
NEWSBLUR.log(['subscriptions', feeds, subscriptions]);
|
||||||
self.flags['favicons_fetching'] = self.feeds.any(function(feed) { return feed.get('favicons_fetching'); });
|
self.flags['favicons_fetching'] = self.feeds.any(function(feed) { return feed.get('favicons_fetching'); });
|
||||||
self.folders = subscriptions.folders;
|
|
||||||
|
self.folders = new NEWSBLUR.Collections.Folders();
|
||||||
|
self.folders.parse(subscriptions.folders);
|
||||||
self.starred_count = subscriptions.starred_count;
|
self.starred_count = subscriptions.starred_count;
|
||||||
self.social_feeds.reset(subscriptions.social_feeds);
|
self.social_feeds.reset(subscriptions.social_feeds);
|
||||||
self.user_profile.set(subscriptions.social_profile);
|
self.user_profile.set(subscriptions.social_profile);
|
||||||
|
|
||||||
if (!_.isEqual(self.favicons, {})) {
|
if (!_.isEqual(self.favicons, {})) {
|
||||||
self.feeds.each(function(feed) {
|
self.feeds.each(function(feed) {
|
||||||
if (self.favicons[feed.id]) {
|
if (self.favicons[feed.id]) {
|
||||||
|
@ -289,6 +291,8 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
self.detect_any_inactive_feeds();
|
self.detect_any_inactive_feeds();
|
||||||
|
|
||||||
|
self.feeds.trigger('reset');
|
||||||
};
|
};
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
|
|
|
@ -2,7 +2,7 @@ NEWSBLUR.Views.FeedList = Backbone.View.extend({
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.$s = NEWSBLUR.reader.$s;
|
this.$s = NEWSBLUR.reader.$s;
|
||||||
this.model = NEWSBLUR.reader.model;
|
this.model = NEWSBLUR.assets;
|
||||||
|
|
||||||
if (!$('#feed_list').length) return;
|
if (!$('#feed_list').length) return;
|
||||||
$('.NB-callout-ftux .NB-callout-text').text('Loading feeds...');
|
$('.NB-callout-ftux .NB-callout-text').text('Loading feeds...');
|
||||||
|
@ -12,7 +12,6 @@ NEWSBLUR.Views.FeedList = Backbone.View.extend({
|
||||||
this.make_feeds();
|
this.make_feeds();
|
||||||
this.make_social_feeds();
|
this.make_social_feeds();
|
||||||
this.load_router();
|
this.load_router();
|
||||||
callback && callback();
|
|
||||||
}, this));
|
}, this));
|
||||||
NEWSBLUR.assets.load_feeds();
|
NEWSBLUR.assets.load_feeds();
|
||||||
},
|
},
|
||||||
|
@ -27,14 +26,14 @@ NEWSBLUR.Views.FeedList = Backbone.View.extend({
|
||||||
$feed_list.empty();
|
$feed_list.empty();
|
||||||
|
|
||||||
this.$s.$story_taskbar.css({'display': 'block'});
|
this.$s.$story_taskbar.css({'display': 'block'});
|
||||||
var $feeds = this.make_feeds_folder(folders, 0);
|
var $feeds = new NEWSBLUR.Views.Folder(this.model.folders).render().el;
|
||||||
$feed_list.css({
|
$feed_list.css({
|
||||||
'display': 'block',
|
'display': 'block',
|
||||||
'opacity': 0
|
'opacity': 0
|
||||||
});
|
});
|
||||||
$feed_list.html($feeds);
|
$feed_list.html($feeds);
|
||||||
this.count_collapsed_unread_stories();
|
|
||||||
$feed_list.animate({'opacity': 1}, {'duration': 700});
|
$feed_list.animate({'opacity': 1}, {'duration': 700});
|
||||||
|
this.count_collapsed_unread_stories();
|
||||||
this.hover_over_feed_titles($feed_list);
|
this.hover_over_feed_titles($feed_list);
|
||||||
this.$s.$feed_link_loader.fadeOut(250);
|
this.$s.$feed_link_loader.fadeOut(250);
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ NEWSBLUR.Collections.Feeds = Backbone.Collection.extend({
|
||||||
options = _.extend({
|
options = _.extend({
|
||||||
data: {
|
data: {
|
||||||
v: 2
|
v: 2
|
||||||
}
|
},
|
||||||
|
silent: true
|
||||||
}, options);
|
}, options);
|
||||||
return Backbone.Collection.prototype.fetch.call(this, options);
|
return Backbone.Collection.prototype.fetch.call(this, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
parse: function(data) {
|
parse: function(data) {
|
||||||
console.log(["parsing collection", data]);
|
|
||||||
return data.feeds;
|
return data.feeds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
NEWSBLUR.Models.Folder = Backbone.Model.extend({
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
27
media/js/newsblur/models/folders.js
Normal file
27
media/js/newsblur/models/folders.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
NEWSBLUR.Models.FeedOrFolder = Backbone.Model.extend({
|
||||||
|
|
||||||
|
initialize: function(model) {
|
||||||
|
console.log(["constructing model", model]);
|
||||||
|
if (_.isNumber(model)) {
|
||||||
|
this.model = NEWSBLUR.assets.feeds.get(model);
|
||||||
|
} else {
|
||||||
|
this.model = new NEWSBLUR.Collections.Folders();
|
||||||
|
this.title = _.keys(model)[0];
|
||||||
|
var children = model[this.title];
|
||||||
|
this.model.parse(children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
NEWSBLUR.Collections.Folders = Backbone.Collection.extend({
|
||||||
|
|
||||||
|
model: NEWSBLUR.Models.FeedOrFolder,
|
||||||
|
|
||||||
|
parse: function(models) {
|
||||||
|
console.log(["parse", this.models, models]);
|
||||||
|
this.reset(models);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,10 @@
|
||||||
|
NEWSBLUR.Views.Feed = Backbone.View.extend({
|
||||||
|
|
||||||
|
className: 'NB-feed',
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
$(this.el).html(this.make('div', {}, this.model.get('feed_title')));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,25 @@
|
||||||
|
NEWSBLUR.Views.Folder = Backbone.View.extend({
|
||||||
|
|
||||||
|
className: 'NB-folder',
|
||||||
|
|
||||||
|
initialize: function(models) {
|
||||||
|
this.models = models;
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
console.log(["render models", this.models]);
|
||||||
|
var $feeds = _.map(this.models, function(model) {
|
||||||
|
var $model;
|
||||||
|
console.log(["model", model]);
|
||||||
|
if (_.isNumber(model)) {
|
||||||
|
var model = NEWSBLUR.assets.feeds.get(model);
|
||||||
|
return new NEWSBLUR.Views.Feed({model: model}).render().el;
|
||||||
|
} else {
|
||||||
|
return new NEWSBLUR.Views.Folder(model).render().el;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(this.el).append($feeds);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue