mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Individual dashboard rivers. Need support for opening stories and limits.
This commit is contained in:
parent
7516493690
commit
951dd54d81
6 changed files with 121 additions and 64 deletions
|
@ -2149,7 +2149,7 @@ hr {
|
|||
}
|
||||
|
||||
.NB-end-line {
|
||||
min-height: 36px;
|
||||
min-height: 76px;
|
||||
border-top: 1px solid #C2C5BE;
|
||||
border-bottom: 1px solid #E1E6E0;
|
||||
/* padding-left: 14px; /* offset for scrollbar on right */
|
||||
|
@ -2160,6 +2160,10 @@ hr {
|
|||
overflow: hidden;
|
||||
clear: both;
|
||||
}
|
||||
.NB-module-river .NB-end-line {
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
.NB-end-line.NB-short {
|
||||
height: 8px;
|
||||
min-height: 8px;
|
||||
|
@ -2170,7 +2174,7 @@ hr {
|
|||
background-size: 203px 24px;
|
||||
margin: 0 auto;
|
||||
width: 175px;
|
||||
height: 36px;
|
||||
height: 76px;
|
||||
}
|
||||
|
||||
.NB-empty .NB-end-line {
|
||||
|
|
|
@ -14,7 +14,6 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
this.folders = new NEWSBLUR.Collections.Folders([]);
|
||||
this.favicons = {};
|
||||
this.stories = new NEWSBLUR.Collections.Stories();
|
||||
this.dashboard_stories = new NEWSBLUR.Collections.Stories();
|
||||
this.starred_feeds = new NEWSBLUR.Collections.StarredFeeds();
|
||||
this.searches_feeds = new NEWSBLUR.Collections.SearchesFeeds();
|
||||
this.queued_read_stories = {};
|
||||
|
@ -45,7 +44,7 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
domCompleteTrigger: true});
|
||||
this.ajax['statistics'] = $.manageAjax.create('statistics', {queue: 'clear', abortOld: true});
|
||||
this.ajax['interactions'] = $.manageAjax.create('interactions', {queue: 'clear', abortOld: true});
|
||||
this.ajax['dashboard'] = $.manageAjax.create('interactions', {queue: 'clear', abortOld: true});
|
||||
this.ajax['dashboard'] = $.manageAjax.create('dashboard', {queue: true});
|
||||
$.ajaxSettings.traditional = true;
|
||||
},
|
||||
|
||||
|
@ -714,7 +713,6 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
}
|
||||
|
||||
self.load_feed_precallback(data, feed_id, callback, first_load);
|
||||
// console.log(['river stories fetch', self.dashboard_stories.length, self.stories.length]);
|
||||
};
|
||||
|
||||
this.feed_id = feed_id;
|
||||
|
@ -736,14 +734,25 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
});
|
||||
},
|
||||
|
||||
fetch_dashboard_stories: function(feed_id, feeds, page, callback, error_callback) {
|
||||
fetch_dashboard_stories: function(feed_id, feeds, page, dashboard_stories, options, callback, error_callback) {
|
||||
var self = this;
|
||||
|
||||
var order = this.view_setting(feed_id, 'order');
|
||||
this.dashboard_stories.comparator = function(a, b) {
|
||||
options = $.extend({
|
||||
feeds: feeds,
|
||||
page: page,
|
||||
order: this.view_setting(feed_id, 'order'),
|
||||
read_filter: this.view_setting(feed_id, 'read_filter'),
|
||||
query: NEWSBLUR.reader.flags.search,
|
||||
limit: 5,
|
||||
infrequent: false,
|
||||
include_hidden: false,
|
||||
dashboard: true,
|
||||
initial_dashboard: true
|
||||
}, options);
|
||||
|
||||
dashboard_stories.comparator = function(a, b) {
|
||||
var a_time = parseInt(a.get('story_timestamp'), 10);
|
||||
var b_time = parseInt(b.get('story_timestamp'), 10);
|
||||
if (order == "newest")
|
||||
if (options.order == "newest")
|
||||
return a_time < b_time ? 1 : (a_time == b_time) ? 0 : -1;
|
||||
else
|
||||
return a_time > b_time ? 1 : (a_time == b_time) ? 0 : -1;
|
||||
|
@ -757,37 +766,36 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
data.stories = data.stories.splice(0, 3);
|
||||
}
|
||||
if (page > 1) {
|
||||
self.dashboard_stories.add(data.stories, {silent: true});
|
||||
self.dashboard_stories.trigger('add', {added: data.stories.length});
|
||||
dashboard_stories.add(data.stories, {silent: true});
|
||||
dashboard_stories.trigger('add', {added: data.stories.length});
|
||||
} else {
|
||||
self.dashboard_stories.reset(data.stories, {added: data.stories.length});
|
||||
dashboard_stories.reset(data.stories, {added: data.stories.length});
|
||||
}
|
||||
|
||||
callback();
|
||||
};
|
||||
|
||||
this.make_request('/reader/river_stories', {
|
||||
feeds: feeds,
|
||||
limit: 4,
|
||||
page: page,
|
||||
order: this.view_setting(feed_id, 'order'),
|
||||
read_filter: this.view_setting(feed_id, 'read_filter'),
|
||||
include_hidden: false,
|
||||
dashboard: true,
|
||||
initial_dashboard: true
|
||||
}, pre_callback, error_callback, {
|
||||
'ajax_group': 'dashboard',
|
||||
'request_type': 'GET'
|
||||
});
|
||||
if (_.string.startsWith(feed_id, 'river:global')) {
|
||||
this.make_request('/social/river_stories', options, pre_callback, error_callback, {
|
||||
'ajax_group': 'dashboard',
|
||||
'request_type': 'GET'
|
||||
});
|
||||
} else if (_.string.startsWith(feed_id, 'river:')) {
|
||||
this.make_request('/reader/river_stories', options, pre_callback, error_callback, {
|
||||
'ajax_group': 'dashboard',
|
||||
'request_type': 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
add_dashboard_story: function(story_hash) {
|
||||
add_dashboard_story: function(story_hash, dashboard_stories) {
|
||||
var self = this;
|
||||
|
||||
var pre_callback = function(data) {
|
||||
self.dashboard_stories.add(data.stories, {silent: true});
|
||||
self.dashboard_stories.limit(NEWSBLUR.Globals.is_premium ? 5 : 3);
|
||||
self.dashboard_stories.trigger('reset', {added: 1});
|
||||
dashboard_stories.add(data.stories, {silent: true});
|
||||
dashboard_stories.limit(NEWSBLUR.Globals.is_premium ? 5 : 3);
|
||||
dashboard_stories.trigger('reset', {added: 1});
|
||||
};
|
||||
|
||||
this.make_request('/reader/river_stories', {
|
||||
|
|
|
@ -132,7 +132,32 @@
|
|||
NEWSBLUR.app.feed_selector = new NEWSBLUR.Views.FeedSelector();
|
||||
NEWSBLUR.app.follow_requests_module = new NEWSBLUR.Views.FollowRequestsModule();
|
||||
NEWSBLUR.app.dashboard_search = new NEWSBLUR.Views.DashboardSearch();
|
||||
NEWSBLUR.app.dashboard_river = new NEWSBLUR.Views.DashboardRiver();
|
||||
NEWSBLUR.app.dashboard_rivers = [];
|
||||
NEWSBLUR.app.dashboard_rivers.push(new NEWSBLUR.Views.DashboardRiver({
|
||||
el: '.NB-module-river-1',
|
||||
active_feed: 'river:',
|
||||
active_folder: NEWSBLUR.assets.folders,
|
||||
dashboard_stories: new NEWSBLUR.Collections.Stories()
|
||||
}));
|
||||
NEWSBLUR.app.dashboard_rivers.push(new NEWSBLUR.Views.DashboardRiver({
|
||||
el: '.NB-module-river-2',
|
||||
active_feed: 'river:infrequent',
|
||||
active_folder: NEWSBLUR.assets.folders,
|
||||
dashboard_stories: new NEWSBLUR.Collections.Stories()
|
||||
}));
|
||||
NEWSBLUR.app.dashboard_rivers.push(new NEWSBLUR.Views.DashboardRiver({
|
||||
el: '.NB-module-river-3',
|
||||
active_feed: 'river:global',
|
||||
active_folder: NEWSBLUR.assets.folders,
|
||||
dashboard_stories: new NEWSBLUR.Collections.Stories()
|
||||
}));
|
||||
NEWSBLUR.app.dashboard_rivers.push(new NEWSBLUR.Views.DashboardRiver({
|
||||
el: '.NB-module-river-4',
|
||||
active_feed: 'river:',
|
||||
active_folder: NEWSBLUR.assets.folders,
|
||||
query: "pizza",
|
||||
dashboard_stories: new NEWSBLUR.Collections.Stories()
|
||||
}));
|
||||
NEWSBLUR.app.taskbar_info = new NEWSBLUR.Views.ReaderTaskbarInfo().render();
|
||||
NEWSBLUR.app.story_titles_header = new NEWSBLUR.Views.StoryTitlesHeader();
|
||||
NEWSBLUR.app.search_header = new NEWSBLUR.Views.FeedSearchHeader();
|
||||
|
@ -4752,7 +4777,7 @@
|
|||
NEWSBLUR.app.sidebar_header.count();
|
||||
NEWSBLUR.assets.folders.update_all_folder_visibility();
|
||||
NEWSBLUR.app.feed_list.scroll_to_selected();
|
||||
NEWSBLUR.app.dashboard_river.load_stories();
|
||||
NEWSBLUR.app.dashboard_rivers.map(function(r) { return r.load_stories(); });
|
||||
|
||||
$('.NB-active', $slider).removeClass('NB-active');
|
||||
if (this.flags['feed_list_showing_starred']) {
|
||||
|
@ -5007,7 +5032,7 @@
|
|||
var story_hash = message.split(',')[0];
|
||||
var timestamp = message.split(',')[1];
|
||||
// NEWSBLUR.log(['Real-time new story', feed_id, story_hash, timestamp]);
|
||||
NEWSBLUR.app.dashboard_river.new_story(story_hash, timestamp);
|
||||
NEWSBLUR.app.dashboard_rivers.map(function(r) { r.new_story(story_hash, timestamp); });
|
||||
}, this));
|
||||
|
||||
this.socket.removeAllListeners(NEWSBLUR.Globals.username);
|
||||
|
|
|
@ -7,12 +7,11 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
},
|
||||
|
||||
initialize: function() {
|
||||
this.active_feed = 'river:';
|
||||
this.active_folder = NEWSBLUR.assets.folders;
|
||||
this.$stories = this.$(".NB-module-item .NB-story-titles");
|
||||
console.log('dashboard stories', this.options.el, this.$stories, this.options);
|
||||
this.story_titles = new NEWSBLUR.Views.StoryTitlesView({
|
||||
el: this.$stories,
|
||||
collection: NEWSBLUR.assets.dashboard_stories,
|
||||
collection: this.options.dashboard_stories,
|
||||
$story_titles: this.$stories,
|
||||
override_layout: 'split',
|
||||
on_dashboard: true
|
||||
|
@ -22,6 +21,12 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
story_hashes: []
|
||||
};
|
||||
|
||||
if (this.options.active_feed == "river:infrequent") {
|
||||
this.options.infrequent = NEWSBLUR.assets.preference('infrequent_stories_per_month');
|
||||
} else if (this.options.active_feed == "river:global") {
|
||||
this.options.global_feed = true;
|
||||
}
|
||||
|
||||
NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this));
|
||||
NEWSBLUR.assets.stories.bind('change:read_status', this.check_read_stories, this);
|
||||
// NEWSBLUR.assets.stories.bind('change:selected', this.check_read_stories, this);
|
||||
|
@ -31,14 +36,14 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
|
||||
feeds: function() {
|
||||
var feeds;
|
||||
var visible_only = NEWSBLUR.assets.view_setting(this.active_feed, 'read_filter') == 'unread';
|
||||
var visible_only = NEWSBLUR.assets.view_setting(this.options.active_feed, 'read_filter') == 'unread';
|
||||
if (visible_only) {
|
||||
feeds = _.pluck(this.active_folder.feeds_with_unreads(), 'id');
|
||||
feeds = _.pluck(this.options.active_folder.feeds_with_unreads(), 'id');
|
||||
if (!feeds.length) {
|
||||
feeds = this.active_folder.feed_ids_in_folder();
|
||||
feeds = this.options.active_folder.feed_ids_in_folder();
|
||||
}
|
||||
} else {
|
||||
feeds = this.active_folder.feed_ids_in_folder();
|
||||
feeds = this.options.active_folder.feed_ids_in_folder();
|
||||
}
|
||||
|
||||
return feeds;
|
||||
|
@ -58,7 +63,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
|
||||
clearTimeout(this.refresh_interval);
|
||||
this.refresh_interval = setTimeout(_.bind(function() {
|
||||
if (NEWSBLUR.reader.active_feed == this.active_feed) {
|
||||
if (NEWSBLUR.reader.active_feed == this.options.active_feed) {
|
||||
// Currently reading the river, so don't reload because it'll break the cache.
|
||||
console.log(['Currently reading river, so not reloading dashboard river', NEWSBLUR.reader.active_feed]);
|
||||
this.setup_dashboard_refresh();
|
||||
|
@ -73,17 +78,20 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
// ==========
|
||||
|
||||
load_stories: function(options) {
|
||||
options = options || {};
|
||||
// console.log(['dashboard river load_stories', this.page, options]);
|
||||
options = _.extend({
|
||||
global_feed: this.options.global_feed,
|
||||
infrequent: this.options.infrequent,
|
||||
query: this.options.query,
|
||||
}, options || {});
|
||||
if (options.feed_selector) return;
|
||||
// var feeds = NEWSBLUR.assets.folders.feed_ids_in_folder();
|
||||
var feeds = this.feeds();
|
||||
if (!feeds.length) return;
|
||||
if (!this.$stories.length) return;
|
||||
|
||||
console.log(['dashboard river load_stories', this.page, feeds.length, options]);
|
||||
this.page = 1;
|
||||
this.story_titles.show_loading();
|
||||
NEWSBLUR.assets.fetch_dashboard_stories(this.active_feed, feeds, this.page,
|
||||
NEWSBLUR.assets.fetch_dashboard_stories(this.options.active_feed, feeds, this.page, this.options.dashboard_stories, options,
|
||||
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
|
||||
|
||||
this.setup_dashboard_refresh();
|
||||
|
@ -91,11 +99,23 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
|
||||
post_load_stories: function() {
|
||||
this.fill_out();
|
||||
this.cache.story_hashes = NEWSBLUR.assets.dashboard_stories.pluck('story_hash');
|
||||
this.cache.story_hashes = this.options.dashboard_stories.pluck('story_hash');
|
||||
},
|
||||
|
||||
fill_out: function() {
|
||||
var visible = NEWSBLUR.assets.dashboard_stories.visible().length;
|
||||
fill_out: function(options) {
|
||||
options = _.extend({
|
||||
global_feed: this.options.global_feed,
|
||||
infrequent: this.options.infrequent,
|
||||
query: this.options.query
|
||||
}, options || {});
|
||||
|
||||
if (this.options.dashboard_stories.length == 0) {
|
||||
this.show_end_line();
|
||||
return;
|
||||
}
|
||||
|
||||
var visible = this.options.dashboard_stories.visible().length;
|
||||
console.log("Visible", visible, options)
|
||||
if (visible >= 3 && !NEWSBLUR.Globals.is_premium) {
|
||||
this.story_titles.check_premium_river();
|
||||
this.complete_fill();
|
||||
|
@ -132,14 +152,14 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
var feeds = this.feeds();
|
||||
this.page += 1;
|
||||
this.story_titles.show_loading();
|
||||
NEWSBLUR.assets.fetch_dashboard_stories(this.active_feed, feeds, this.page,
|
||||
NEWSBLUR.assets.fetch_dashboard_stories(this.options.active_feed, feeds, this.page, this.options.dashboard_stories, options,
|
||||
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
|
||||
},
|
||||
|
||||
check_read_stories: function(story, attr) {
|
||||
// console.log(['story read', story, story.get('story_hash'), story.get('read_status'), attr]);
|
||||
if (!_.contains(this.cache.story_hashes, story.get('story_hash'))) return;
|
||||
var dashboard_story = NEWSBLUR.assets.dashboard_stories.get_by_story_hash(story.get('story_hash'));
|
||||
var dashboard_story = this.options.dashboard_stories.get_by_story_hash(story.get('story_hash'));
|
||||
if (!dashboard_story) {
|
||||
console.log(['Error: missing story on dashboard', story, this.cache.story_hashes]);
|
||||
return;
|
||||
|
@ -163,7 +183,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
|
||||
complete_fill: function() {
|
||||
var feeds = this.feeds();
|
||||
NEWSBLUR.assets.complete_river(this.active_feed, feeds, this.page);
|
||||
NEWSBLUR.assets.complete_river(this.options.active_feed, feeds, this.page);
|
||||
},
|
||||
|
||||
new_story: function(story_hash, timestamp) {
|
||||
|
@ -174,12 +194,12 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
var oldest_story = NEWSBLUR.assets.dashboard_stories.last();
|
||||
var oldest_story = this.options.dashboard_stories.last();
|
||||
if (oldest_story) {
|
||||
var last_timestamp = parseInt(oldest_story.get('story_timestamp'), 10);
|
||||
timestamp = parseInt(timestamp, 10);
|
||||
|
||||
if (NEWSBLUR.assets.view_setting(this.active_feed, 'order') == 'newest') {
|
||||
if (NEWSBLUR.assets.view_setting(this.options.active_feed, 'order') == 'newest') {
|
||||
if (timestamp < last_timestamp) {
|
||||
// console.log(['New story older than last/oldest dashboard story', timestamp, '<', last_timestamp]);
|
||||
return;
|
||||
|
@ -202,9 +222,9 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
var delay = subs * 2; // 1,000 subs = 2 seconds
|
||||
console.log(['Fetching dashboard story', story_hash, delay + 'ms delay']);
|
||||
|
||||
_.delay(function() {
|
||||
NEWSBLUR.assets.add_dashboard_story(story_hash);
|
||||
}, Math.random() * delay);
|
||||
_.delay(_.bind(function() {
|
||||
NEWSBLUR.assets.add_dashboard_story(story_hash, this.options.dashboard_stories);
|
||||
}, this), Math.random() * delay);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
{% render_getting_started %}
|
||||
{% endif %}
|
||||
|
||||
<div class="NB-module NB-module-river">
|
||||
<div class="NB-module NB-module-river NB-module-river-1">
|
||||
<h5 class="NB-module-header">
|
||||
<div class="NB-module-river-settings NB-javascript"></div>
|
||||
All Site Stories
|
||||
|
@ -67,10 +67,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="NB-module NB-module-river">
|
||||
<div class="NB-module NB-module-river NB-module-river-2">
|
||||
<h5 class="NB-module-header">
|
||||
<div class="NB-module-river-settings NB-javascript"></div>
|
||||
Global Shared Stories
|
||||
Infrequent Site Stories
|
||||
</h5>
|
||||
|
||||
<div class="NB-view-river">
|
||||
|
@ -80,10 +80,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="NB-module NB-module-river">
|
||||
<div class="NB-module NB-module-river NB-module-river-3">
|
||||
<h5 class="NB-module-header">
|
||||
<div class="NB-module-river-settings NB-javascript"></div>
|
||||
Infrequent Site Stories
|
||||
Global Shared Stories
|
||||
</h5>
|
||||
|
||||
<div class="NB-view-river">
|
||||
|
@ -117,10 +117,10 @@
|
|||
|
||||
<div class="NB-account-wide">
|
||||
|
||||
<div class="NB-module NB-module-river">
|
||||
<div class="NB-module NB-module-river NB-module-river-4">
|
||||
<h5 class="NB-module-header">
|
||||
<div class="NB-module-river-settings NB-javascript"></div>
|
||||
Twitter
|
||||
"pizza" in All Site Stories
|
||||
</h5>
|
||||
|
||||
<div class="NB-view-river">
|
||||
|
|
|
@ -6,4 +6,4 @@ class DumpRequestMiddleware:
|
|||
if settings.DEBUG:
|
||||
request_items = request.REQUEST.items()
|
||||
if request_items:
|
||||
logging.debug(" ---> ~FC%s ~SN~FC%s ~SN~BC~FK%s~BK~FC %s" % (request.method, request.path, dict(request_items), request.COOKIES))
|
||||
logging.debug(" ---> ~FC%s ~SN~FC%s ~SN~BC~FK%s~BK~FC" % (request.method, request.path, dict(request_items)))
|
Loading…
Add table
Reference in a new issue