Merge branch 'dejal' into wkwebkit

This commit is contained in:
David Sinclair 2020-03-23 19:37:25 -07:00
commit c3556b06b8
16 changed files with 119 additions and 40 deletions

View file

@ -51,6 +51,7 @@ from apps.social.views import load_social_page
from apps.rss_feeds.tasks import ScheduleImmediateFetches
from utils import json_functions as json
from utils.user_functions import get_user, ajax_login_required
from utils.user_functions import extract_user_agent
from utils.feed_functions import relative_timesince
from utils.story_functions import format_story_link_date__short
from utils.story_functions import format_story_link_date__long
@ -240,7 +241,7 @@ def load_feeds(request):
feeds = {}
include_favicons = is_true(request.REQUEST.get('include_favicons', False))
flat = is_true(request.REQUEST.get('flat', False))
update_counts = is_true(request.REQUEST.get('update_counts', False))
update_counts = is_true(request.REQUEST.get('update_counts', True))
version = int(request.REQUEST.get('v', 1))
if include_favicons == 'false': include_favicons = False
@ -249,6 +250,12 @@ def load_feeds(request):
if flat: return load_feeds_flat(request)
platform = extract_user_agent(request)
if platform in ['iPhone', 'iPad', 'Androd']:
# Remove this check once the iOS and Android updates go out which have update_counts=False
# and then guarantee a refresh_feeds call
update_counts = False
try:
folders = UserSubscriptionFolders.objects.get(user=user)
except UserSubscriptionFolders.DoesNotExist:
@ -442,7 +449,14 @@ def load_feeds_flat(request):
}
return data
@ratelimit(minutes=1, requests=30)
class ratelimit_refresh_feeds(ratelimit):
def should_ratelimit(self, request):
feed_ids = request.POST.getlist('feed_id') or request.POST.getlist('feed_id[]')
if len(feed_ids) == 1:
return False
return True
@ratelimit_refresh_feeds(minutes=1, requests=30)
@never_cache
@json.json_view
def refresh_feeds(request):

View file

@ -38,6 +38,7 @@ BROKEN_PAGE_URLS = [
'rankexploits',
'gamespot.com',
'espn.com',
'royalroad.com',
]
class PageImporter(object):

View file

@ -76,6 +76,7 @@ def load_feed_favicon(request, feed_id):
try:
feed_icon = MFeedIcon.objects.get(feed_id=feed_id)
except MFeedIcon.DoesNotExist:
logging.user(request, "~FBNo feed icon found: %s" % feed_id)
not_found = True
if not_found or not feed_icon.data:
@ -270,7 +271,7 @@ def load_feed_settings(request, feed_id):
return stats
@ratelimit(minutes=5, requests=30)
@ratelimit(minutes=1, requests=30)
@json.json_view
def exception_retry(request):
user = get_user(request)

View file

@ -43,6 +43,7 @@
@interface FeedDetailViewController ()
@property (nonatomic) NSUInteger scrollingMarkReadRow;
@property (nonatomic, readonly) BOOL isMarkReadOnScroll;
@property (nonatomic, strong) NSString *restoringFolder;
@property (nonatomic, strong) NSString *restoringFeedID;
@ -1762,7 +1763,7 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (storyCount && indexPath.row == storyCount) {
if (!self.pageFinished) return 40;
BOOL markReadOnScroll = [[NSUserDefaults standardUserDefaults] boolForKey:@"default_scroll_read_filter"];
BOOL markReadOnScroll = self.isMarkReadOnScroll;
if (markReadOnScroll) {
return CGRectGetHeight(self.view.frame) - 40;
}
@ -1847,6 +1848,20 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
!self.isDashboardModule;
}
- (BOOL)isMarkReadOnScroll {
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
if ([userPreferences boolForKey:@"override_scroll_read_filter"]) {
NSNumber *markRead = [userPreferences objectForKey:appDelegate.storiesCollection.scrollReadFilterKey];
if (markRead != nil) {
return markRead.boolValue;
}
}
return [userPreferences boolForKey:@"default_scroll_read_filter"];
}
- (void)checkScroll {
NSInteger currentOffset = self.storyTitlesTable.contentOffset.y;
NSInteger maximumOffset = self.storyTitlesTable.contentSize.height - self.storyTitlesTable.frame.size.height;
@ -1865,7 +1880,7 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGPoint topRowPoint = self.storyTitlesTable.contentOffset;
topRowPoint.y = topRowPoint.y + 80.f;
NSIndexPath *indexPath = [self.storyTitlesTable indexPathForRowAtPoint:topRowPoint];
BOOL markReadOnScroll = [[NSUserDefaults standardUserDefaults] boolForKey:@"default_scroll_read_filter"];
BOOL markReadOnScroll = self.isMarkReadOnScroll;
if (indexPath && markReadOnScroll) {
NSUInteger topRow = indexPath.row;
@ -2226,6 +2241,10 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[self reloadStories];
}];
[viewController addSegmentedControlWithTitles:@[@"Mark read", @"Leave unread"] selectIndex:self.isMarkReadOnScroll ? 0 : 1 selectionShouldDismiss:YES handler:^(NSUInteger selectedIndex) {
[userPreferences setBool:selectedIndex == 0 forKey:appDelegate.storiesCollection.scrollReadFilterKey];
}];
}
NSString *preferenceKey = @"story_list_preview_text_size";

