From f37ce4357e13ddc760d53608b21375f16f6945f0 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 28 Dec 2019 16:04:24 -0700 Subject: [PATCH 1/5] Delete obsolete code --- NetNewsWire.xcodeproj/project.pbxproj | 8 -------- .../ArticleExtractorConfig.swift | 15 --------------- 2 files changed, 23 deletions(-) delete mode 100644 Shared/Article Extractor/ArticleExtractorConfig.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 56fc5acb6..3e8b9b83f 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -259,8 +259,6 @@ 51FA73A52332BE110090D516 /* ArticleExtractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A32332BE110090D516 /* ArticleExtractor.swift */; }; 51FA73A72332BE880090D516 /* ExtractedArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A62332BE880090D516 /* ExtractedArticle.swift */; }; 51FA73A82332BE880090D516 /* ExtractedArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A62332BE880090D516 /* ExtractedArticle.swift */; }; - 51FA73AA2332C2FD0090D516 /* ArticleExtractorConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A92332C2FD0090D516 /* ArticleExtractorConfig.swift */; }; - 51FA73AB2332C2FD0090D516 /* ArticleExtractorConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A92332C2FD0090D516 /* ArticleExtractorConfig.swift */; }; 51FA73B72332D5F70090D516 /* ArticleExtractorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73B62332D5F70090D516 /* ArticleExtractorButton.swift */; }; 51FD413B2342BD0500880194 /* MasterTimelineUnreadCountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FD413A2342BD0500880194 /* MasterTimelineUnreadCountView.swift */; }; 51FE10032345529D0056195D /* UserNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FE10022345529D0056195D /* UserNotificationManager.swift */; }; @@ -279,7 +277,6 @@ 65ED3FB7235DEF6C0081F399 /* ArticleArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F204DF1FAACBB30076E152 /* ArticleArray.swift */; }; 65ED3FB8235DEF6C0081F399 /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848B937121C8C5540038DC0D /* CrashReporter.swift */; }; 65ED3FB9235DEF6C0081F399 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847CD6C9232F4CBF00FAC46D /* IconView.swift */; }; - 65ED3FBA235DEF6C0081F399 /* ArticleExtractorConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A92332C2FD0090D516 /* ArticleExtractorConfig.swift */; }; 65ED3FBB235DEF6C0081F399 /* InspectorWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BBB12C20142A4700F054F5 /* InspectorWindowController.swift */; }; 65ED3FBC235DEF6C0081F399 /* ColorHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F78227716380050506E /* ColorHash.swift */; }; 65ED3FBD235DEF6C0081F399 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */; }; @@ -1379,7 +1376,6 @@ 51F85BFC2275DCA800C787DC /* SingleLineUILabelSizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleLineUILabelSizer.swift; sourceTree = ""; }; 51FA73A32332BE110090D516 /* ArticleExtractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleExtractor.swift; sourceTree = ""; }; 51FA73A62332BE880090D516 /* ExtractedArticle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtractedArticle.swift; sourceTree = ""; }; - 51FA73A92332C2FD0090D516 /* ArticleExtractorConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleExtractorConfig.swift; sourceTree = ""; }; 51FA73B62332D5F70090D516 /* ArticleExtractorButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleExtractorButton.swift; sourceTree = ""; }; 51FD413A2342BD0500880194 /* MasterTimelineUnreadCountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineUnreadCountView.swift; sourceTree = ""; }; 51FE10022345529D0056195D /* UserNotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNotificationManager.swift; sourceTree = ""; }; @@ -2014,7 +2010,6 @@ 51FA739A2332BDE70090D516 /* Article Extractor */ = { isa = PBXGroup; children = ( - 51FA73A92332C2FD0090D516 /* ArticleExtractorConfig.swift */, 51FA73A32332BE110090D516 /* ArticleExtractor.swift */, 51FA73A62332BE880090D516 /* ExtractedArticle.swift */, ); @@ -3668,7 +3663,6 @@ 65ED3FB7235DEF6C0081F399 /* ArticleArray.swift in Sources */, 65ED3FB8235DEF6C0081F399 /* CrashReporter.swift in Sources */, 65ED3FB9235DEF6C0081F399 /* IconView.swift in Sources */, - 65ED3FBA235DEF6C0081F399 /* ArticleExtractorConfig.swift in Sources */, 65ED3FBB235DEF6C0081F399 /* InspectorWindowController.swift in Sources */, 65ED3FBC235DEF6C0081F399 /* ColorHash.swift in Sources */, 65ED3FBD235DEF6C0081F399 /* AppDefaults.swift in Sources */, @@ -3860,7 +3854,6 @@ FF3ABF162325AF5D0074C542 /* ArticleSorter.swift in Sources */, 51C4525C226508DF00C03939 /* String-Extensions.swift in Sources */, 51C452792265091600C03939 /* MasterTimelineTableViewCell.swift in Sources */, - 51FA73AB2332C2FD0090D516 /* ArticleExtractorConfig.swift in Sources */, 51C4526B226508F600C03939 /* MasterFeedViewController.swift in Sources */, 5126EE97226CB48A00C22AFC /* SceneCoordinator.swift in Sources */, 84CAFCB022BC8C35007694F0 /* FetchRequestOperation.swift in Sources */, @@ -3965,7 +3958,6 @@ 84F204E01FAACBB30076E152 /* ArticleArray.swift in Sources */, 848B937221C8C5540038DC0D /* CrashReporter.swift in Sources */, 847CD6CA232F4CBF00FAC46D /* IconView.swift in Sources */, - 51FA73AA2332C2FD0090D516 /* ArticleExtractorConfig.swift in Sources */, 84BBB12E20142A4700F054F5 /* InspectorWindowController.swift in Sources */, 51EF0F7A22771B890050506E /* ColorHash.swift in Sources */, 84E46C7D1F75EF7B005ECFB3 /* AppDefaults.swift in Sources */, diff --git a/Shared/Article Extractor/ArticleExtractorConfig.swift b/Shared/Article Extractor/ArticleExtractorConfig.swift deleted file mode 100644 index b2ca59cbc..000000000 --- a/Shared/Article Extractor/ArticleExtractorConfig.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// ArticleExtractorSecrets.swift -// NetNewsWire -// -// Created by Maurice Parker on 9/18/19. -// Copyright © 2019 Ranchero Software. All rights reserved. -// - -import Foundation - -enum ArticleExtractorConfig { - static let clientId = "netnewswire" - static let clientSecret = "PM9QZZwckFPLcJdUt4BADDqwHdKCAy8zxaAakjmpGdbjEjfcAdU3CTNdBf8Lw" - static let clientURL = "https://extract.feedbin.com/parser" -} From 5709c1c58a390bdaca767e3f2508ba6592a14f38 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 1 Jan 2020 17:30:42 -0800 Subject: [PATCH 2/5] Remove references to DB5. --- Technotes/CodingGuidelines.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Technotes/CodingGuidelines.md b/Technotes/CodingGuidelines.md index e7c11cdea..c106167ec 100644 --- a/Technotes/CodingGuidelines.md +++ b/Technotes/CodingGuidelines.md @@ -102,7 +102,7 @@ Don’t fight the built-in frameworks and don’t try to hide them. Let’s not NetNewsWire is layered into frameworks. There’s an app level and a bunch of frameworks below that. Each framework has its own reason for being. Dependencies between frameworks should be as minimal as possible, but those dependencies do exist. -Some frameworks are not permitted to add dependencies, and should be treated as at the bottom of the cake: RSCore, RSWeb, RSDatabase, RSParser, RSTree, and DB5. This simplifies things for us, and makes it easier for us and other people to use these frameworks in other apps. +Some frameworks are not permitted to add dependencies, and should be treated as at the bottom of the cake: RSCore, RSWeb, RSDatabase, RSParser, and RSTree. This simplifies things for us, and makes it easier for us and other people to use these frameworks in other apps. ### User Interface @@ -110,8 +110,6 @@ Stick to stock elements, since this tends to eliminate bugs and future churn. Th Storyboards are preferred to xibs — except when the problem is xib-sized. -Use DB5 where parameters (sizes, colors, etc.) are needed. - Auto layout is used everywhere except in table and outline view cells, where performance is critical. Stack views are not allowed in table and outline view cells, but they can be useful elsewhere. However, care must be taken that performance (of window resizing, for instance) is not affected. When it is, don’t use a stack view. From a2005fce889285abe52c289c7a9bbc935246ed32 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 1 Jan 2020 17:36:08 -0800 Subject: [PATCH 3/5] =?UTF-8?q?Add=20note=20to=20coding=20guidelines=20abo?= =?UTF-8?q?ut=20using=20the=20magic=20error,=20oldValue,=20and=20newValue?= =?UTF-8?q?=20variables.=20It=E2=80=99s=20totally=20okay=20to=20use=20thes?= =?UTF-8?q?e.=20Fix=20#1512.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Technotes/CodingGuidelines.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Technotes/CodingGuidelines.md b/Technotes/CodingGuidelines.md index c106167ec..80e623299 100644 --- a/Technotes/CodingGuidelines.md +++ b/Technotes/CodingGuidelines.md @@ -36,6 +36,8 @@ Functions should tend to be small. One-liners are a-okay, especially when the fu We mostly avoid Swift generics, since generics is an advanced feature that can be relatively hard to understand. We *do* use them, though, when appropriate. +It’s totally okay to use the magic `error` variable when catching errors. In accessors, use of the magic `oldValue` and `newValue` is expected when you need the old or new value. + We use assertions and preconditions (assertions are hit only when running a debug build; preconditions will crash a release build). We also allow force-unwrapping of optionals as a shorthand for a precondition failure, though these should be used sparingly. Extensions, including private extensions, are used — though we take care not to extend Foundation and AppKit objects too much, lest we end up with our own Cocoa dialect. From 36230d930eb933c1b5e8914d3ba1dc5f6eb399e7 Mon Sep 17 00:00:00 2001 From: Mihael Cholakov Date: Mon, 6 Jan 2020 14:52:18 +0200 Subject: [PATCH 4/5] Context menu now previews selected article --- .../MasterTimelineViewController.swift | 71 ++++++++++--------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index f6584928c..b5b7baba2 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -18,6 +18,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner private lazy var feedTapGestureRecognizer = UITapGestureRecognizer(target: self, action:#selector(showFeedInspector(_:))) private var refreshProgressView: RefreshProgressView? + private var currentlyPreviewedArticle: Article? @IBOutlet weak var filterButton: UIBarButtonItem! @IBOutlet weak var markAllAsReadButton: UIBarButtonItem! @@ -305,41 +306,36 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner guard let article = dataSource.itemIdentifier(for: indexPath) else { return nil } - return UIContextMenuConfiguration(identifier: indexPath.row as NSCopying, previewProvider: nil, actionProvider: { [weak self] suggestedActions in - - guard let self = self else { return nil } - - var actions = [UIAction]() - actions.append(self.toggleArticleReadStatusAction(article)) - actions.append(self.toggleArticleStarStatusAction(article)) - - if let action = self.markAboveAsReadAction(article) { - actions.append(action) + currentlyPreviewedArticle = article + + return UIContextMenuConfiguration( + identifier: indexPath.row as NSCopying, + previewProvider: { [weak self] in + + guard let self = self else { return nil } + + let articleViewController = UIStoryboard.main.instantiateController(ofType: ArticleViewController.self) + articleViewController.coordinator = self.coordinator + articleViewController.article = article + return articleViewController + + }, actionProvider: { [weak self] suggestedActions in + + guard let self = self else { return nil } + + return UIMenu(title: "", children: [ + self.toggleArticleReadStatusAction(article), + self.toggleArticleStarStatusAction(article), + self.markAboveAsReadAction(article), + self.markBelowAsReadAction(article), + self.discloseFeedAction(article), + self.markAllInFeedAsReadAction(article), + self.openInBrowserAction(article), + self.shareAction(article, indexPath: indexPath) + ].compactMap { $0 }) + } - - if let action = self.markBelowAsReadAction(article) { - actions.append(action) - } - - if let action = self.discloseFeedAction(article) { - actions.append(action) - } - - if let action = self.markAllInFeedAsReadAction(article) { - actions.append(action) - } - - if let action = self.openInBrowserAction(article) { - actions.append(action) - } - - if let action = self.shareAction(article, indexPath: indexPath) { - actions.append(action) - } - - return UIMenu(title: "", children: actions) - - }) + ) } @@ -351,6 +347,13 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner return UITargetedPreview(view: cell, parameters: CroppingPreviewParameters(view: cell)) } + + override func tableView(_ tableView: UITableView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { + if let article = currentlyPreviewedArticle { + coordinator.selectArticle(article) + currentlyPreviewedArticle = nil + } + } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { becomeFirstResponder() From af5fd716fdfdb85e8f5db6ee15fc75eee9b8e859 Mon Sep 17 00:00:00 2001 From: Mihael Cholakov Date: Tue, 7 Jan 2020 09:51:09 +0200 Subject: [PATCH 5/5] Reset unintended CodingGuidelines changes --- Technotes/CodingGuidelines.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Technotes/CodingGuidelines.md b/Technotes/CodingGuidelines.md index 80e623299..e7c11cdea 100644 --- a/Technotes/CodingGuidelines.md +++ b/Technotes/CodingGuidelines.md @@ -36,8 +36,6 @@ Functions should tend to be small. One-liners are a-okay, especially when the fu We mostly avoid Swift generics, since generics is an advanced feature that can be relatively hard to understand. We *do* use them, though, when appropriate. -It’s totally okay to use the magic `error` variable when catching errors. In accessors, use of the magic `oldValue` and `newValue` is expected when you need the old or new value. - We use assertions and preconditions (assertions are hit only when running a debug build; preconditions will crash a release build). We also allow force-unwrapping of optionals as a shorthand for a precondition failure, though these should be used sparingly. Extensions, including private extensions, are used — though we take care not to extend Foundation and AppKit objects too much, lest we end up with our own Cocoa dialect. @@ -104,7 +102,7 @@ Don’t fight the built-in frameworks and don’t try to hide them. Let’s not NetNewsWire is layered into frameworks. There’s an app level and a bunch of frameworks below that. Each framework has its own reason for being. Dependencies between frameworks should be as minimal as possible, but those dependencies do exist. -Some frameworks are not permitted to add dependencies, and should be treated as at the bottom of the cake: RSCore, RSWeb, RSDatabase, RSParser, and RSTree. This simplifies things for us, and makes it easier for us and other people to use these frameworks in other apps. +Some frameworks are not permitted to add dependencies, and should be treated as at the bottom of the cake: RSCore, RSWeb, RSDatabase, RSParser, RSTree, and DB5. This simplifies things for us, and makes it easier for us and other people to use these frameworks in other apps. ### User Interface @@ -112,6 +110,8 @@ Stick to stock elements, since this tends to eliminate bugs and future churn. Th Storyboards are preferred to xibs — except when the problem is xib-sized. +Use DB5 where parameters (sizes, colors, etc.) are needed. + Auto layout is used everywhere except in table and outline view cells, where performance is critical. Stack views are not allowed in table and outline view cells, but they can be useful elsewhere. However, care must be taken that performance (of window resizing, for instance) is not affected. When it is, don’t use a stack view.