Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: samuelclay/NewsBlur
base: 6c30e071d1
...
head fork: samuelclay/NewsBlur
compare: bc40a1bb82
  • 3 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
8 media/js/newsblur/common/assetmodel.js
View
@@ -611,7 +611,13 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
feed = feed_id;
feed_id = feed.id;
}
- this.feeds.get(feed_id).set(feed);
+ if (!this.feeds.get(feed)) {
+ this.feeds.add(feed);
+ } else {
+ this.feeds.get(feed_id).set(feed);
+ }
+
+ return this.feeds.get(feed_id);
},
add_social_feed: function(feed) {
4 media/js/newsblur/models/feeds.js
View
@@ -25,9 +25,9 @@ NEWSBLUR.Models.Feed = Backbone.Model.extend({
delete_feed: function(options) {
options = options || {};
var view = options.view || this.get_view();
- console.log(["Delete Feed", this, view, view.collection.options.title]);
+ console.log(["Delete Feed", this, view, view.collection && view.collection.options.title]);
- NEWSBLUR.assets.delete_feed(this.id, view.collection.options.title);
+ NEWSBLUR.assets.delete_feed(this.id, view.collection && view.collection.options.title);
view.delete_feed();
},
63 media/js/newsblur/models/stories.js
View
@@ -89,9 +89,9 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
if (feed.is_social()) {
mark_read_fn = NEWSBLUR.assets.mark_social_story_as_read;
}
- mark_read_fn.call(NEWSBLUR.assets, story.id, story.get('story_feed_id'), function(read) {
- NEWSBLUR.reader.update_read_count(story.id, story.get('story_feed_id'), {previously_read: read});
- });
+ mark_read_fn.call(NEWSBLUR.assets, story.id, story.get('story_feed_id'), _.bind(function(read) {
+ this.update_read_count(story, {previously_read: read});
+ }, this));
story.set('read_status', 1);
}
}, this), delay * 1000);
@@ -99,21 +99,52 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
mark_unread: function(story, options) {
options = options || {};
- NEWSBLUR.assets.mark_story_as_unread(story.id, story.get('story_feed_id'), function(read) {
- NEWSBLUR.reader.update_read_count(story.id, story.get('story_feed_id'), {unread: true});
- });
+ NEWSBLUR.assets.mark_story_as_unread(story.id, story.get('story_feed_id'), _.bind(function(read) {
+ this.update_read_count(story, {unread: true});
+ }, this));
story.set('read_status', 0);
},
+ update_read_count: function(story, options) {
+ options = options || {};
+
+ if (options.previously_read) return;
+
+ var story_unread_counter = NEWSBLUR.app.story_unread_counter;
+ var unread_view = NEWSBLUR.reader.get_unread_view_name();
+ var feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id'));
+
+ if (story.score() > 0) {
+ var count = Math.max(feed.get('ps') + (options.unread?1:-1), 0);
+ feed.set('ps', count, {instant: true});
+ } else if (story.score() == 0) {
+ var count = Math.max(feed.get('nt') + (options.unread?1:-1), 0);
+ feed.set('nt', count, {instant: true});
+ } else if (story.score() < 0) {
+ var count = Math.max(feed.get('ng') + (options.unread?1:-1), 0);
+ feed.set('ng', count, {instant: true});
+ }
+
+ if (story_unread_counter) {
+ story_unread_counter.flash();
+ }
+
+ // if ((unread_view == 'positive' && feed.get('ps') == 0) ||
+ // (unread_view == 'neutral' && feed.get('ps') == 0 && feed.get('nt') == 0) ||
+ // (unread_view == 'negative' && feed.get('ps') == 0 && feed.get('nt') == 0 && feed.get('ng') == 0)) {
+ // story_unread_counter.fall();
+ // }
+ },
+
// ==================
// = Model Managers =
// ==================
- visible: function() {
- var unread_score = NEWSBLUR.assets.preference('unread_view');
+ visible: function(score) {
+ score = _.isUndefined(score) ? NEWSBLUR.assets.preference('unread_view') : score;
return this.select(function(story) {
- return story.score() >= unread_score;
+ return story.score() >= score;
});
},
@@ -129,10 +160,11 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
// = Getters =
// ===========
- get_next_story: function(direction) {
- if (direction == -1) return this.get_previous_story();
-
- var visible_stories = this.visible();
+ get_next_story: function(direction, options) {
+ options = options || {};
+ if (direction == -1) return this.get_previous_story(options);
+ console.log(["next at score", options]);
+ var visible_stories = this.visible(options.score);
if (!this.active_story) {
return visible_stories[0];
@@ -145,8 +177,9 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
}
},
- get_previous_story: function() {
- var visible_stories = this.visible();
+ get_previous_story: function(options) {
+ options = options || {};
+ var visible_stories = this.visible(options.score);
if (!this.active_story) {
return visible_stories[0];
171 media/js/newsblur/reader/reader.js
View
@@ -452,40 +452,12 @@
// = Getters and Finders =
// =======================
- find_feed_in_feed_list: function(feed_id) {
- var $feed_list = this.$s.$feed_list.parent();
- var $feeds = $([]);
- if (feed_id) {
- $('.feed', $feed_list).each(function() {
- var data_id = $(this).data('id');
- if (data_id == feed_id ||
- (!_.string.contains(data_id, 'social:') && parseInt(data_id, 10) == feed_id)) {
- $feeds.push($(this).get(0));
- }
- });
- }
-
- return $feeds;
- },
-
- find_folder_in_feed_list: function(folder_name) {
- var $feed_list = this.$s.$feed_list;
- var $folders = $([]);
- $('.folder_title_text', $feed_list).each(function() {
- if ($(this).text() == folder_name) {
- $folders.push($(this).parents('li.folder').eq(0)[0]);
- }
- });
-
- return $folders;
- },
-
find_story_in_story_titles: function(story_id) {
var story = story_id && this.model.get_story(story_id);
if (!story_id) story = this.active_story;
var $stories = $('.story', this.$s.$story_titles);
var $story_title;
-
+ console.log(["DEPRECATED find_story_in_story_titles", story]);
if (story) {
$stories.each(function() {
var $this = $(this);
@@ -505,7 +477,10 @@
// ==============
show_next_story: function(direction) {
- var story = NEWSBLUR.assets.stories.get_next_story(direction);
+ var story = NEWSBLUR.assets.stories.get_next_story(direction, {
+ score: this.get_unread_view_score()
+ });
+
if (story) {
story.set('selected', true);
}
@@ -1080,6 +1055,7 @@
var temp = feed.get('temp') || !feed.get('subscribed');
if (!feed || (temp && !options.try_feed)) {
+ // Setup tryfeed views first, then come back here.
return this.load_feed_in_tryfeed_view(feed_id, options);
}
@@ -1158,7 +1134,7 @@
// this.make_story_feed_entries(stories, first_load);
this.find_story_with_action_preference_on_open_feed();
this.show_feed_hidden_story_title_indicator(true);
- // this.show_story_titles_above_intelligence_level({'animate': false});
+ this.show_story_titles_above_intelligence_level({'animate': false});
// this.scroll_story_titles_to_show_selected_story_title();
// this.fill_out_story_titles();
if (this.counts['find_next_unread_on_page_of_feed_stories_load']) {
@@ -1625,7 +1601,7 @@
// // So just assume story not found.
// this.switch_to_correct_view(false);
// feed_position = this.scroll_to_story_in_story_feed(story, $feed_story, options);
- // this.show_stories_preference_in_feed_view(true);
+ // NEWSBLUR.app.story_list.show_stories_preference_in_feed_view(true);
// } else {
// iframe_position = this.scroll_to_story_in_iframe(story, $iframe_story);
// this.switch_to_correct_view(iframe_position);
@@ -1633,7 +1609,7 @@
// } else if (this.story_view == 'feed') {
// this.switch_to_correct_view();
// feed_position = this.scroll_to_story_in_story_feed(story, $feed_story, options);
- // this.show_stories_preference_in_feed_view(true);
+ // NEWSBLUR.app.story_list.show_stories_preference_in_feed_view(true);
// } else if (this.story_view == 'story') {
// this.open_story_in_story_view(story);
// }
@@ -1649,7 +1625,7 @@
this.flags['page_view_showing_feed_view'] = true;
this.flags['feed_view_showing_story_view'] = false;
this.switch_taskbar_view('feed', 'page');
- this.show_stories_preference_in_feed_view();
+ NEWSBLUR.app.story_list.show_stories_preference_in_feed_view();
}
} else {
if (this.story_view == 'page' && this.flags['page_view_showing_feed_view']) {
@@ -1666,40 +1642,6 @@
}
},
- update_read_count: function(story_id, feed_id, options) {
- options = options || {};
-
- if (options.previously_read) return;
-
- var feed = this.model.get_feed(feed_id);
- var story = this.model.get_story(story_id);
- var $feed_list = this.$s.$feed_list;
- var $content_pane = this.$s.$content_pane;
- var story_unread_counter = NEWSBLUR.app.story_unread_counter;
- var unread_view = this.get_unread_view_name();
-
- if (story.score() > 0) {
- var count = Math.max(feed.get('ps') + (options.unread?1:-1), 0);
- feed.set('ps', count, {instant: true});
- } else if (story.score() == 0) {
- var count = Math.max(feed.get('nt') + (options.unread?1:-1), 0);
- feed.set('nt', count, {instant: true});
- } else if (story.score() < 0) {
- var count = Math.max(feed.get('ng') + (options.unread?1:-1), 0);
- feed.set('ng', count, {instant: true});
- }
-
- if (story_unread_counter) {
- story_unread_counter.flash();
- }
-
- // if ((unread_view == 'positive' && feed.get('ps') == 0) ||
- // (unread_view == 'neutral' && feed.get('ps') == 0 && feed.get('nt') == 0) ||
- // (unread_view == 'negative' && feed.get('ps') == 0 && feed.get('nt') == 0 && feed.get('ng') == 0)) {
- // story_unread_counter.fall();
- // }
- },
-
mark_feed_as_read: function(feed_id) {
feed_id = feed_id || this.active_feed;
@@ -1993,7 +1935,10 @@
} else if (unread_view_name == 'neutral') {
hidden_stories = !!feed.get('ng');
}
- if (!hidden_stories) return;
+ if (!hidden_stories) {
+ $indicator.hide();
+ return;
+ }
$indicator.css({'display': 'block', 'opacity': 0});
if (is_feed_load) {
@@ -2034,16 +1979,14 @@
var unread_view_name = $indicator.hasClass('unread_threshold_positive') ?
'positive' :
'neutral';
- var hidden_stories_at_threshold = _.any(this.model.stories, _.bind(function(story) {
- var score = this.compute_story_score(story);
-
+ var hidden_stories_at_threshold = this.model.stories.any(_.bind(function(story) {
+ var score = story.score();
if (unread_view_name == 'positive') return score == 0;
else if (unread_view_name == 'neutral') return score < 0;
}, this));
var hidden_stories_below_threshold = unread_view_name == 'positive' &&
- _.any(this.model.stories, _.bind(function(story) {
- var score = this.compute_story_score(story);
- return score < 0;
+ this.model.stories.any(_.bind(function(story) {
+ return story.score() < 0;
}, this));
// NEWSBLUR.log(['show_hidden_story_titles', hidden_stories_at_threshold, hidden_stories_below_threshold, unread_view_name]);
@@ -2054,8 +1997,7 @@
this.show_story_titles_above_intelligence_level({
'unread_view_name': 'neutral',
'animate': true,
- 'follow': true,
- 'temporary': true
+ 'follow': true
});
$indicator.removeClass('unread_threshold_positive').addClass('unread_threshold_neutral');
} else {
@@ -2063,8 +2005,7 @@
this.show_story_titles_above_intelligence_level({
'unread_view_name': 'negative',
'animate': true,
- 'follow': true,
- 'temporary': true
+ 'follow': true
});
$indicator.removeClass('unread_threshold_positive')
.removeClass('unread_threshold_neutral')
@@ -2183,7 +2124,7 @@
var $feed_view = this.$s.$feed_view;
var $stories = this.$s.$feed_stories;
var self = this;
- var unread_view = this.model.preference('unread_view');
+ var unread_view = this.get_unread_view_score();
var river_same_feed;
var feed = this.model.get_feed(this.active_feed);
@@ -2223,7 +2164,7 @@
// this.fetch_story_locations_in_feed_view({'reset_timer': true});
}
- if (first_load) this.show_stories_preference_in_feed_view(true);
+ if (first_load) NEWSBLUR.app.story_list.show_stories_preference_in_feed_view(true);
},
make_story_content: function(story_content) {
@@ -2311,6 +2252,7 @@
});
} else if (view == 'feed') {
NEWSBLUR.app.story_list.scroll_to_selected_story(this.active_story, {immediate: true});
+ NEWSBLUR.app.story_list.show_stories_preference_in_feed_view();
$story_pane.animate({
'left': -1 * $feed_iframe.width()
@@ -2320,7 +2262,6 @@
'queue': false
});
- this.show_stories_preference_in_feed_view();
if (!this.flags['feed_view_positions_calculated']) {
// this.prefetch_story_locations_in_feed_view();
}
@@ -2367,31 +2308,6 @@
}
},
- show_stories_preference_in_feed_view: function(is_creating) {
- var $feed_view = this.$s.$feed_view;
- var $feed_view_stories = $(".NB-feed-story", $feed_view);
- var $stories = this.$s.$feed_stories;
- var story = this.active_story;
-
- if (story && this.model.preference('feed_view_single_story')) {
- // NEWSBLUR.log(['show_stories_preference_in_feed_view', is_creating, this.model.preference('feed_view_single_story'), $feed_view_stories.length + " stories"]);
- $stories.removeClass('NB-feed-view-feed').addClass('NB-feed-view-story');
- $feed_view_stories.css({'display': 'none'});
- if (is_creating) this.$s.$feed_stories.scrollTop('0px');
- var $current_story = this.get_current_story_from_story_titles($feed_view_stories);
- if ($current_story && $current_story.length) {
- $current_story.css({'display': 'block'});
- }
- this.flags['feed_view_positions_calculated'] = false;
- } else {
- $stories.removeClass('NB-feed-view-story').addClass('NB-feed-view-feed');
- if (!is_creating) {
- this.show_story_titles_above_intelligence_level({'animate': false});
- }
- }
- NEWSBLUR.app.story_list.cache.story_pane_position = null;
- },
-
// ===================
// = Taskbar - Feeds =
// ===================
@@ -3360,7 +3276,7 @@
load_intelligence_slider: function() {
var self = this;
var $slider = this.$s.$intelligence_slider;
- var unread_view = this.model.preference('unread_view');
+ var unread_view = this.get_unread_view_score();
this.slide_intelligence_slider(unread_view);
},
@@ -3370,9 +3286,10 @@
if (this.model.preference('unread_view') != value) {
this.model.preference('unread_view', value);
}
+ this.flags['unread_threshold_temporarily'] = null;
this.flags['feed_view_positions_calculated'] = false;
this.switch_feed_view_unread_view(value);
- this.show_feed_hidden_story_title_indicator();
+ this.show_feed_hidden_story_title_indicator(true);
this.show_story_titles_above_intelligence_level({'animate': true, 'follow': true});
$('.NB-active', $slider).removeClass('NB-active');
@@ -3386,14 +3303,12 @@
},
move_intelligence_slider: function(direction) {
- var $slider = this.$s.$intelligence_slider;
var value = this.model.preference('unread_view') + direction;
- $slider.slider({value: value});
this.slide_intelligence_slider(value);
},
switch_feed_view_unread_view: function(unread_view) {
- if (!_.isNumber(unread_view)) unread_view = this.model.preference('unread_view');
+ if (!_.isNumber(unread_view)) unread_view = this.get_unread_view_score();
var $feed_list = this.$s.$feed_list;
var $social_feeds = this.$s.$social_feeds;
var unread_view_name = this.get_unread_view_name(unread_view);
@@ -3420,9 +3335,26 @@
.addClass('unread_threshold_'+unread_view_name);
},
+ get_unread_view_score: function() {
+ if (this.flags['unread_threshold_temporarily']) {
+ var score_name = this.flags['unread_threshold_temporarily'];
+ if (score_name == 'neutral') {
+ return 0;
+ } else if (score_name == 'negative') {
+ return -1;
+ }
+ }
+
+ return this.model.preference('unread_view');
+ },
+
get_unread_view_name: function(unread_view) {
+ if (this.flags['unread_threshold_temporarily']) {
+ return this.flags['unread_threshold_temporarily'];
+ }
+
if (typeof unread_view == 'undefined') {
- unread_view = this.model.preference('unread_view');
+ unread_view = this.get_unread_view_score();
}
return (unread_view > 0
@@ -3483,7 +3415,6 @@
}
if (this.flags['unread_threshold_temporarily']) {
- unread_view_name = this.flags['unread_threshold_temporarily'];
options['temporary'] = true;
}
@@ -3529,8 +3460,9 @@
}
}
- NEWSBLUR.log(['Showing correct stories', this.story_view, this.flags['feed_view_positions_calculated'], unread_view_name, $stories_show.length, $stories_hide.length]);
- if (options['animate'] && options['follow']) {
+ if (options['animate'] && options['follow'] &&
+ ($stories_hide.length || $stories_show.length)) {
+ // NEWSBLUR.log(['Showing correct stories', this.story_view, this.flags['feed_view_positions_calculated'], unread_view_name, $stories_show.length, $stories_hide.length]);
if (this.model.preference('animations')) {
$stories_hide.slideUp(500, function() {
NEWSBLUR.app.story_titles.fill_out();
@@ -4157,9 +4089,9 @@
var $tryfeed_container = this.$s.$tryfeed_header.closest('.NB-feeds-header-container');
this.reset_feed();
- this.model.set_feed(feed_id, feed);
+ feed = this.model.set_feed(feed_id, feed);
- $('.NB-feeds-header-title', this.$s.$tryfeed_header).text(feed.feed_title);
+ $('.NB-feeds-header-title', this.$s.$tryfeed_header).text(feed.get('feed_title'));
$('.NB-feeds-header-icon', this.$s.$tryfeed_header).attr('src', $.favicon(feed));
$tryfeed_container.slideDown(350, _.bind(function() {
@@ -4234,7 +4166,8 @@
},
add_recommended_feed: function(feed_id) {
- var feed_address = this.model.get_feed(feed_id ? feed_id : this.active_feed).feed_address;
+ feed_id = feed_id || this.active_feed;
+ var feed_address = this.model.get_feed(feed_id).get('feed_address');
this.open_add_feed_modal({url: feed_address});
},
1  media/js/newsblur/views/feed_title_view.js
View
@@ -147,7 +147,6 @@ NEWSBLUR.Views.FeedTitleView = Backbone.View.extend({
this.counts_view = new NEWSBLUR.Views.FeedCount({model: this.model}).render();
this.$('.feed_counts').html(this.counts_view.el);
if (this.options.type == 'story') {
- console.log(["Counting for hidden stories", this.counts_view]);
this.$('.NB-story-title-indicator-count').html(this.counts_view.$el.clone());
}
},
31 media/js/newsblur/views/story_list_view.js
View
@@ -123,6 +123,31 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
this.cache.feed_title_floater_story_id = null;
}
},
+
+ show_stories_preference_in_feed_view: function(is_creating) {
+ var $feed_view = NEWSBLUR.reader.$s.$feed_view;
+ var $feed_view_stories = $(".NB-feed-story", $feed_view);
+ var $stories = NEWSBLUR.reader.$s.$feed_stories;
+ var story = NEWSBLUR.reader.active_story;
+
+ if (story && NEWSBLUR.assets.preference('feed_view_single_story')) {
+ // NEWSBLUR.log(['show_stories_preference_in_feed_view', is_creating, NEWSBLUR.assets.preference('feed_view_single_story'), $feed_view_stories.length + " stories"]);
+ $stories.removeClass('NB-feed-view-feed').addClass('NB-feed-view-story');
+ $feed_view_stories.css({'display': 'none'});
+ if (is_creating) this.$s.$feed_stories.scrollTop('0px');
+ var $current_story = this.get_current_story_from_story_titles($feed_view_stories);
+ if ($current_story && $current_story.length) {
+ $current_story.css({'display': 'block'});
+ }
+ this.flags['feed_view_positions_calculated'] = false;
+ } else {
+ $stories.removeClass('NB-feed-view-story').addClass('NB-feed-view-feed');
+ if (!is_creating) {
+ NEWSBLUR.reader.show_story_titles_above_intelligence_level({'animate': false});
+ }
+ }
+ NEWSBLUR.app.story_list.cache.story_pane_position = null;
+ },
// =============
// = Positions =
@@ -130,7 +155,7 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
prefetch_story_locations_in_feed_view: function() {
var self = this;
- var stories = this.model.stories;
+ var stories = NEWSBLUR.assets.stories;
// NEWSBLUR.log(['Prefetching', this.flags['feed_view_positions_calculated'], this.flags.feed_view_images_loaded, (_.keys(this.flags.feed_view_images_loaded).length > 0 || this.cache.feed_view_story_positions_keys.length > 0)]);
if (!this.flags['feed_view_positions_calculated']) {
@@ -168,7 +193,7 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
fetch_story_locations_in_feed_view: function(options) {
options = options || {};
- var stories = this.model.stories;
+ var stories = NEWSBLUR.assets.stories;
if (!stories || !stories.length) return;
if (options.reset_timer) this.counts['feed_view_positions_timer'] = 0;
@@ -184,7 +209,7 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
}
this.flags['feed_view_positions_calculated'] = true;
- // NEWSBLUR.log(['Feed view entirely loaded', this.model.stories.length + " stories", this.counts['feed_view_positions_timer']/1000 + " sec delay"]);
+ // NEWSBLUR.log(['Feed view entirely loaded', NEWSBLUR.assets.stories.length + " stories", this.counts['feed_view_positions_timer']/1000 + " sec delay"]);
this.counts['feed_view_positions_timer'] = Math.max(this.counts['feed_view_positions_timer']*2, 1000);
clearTimeout(this.flags['next_fetch']);
3  media/js/newsblur/views/story_titles_view.js
View
@@ -174,7 +174,8 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({
snap_back_scroll_position: function() {
var $story_titles = NEWSBLUR.reader.$s.$story_titles;
- if (this.post_load_page_scroll_position == $story_titles.scrollTop() && this.pre_load_page_scroll_position != null) {
+ if (this.post_load_page_scroll_position == $story_titles.scrollTop() &&
+ this.pre_load_page_scroll_position != null) {
$story_titles.scrollTo(this.pre_load_page_scroll_position, {
duration: 0,
axis: 'y',
6 templates/reader/feeds.xhtml
View
@@ -568,12 +568,6 @@
<span class="NB-task-title">Story</span>
</div>
</li>
- <li class="task_button NB-task-feed-settings">
- <div class="NB-task-button-wrapper">
- <div class="task_button_background"></div>
- <div class="NB-task-image"></div>
- </div>
- </li>
</ul>
<ul class="taskbar_nav taskbar_nav_story first">
<li class="task_button task_button_story task_story_previous">

No commit comments for this range

Something went wrong with that request. Please try again.