Permalink
Browse files

Merge branch 'master' of github.com:samuelclay/NewsBlur

* 'master' of github.com:samuelclay/NewsBlur:
  Immediately marking story as read when sending it to a service or opening in a new tab. Thanks to Jonas for the suggestion.
  Handling story-level original/story view bans, preventing iframe busts on nytimes/twitter. Thanks to @j4ded for the persistance.
  • Loading branch information...
2 parents d432214 + f6e0933 commit 941dcf486d73f155a23128f25165a6d16f933ef9 @samuelclay samuelclay committed May 10, 2012
Showing with 53 additions and 35 deletions.
  1. +42 −35 media/js/newsblur/reader.js
  2. +11 −0 media/js/newsblur/reader_utils.js
@@ -1906,31 +1906,29 @@
},
set_correct_story_view_for_feed: function(feed_id, view) {
- var feed = this.model.get_feed(feed_id);
- view = view || this.model.view_setting(feed_id);
-
- if (feed && feed.has_exception && feed.exception_type == 'page') {
- if (view == 'page') {
- view = 'feed';
+ var feed = this.model.get_feed(feed_id);
+ view = view || this.model.view_setting(feed_id);
+
+ if (feed && feed.disabled_page) {
+ view = 'feed';
+ $('.task_view_page').addClass('NB-disabled-page')
+ .addClass('NB-disabled');
+ $('.task_view_story').addClass('NB-disabled-page')
+ .addClass('NB-disabled');
+ } else if (feed && feed.has_exception && feed.exception_type == 'page') {
+ if (view == 'page') {
+ view = 'feed';
+ }
+ $('.task_view_page').addClass('NB-exception-page');
+ } else {
+ $('.task_view_page').removeClass('NB-disabled-page')
+ .removeClass('NB-disabled')
+ .removeClass('NB-exception-page');
+ $('.task_view_story').removeClass('NB-disabled-page')
+ .removeClass('NB-disabled');
}
- $('.task_view_page').addClass('NB-exception-page');
- } else if (feed && feed.disabled_page) {
- if (view == 'page') {
- view = 'feed';
- }
- $('.task_view_page').addClass('NB-disabled-page')
- .addClass('NB-disabled');
- $('.task_view_story').addClass('NB-disabled-page')
- .addClass('NB-disabled');
- } else {
- $('.task_view_page').removeClass('NB-disabled-page')
- .removeClass('NB-disabled')
- .removeClass('NB-exception-page');
- $('.task_view_story').removeClass('NB-disabled-page')
- .removeClass('NB-disabled');
- }
- this.story_view = view;
+ this.story_view = view;
},
// ===============
@@ -2790,7 +2788,7 @@
encodeURIComponent(story.story_title)
].join('');
window.open(instapaper_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_readitlater: function(story_id) {
@@ -2804,7 +2802,7 @@
encodeURIComponent(story.story_title)
].join('');
window.open(readitlater_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_tumblr: function(story_id) {
@@ -2818,7 +2816,7 @@
encodeURIComponent(story.story_title)
].join('');
window.open(tumblr_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_delicious: function(story_id) {
@@ -2832,7 +2830,7 @@
encodeURIComponent(story.story_title)
].join('');
window.open(delicious_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_readability: function(story_id) {
@@ -2846,7 +2844,7 @@
encodeURIComponent(story.story_title)
].join('');
window.open(readability_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_twitter: function(story_id) {
@@ -2860,7 +2858,7 @@
encodeURIComponent(story.story_permalink)
].join('');
window.open(twitter_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_facebook: function(story_id) {
@@ -2874,7 +2872,7 @@
encodeURIComponent(story.story_title)
].join('');
window.open(facebook_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_pinboard: function(story_id) {
@@ -2890,7 +2888,7 @@
encodeURIComponent(story.story_tags.join(', '))
].join('');
window.open(pinboard_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_googleplus: function(story_id) {
@@ -2906,12 +2904,12 @@
encodeURIComponent(story.story_tags.join(', '))
].join('');
window.open(googleplus_url, '_blank');
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
send_story_to_email: function(story_id) {
NEWSBLUR.reader_send_email = new NEWSBLUR.ReaderSendEmail(story_id);
- this.mark_story_as_read(story_id);
+ this.mark_story_as_read(story_id, true);
},
// =====================
@@ -3509,6 +3507,7 @@
var story = this.model.get_story(story_id);
window.open(story['story_permalink'], '_blank');
window.focus();
+ this.mark_story_as_read(story_id, true);
}
},
@@ -4182,8 +4181,16 @@
open_story_in_story_view: function(story, is_temporary) {
if (!story) story = this.active_story;
- this.switch_taskbar_view('story', is_temporary ? 'story' : false);
- this.load_story_iframe(story, story.story_feed_id);
+ var feed = this.model.get_feed(story.story_feed_id);
+ if ((feed && feed.disabled_page) ||
+ NEWSBLUR.utils.is_url_iframe_buster(story.story_permalink)) {
+ if (!is_temporary) {
+ this.switch_taskbar_view('feed', 'story');
+ }
+ } else {
+ this.switch_taskbar_view('story', is_temporary ? 'story' : false);
+ this.load_story_iframe(story, story.story_feed_id);
+ }
},
load_story_iframe: function(story, feed_id) {
@@ -118,6 +118,17 @@ NEWSBLUR.utils = {
}
return $options;
+ },
+
+ is_url_iframe_buster: function(url) {
+ var BROKEN_URLS = [
+ 'nytimes.com',
+ 'stackoverflow.com',
+ 'twitter.com'
+ ];
+ return _.any(BROKEN_URLS, function(broken_url) {
+ return _.includes(url, broken_url);
+ });
}
};

0 comments on commit 941dcf4

Please sign in to comment.