View file

@ -117,7 +117,9 @@ NSString * const MenuHandler = @"handler";
[self addSegmentedControlWithTitles:titles selectIndex:valueIndex selectionShouldDismiss:selectionShouldDismiss handler:^(NSUInteger selectedIndex) {
[userPreferences setObject:values[selectedIndex] forKey:preferenceKey];
handler(selectedIndex);
if (handler != nil) {
handler(selectedIndex);
}
}];
}

View file

@ -80,6 +80,7 @@
- (NSString *)activeStoryView;
- (NSString *)orderKey;
- (NSString *)readFilterKey;
- (NSString *)scrollReadFilterKey;
- (NSString *)storyViewKey;
- (void)setStories:(NSArray *)activeFeedStoriesValue;

View file

@ -288,6 +288,19 @@
}
}
- (NSString *)scrollReadFilterKey {
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
BOOL shouldOverride = [userPreferences boolForKey:@"override_scroll_read_filter"];
if (!shouldOverride) {
return @"default_scroll_read_filter";
} else if (self.isRiverView) {
return [NSString stringWithFormat:@"folder:%@:scroll_read_filter", self.activeFolder];
} else {
return [NSString stringWithFormat:@"%@:scroll_read_filter", [self.activeFeed objectForKey:@"id"]];
}
}
- (NSString *)storyViewKey {
if (self.isRiverView) {
return [NSString stringWithFormat:@"folder:%@:story_view", self.activeFolder];

View file

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina5_9" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -218,7 +216,6 @@
</state>
<connections>
<action selector="autoscrollDisable:" destination="-1" eventType="touchUpInside" id="AUl-NG-nw2"/>
<action selector="beginTouchDown:" destination="-1" eventType="touchDown" id="UFg-jO-mRy"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Uu8-vD-eak">
@ -238,7 +235,6 @@
</state>
<connections>
<action selector="autoscrollPauseResume:" destination="-1" eventType="touchUpInside" id="HdM-KI-fRH"/>
<action selector="beginTouchDown:" destination="-1" eventType="touchDown" id="nz0-kE-cwQ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qah-Lp-ocZ">
@ -258,7 +254,6 @@
</state>
<connections>
<action selector="autoscrollSlower:" destination="-1" eventType="touchUpInside" id="zFg-8j-Xa1"/>
<action selector="beginTouchDown:" destination="-1" eventType="touchDown" id="8HO-L0-Mc7"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DHS-JI-8yT">
@ -278,7 +273,6 @@
</state>
<connections>
<action selector="autoscrollFaster:" destination="-1" eventType="touchUpInside" id="Bak-TC-duJ"/>
<action selector="beginTouchDown:" destination="-1" eventType="touchDown" id="8Jz-7M-FtT"/>
</connections>
</button>
</subviews>

View file

@ -3640,7 +3640,7 @@
CODE_SIGN_ENTITLEMENTS = "Share Extension/Share Extension.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = HR7P97SD72;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -3660,7 +3660,7 @@
INFOPLIST_FILE = "Share Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 10.0;
MARKETING_VERSION = 10.0.1;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Share-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -3690,7 +3690,7 @@
CODE_SIGN_ENTITLEMENTS = "Share Extension/Share Extension.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = HR7P97SD72;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -3704,7 +3704,7 @@
INFOPLIST_FILE = "Share Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 10.0;
MARKETING_VERSION = 10.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Share-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -3736,7 +3736,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = HR7P97SD72;
GCC_C_LANGUAGE_STANDARD = gnu11;
@ -3751,7 +3751,7 @@
INFOPLIST_FILE = "Widget Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 10.0;
MARKETING_VERSION = 10.0.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.newsblur.NewsBlur.widget;
@ -3785,7 +3785,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = HR7P97SD72;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
@ -3794,7 +3794,7 @@
INFOPLIST_FILE = "Widget Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 10.0;
MARKETING_VERSION = 10.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.newsblur.NewsBlur.widget;
@ -3817,7 +3817,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = HR7P97SD72;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -3866,7 +3866,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = HR7P97SD72;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -4013,7 +4013,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = HR7P97SD72;
GCC_C_LANGUAGE_STANDARD = gnu99;
@ -4028,7 +4028,7 @@
INFOPLIST_FILE = "Story Notification Service Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 10.0;
MARKETING_VERSION = 10.0.1;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Story-Notification-Service-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -4053,7 +4053,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 108;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = HR7P97SD72;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
@ -4062,7 +4062,7 @@
INFOPLIST_FILE = "Story Notification Service Extension/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 10.0;
MARKETING_VERSION = 10.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.newsblur.NewsBlur.Story-Notification-Service-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";

View file

@ -142,15 +142,25 @@
<key>Key</key>
<string>show_global_shared_stories</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Mark stories read on scroll</string>
<key>DefaultValue</key>
<string>YES</string>
<key>Key</key>
<string>default_scroll_read_filter</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Mark stories read on scroll</string>
<string>Override scroll read per feed/folder</string>
<key>DefaultValue</key>
<string>YES</string>
<key>Key</key>
<string>default_scroll_read_filter</string>
<string>override_scroll_read_filter</string>
</dict>
<dict>
<key>Type</key>

View file

@ -152,6 +152,16 @@
<key>Key</key>
<string>default_scroll_read_filter</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Override scroll read per feed/folder</string>
<key>DefaultValue</key>
<string>YES</string>
<key>Key</key>
<string>override_scroll_read_filter</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>

View file

@ -579,6 +579,13 @@ private extension WidgetExtensionViewController {
return
}
let size = loadedImage.size
guard size.width >= 50, size.height >= 50 else {
completion(nil, identifier)
return
}
let scaledImage = self.scale(image: loadedImage)
self.save(storyImage: scaledImage, for: identifier)

View file

@ -42,7 +42,8 @@ struct Story: Codable, Identifiable {
static let author = "story_authors"
static let title = "story_title"
static let content = "story_content"
static let imageURLs = "secure_image_thumbnails"
static let imageURLs = "image_urls"
static let secureImageURLs = "secure_image_thumbnails"
}
/// Initializer from a dictionary.
@ -56,8 +57,8 @@ struct Story: Codable, Identifiable {
title = dictionary[DictionaryKeys.title] as? String ?? ""
content = dictionary[DictionaryKeys.content] as? String ?? ""
if let images = dictionary[DictionaryKeys.imageURLs] as? [String : String], let first = images.values.first {
imageURL = URL(string: first)
if let imageURLs = dictionary[DictionaryKeys.imageURLs] as? [String], let first = imageURLs.first, let secureImages = dictionary[DictionaryKeys.secureImageURLs] as? [String : String], let url = secureImages[first] {
imageURL = URL(string: url)
} else {
imageURL = nil
}

View file

@ -283,7 +283,8 @@ NEWSBLUR.Collections.Feeds = Backbone.Collection.extend({
fetch: function(options) {
var data = {
'v': 2
'v': 2,
'update_counts': false
};
options = _.extend({

View file

@ -4888,10 +4888,14 @@
this.socket.removeAllListeners('feed:update');
this.socket.on('feed:update', _.bind(function(feed_id, message) {
NEWSBLUR.log(['Real-time feed update', feed_id, message]);
this.feed_unread_count(feed_id, {
realtime: true
});
var feed = this.model.get_feed(feed_id);
if (feed && !feed.get('fetched_once')) {
this.force_feed_refresh(feed_id);
} else {
this.feed_unread_count(feed_id, {
realtime: true
});
}
}, this));
this.socket.removeAllListeners('feed:story:new');

View file

@ -197,7 +197,8 @@ NEWSBLUR.utils = {
'stackexchange.com',
'twitter.com',
'rankexploits',
'gamespot.com'
'gamespot.com',
'royalroad.com'
];
return _.any(BROKEN_URLS, function(broken_url) {
return _.string.contains(url, broken_url);