diff --git a/Mac/Resources/NetNewsWire.sdef b/Mac/Resources/NetNewsWire.sdef index d732ad00e..bd5706e59 100644 --- a/Mac/Resources/NetNewsWire.sdef +++ b/Mac/Resources/NetNewsWire.sdef @@ -73,9 +73,9 @@ - - - + + + @@ -105,30 +105,30 @@ - - - - + + + + - - - + + + - + - + - - - + + + @@ -189,9 +189,9 @@ - - - + + + @@ -245,7 +245,7 @@ - + diff --git a/Mac/Scriptability/Account+Scriptability.swift b/Mac/Scriptability/Account+Scriptability.swift index bb75b20a3..8aedef6f7 100644 --- a/Mac/Scriptability/Account+Scriptability.swift +++ b/Mac/Scriptability/Account+Scriptability.swift @@ -94,31 +94,31 @@ final class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjec // MARK: --- Scriptable elements --- - @objc(webFeeds) - var webFeeds:NSArray { + @objc(feeds) + var feeds:NSArray { return account.topLevelFeeds.map { ScriptableFeed($0, container:self) } as NSArray } - @objc(countOfWebFeeds) - func countOfWebFeeds() -> Int { + @objc(countOfFeeds) + func countOfFeeds() -> Int { return account.topLevelFeeds.count } - @objc(objectInWebFeedsAtIndex:) - func objectInWebFeedsAtIndex(_ index: Int) -> ScriptableFeed? { + @objc(objectInFeedsAtIndex:) + func objectInFeedsAtIndex(_ index: Int) -> ScriptableFeed? { let feeds = Array(account.topLevelFeeds) guard index >= 0 && index < feeds.count else { return nil } return ScriptableFeed(feeds[index], container: self) } - @objc(valueInWebFeedsWithUniqueID:) - func valueInWebFeeds(withUniqueID id:String) -> ScriptableFeed? { + @objc(valueInFeedsWithUniqueID:) + func valueInFeeds(withUniqueID id:String) -> ScriptableFeed? { guard let feed = account.existingFeed(withFeedID: id) else { return nil } return ScriptableFeed(feed, container:self) } - @objc(valueInWebFeedsWithName:) - func valueInWebFeeds(withName name:String) -> ScriptableFeed? { + @objc(valueInFeedsWithName:) + func valueInFeeds(withName name:String) -> ScriptableFeed? { let feeds = Array(account.flattenedFeeds()) guard let feed = feeds.first(where:{$0.name == name}) else { return nil } return ScriptableFeed(feed, container:self) @@ -155,35 +155,35 @@ final class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjec // MARK: --- Scriptable properties --- - @objc(allWebFeeds) - var allWebFeeds: NSArray { + @objc(allFeeds) + var allFeeds: NSArray { let allFeeds = account.flattenedFeeds() - let scriptableWebFeeds = allFeeds.map { webFeed in - return ScriptableFeed(webFeed, container: self) + let scriptableFeeds = allFeeds.map { feed in + return ScriptableFeed(feed, container: self) } - return scriptableWebFeeds as NSArray + return scriptableFeeds as NSArray } - @objc(countOfAllWebFeeds) - func countOfAllWebFeeds() -> Int { + @objc(countOfAllFeeds) + func countOfAllFeeds() -> Int { return account.flattenedFeeds().count } - @objc(objectInAllWebFeedsAtIndex:) - func objectInAllWebFeedsAtIndex(_ index: Int) -> ScriptableFeed? { + @objc(objectInAllFeedsAtIndex:) + func objectInAllFeedsAtIndex(_ index: Int) -> ScriptableFeed? { let allFeeds = Array(account.flattenedFeeds()) guard index >= 0 && index < allFeeds.count else { return nil } return ScriptableFeed(allFeeds[index], container: self) } - @objc(valueInAllWebFeedsWithUniqueID:) - func valueInAllWebFeeds(withUniqueID id:String) -> ScriptableFeed? { + @objc(valueInAllFeedsWithUniqueID:) + func valueInAllFeeds(withUniqueID id:String) -> ScriptableFeed? { guard let feed = account.existingFeed(withFeedID: id) else { return nil } return ScriptableFeed(feed, container:self) } - @objc(valueInAllWebFeedsWithName:) - func valueInAllWebFeeds(withName name:String) -> ScriptableFeed? { + @objc(valueInAllFeedsWithName:) + func valueInAllFeeds(withName name:String) -> ScriptableFeed? { let feeds = Array(account.flattenedFeeds()) guard let feed = feeds.first(where:{$0.name == name}) else { return nil } return ScriptableFeed(feed, container:self) diff --git a/Mac/Scriptability/AppDelegate+Scriptability.swift b/Mac/Scriptability/AppDelegate+Scriptability.swift index e528f4ef1..39a13c703 100644 --- a/Mac/Scriptability/AppDelegate+Scriptability.swift +++ b/Mac/Scriptability/AppDelegate+Scriptability.swift @@ -94,7 +94,7 @@ extension AppDelegate : AppDelegateAppleEvents { final class NetNewsWireCreateElementCommand : NSCreateCommand { override func performDefaultImplementation() -> Any? { let classDescription = self.createClassDescription - if (classDescription.className == "webFeed") { + if (classDescription.className == "feed") { return ScriptableFeed.handleCreateElement(command:self) } else if (classDescription.className == "folder") { return ScriptableFolder.handleCreateElement(command:self) diff --git a/Mac/Scriptability/Article+Scriptability.swift b/Mac/Scriptability/Article+Scriptability.swift index 768ab37d7..e3a34e46f 100644 --- a/Mac/Scriptability/Article+Scriptability.swift +++ b/Mac/Scriptability/Article+Scriptability.swift @@ -144,6 +144,6 @@ final class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjec @objc(feed) var feed: ScriptableFeed? { guard let parentFeed = self.article.feed else { return nil } - return ScriptableFeed.scriptableWebFeed(for: parentFeed) + return ScriptableFeed.scriptableFeed(for: parentFeed) } } diff --git a/Mac/Scriptability/Folder+Scriptability.swift b/Mac/Scriptability/Folder+Scriptability.swift index 0e04abf8c..bab26ff62 100644 --- a/Mac/Scriptability/Folder+Scriptability.swift +++ b/Mac/Scriptability/Folder+Scriptability.swift @@ -95,8 +95,8 @@ final class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObject // MARK: --- Scriptable elements --- - @objc(webFeeds) - var webFeeds:NSArray { + @objc(feeds) + var feeds:NSArray { let feeds = Array(folder.topLevelFeeds) return feeds.map { ScriptableFeed($0, container:self) } as NSArray } @@ -107,7 +107,7 @@ final class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObject let allArticles = feeds.flatMap { feed in (try? feed.fetchArticles()) ?? Set
() } - // Sort articles by logical date published like WebFeed does + // Sort articles by logical date published like Feed does let sortedArticles = allArticles.sorted(by: { return $0.logicalDatePublished > $1.logicalDatePublished }) diff --git a/Mac/Scriptability/NSApplication+Scriptability.swift b/Mac/Scriptability/NSApplication+Scriptability.swift index fc1906d82..a3c44d565 100644 --- a/Mac/Scriptability/NSApplication+Scriptability.swift +++ b/Mac/Scriptability/NSApplication+Scriptability.swift @@ -31,7 +31,7 @@ extension NSApplication : ScriptingObjectContainer { var scriptableArticle: ScriptableArticle? if let currentArticle = appDelegate.scriptingCurrentArticle { if let feed = currentArticle.feed, - let scriptableFeed = ScriptableFeed.scriptableWebFeed(for: feed) { + let scriptableFeed = ScriptableFeed.scriptableFeed(for: feed) { scriptableArticle = ScriptableArticle(currentArticle, container: scriptableFeed) } } @@ -43,7 +43,7 @@ extension NSApplication : ScriptingObjectContainer { let articles = appDelegate.scriptingSelectedArticles let scriptableArticles:[ScriptableArticle] = articles.compactMap { article in if let feed = article.feed, - let scriptableFeed = ScriptableFeed.scriptableWebFeed(for: feed) { + let scriptableFeed = ScriptableFeed.scriptableFeed(for: feed) { return ScriptableArticle(article, container:scriptableFeed) } else { return nil @@ -64,7 +64,7 @@ extension NSApplication : ScriptingObjectContainer { let article = articles[index] if let feed = article.feed, - let scriptableFeed = ScriptableFeed.scriptableWebFeed(for: feed) { + let scriptableFeed = ScriptableFeed.scriptableFeed(for: feed) { return ScriptableArticle(article, container: scriptableFeed) } else { return nil @@ -104,7 +104,7 @@ extension NSApplication : ScriptingObjectContainer { for 'articles of feed "The Shape of Everything" of account "On My Mac"' */ - func allWebFeeds() -> [Feed] { + func allFeeds() -> [Feed] { let accounts = AccountManager.shared.activeAccounts let emptyFeeds:[Feed] = [] return accounts.reduce(emptyFeeds) { (result, nthAccount) -> [Feed] in @@ -113,29 +113,28 @@ extension NSApplication : ScriptingObjectContainer { } } - @objc(webFeeds) - func webFeeds() -> NSArray { - let webFeeds = self.allWebFeeds() - return webFeeds.map { ScriptableFeed($0, container:self) } as NSArray + @objc(feeds) + func feeds() -> NSArray { + allFeeds().map { ScriptableFeed($0, container:self) } as NSArray } - @objc(countOfWebFeeds) - func countOfWebFeeds() -> Int { - return self.allWebFeeds().count + @objc(countOfFeeds) + func countOfFeeds() -> Int { + allFeeds().count } - @objc(objectInWebFeedsAtIndex:) - func objectInWebFeedsAtIndex(_ index: Int) -> ScriptableFeed? { - let webFeeds = self.allWebFeeds() - guard index >= 0 && index < webFeeds.count else { return nil } - return ScriptableFeed(webFeeds[index], container: self) + @objc(objectInFeedsAtIndex:) + func objectInFeedsAtIndex(_ index: Int) -> ScriptableFeed? { + let feeds = allFeeds() + guard index >= 0 && index < feeds.count else { return nil } + return ScriptableFeed(feeds[index], container: self) } - @objc(valueInWebFeedsWithUniqueID:) - func valueInWebFeeds(withUniqueID id:String) -> ScriptableFeed? { - let webFeeds = self.allWebFeeds() - guard let webFeed = webFeeds.first(where:{$0.feedID == id}) else { return nil } - return ScriptableFeed(webFeed, container:self) + @objc(valueInFeedsWithUniqueID:) + func valueInFeeds(withUniqueID id:String) -> ScriptableFeed? { + let feeds = allFeeds() + guard let feed = feeds.first(where:{$0.feedID == id}) else { return nil } + return ScriptableFeed(feed, container:self) } } diff --git a/Mac/Scriptability/WebFeed+Scriptability.swift b/Mac/Scriptability/WebFeed+Scriptability.swift index ae6b02676..659f04446 100644 --- a/Mac/Scriptability/WebFeed+Scriptability.swift +++ b/Mac/Scriptability/WebFeed+Scriptability.swift @@ -36,7 +36,7 @@ final class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectCo // MARK: --- ScriptingObject protocol --- var scriptingKey: String { - return "webFeeds" + return "feeds" } // MARK: --- UniqueIdScriptingObject protocol --- @@ -81,7 +81,7 @@ final class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectCo } } - class func scriptableWebFeed(for feed: Feed) -> ScriptableFeed? { + class func scriptableFeed(for feed: Feed) -> ScriptableFeed? { guard let account = feed.account else { return nil } // Find the proper container hierarchy diff --git a/iOS/MainFeed/MainFeedCollectionViewController.swift b/iOS/MainFeed/MainFeedCollectionViewController.swift index 87400476b..e29f93363 100644 --- a/iOS/MainFeed/MainFeedCollectionViewController.swift +++ b/iOS/MainFeed/MainFeedCollectionViewController.swift @@ -722,19 +722,19 @@ class MainFeedCollectionViewController: UICollectionViewController, UndoableComm let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel") let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel) - let addWebFeedActionTitle = NSLocalizedString("Add Web Feed", comment: "Add Web Feed") - let addWebFeedAction = UIAlertAction(title: addWebFeedActionTitle, style: .default) { _ in + let addFeedActionTitle = NSLocalizedString("Add Web Feed", comment: "Add Web Feed") + let addFeedAction = UIAlertAction(title: addFeedActionTitle, style: .default) { _ in self.coordinator.showAddFeed() } - let addWebFolderdActionTitle = NSLocalizedString("Add Folder", comment: "Add Folder") - let addWebFolderAction = UIAlertAction(title: addWebFolderdActionTitle, style: .default) { _ in + let addFolderActionTitle = NSLocalizedString("Add Folder", comment: "Add Folder") + let addFolderAction = UIAlertAction(title: addFolderActionTitle, style: .default) { _ in self.coordinator.showAddFolder() } - alertController.addAction(addWebFeedAction) + alertController.addAction(addFeedAction) - alertController.addAction(addWebFolderAction) + alertController.addAction(addFolderAction) alertController.addAction(cancelAction) alertController.popoverPresentationController?.barButtonItem = sender @@ -945,8 +945,8 @@ extension MainFeedCollectionViewController { } func copyFeedPageAction(indexPath: IndexPath) -> UIAction? { - guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, - let url = URL(string: webFeed.url) else { + guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, + let url = URL(string: feed.url) else { return nil } @@ -958,8 +958,8 @@ extension MainFeedCollectionViewController { } func copyFeedPageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, - let url = URL(string: webFeed.url) else { + guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, + let url = URL(string: feed.url) else { return nil } @@ -972,8 +972,8 @@ extension MainFeedCollectionViewController { } func copyHomePageAction(indexPath: IndexPath) -> UIAction? { - guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, - let homePageURL = webFeed.homePageURL, + guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, + let homePageURL = feed.homePageURL, let url = URL(string: homePageURL) else { return nil } @@ -986,8 +986,8 @@ extension MainFeedCollectionViewController { } func copyHomePageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, - let homePageURL = webFeed.homePageURL, + guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, + let homePageURL = feed.homePageURL, let url = URL(string: homePageURL) else { return nil } @@ -1001,14 +1001,14 @@ extension MainFeedCollectionViewController { } func markAllAsReadAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, - webFeed.unreadCount > 0, - let articles = try? webFeed.fetchArticles(), let contentView = self.collectionView.cellForItem(at: indexPath)?.contentView else { + guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed, + feed.unreadCount > 0, + let articles = try? feed.fetchArticles(), let contentView = self.collectionView.cellForItem(at: indexPath)?.contentView else { return nil } let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command") - let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, webFeed.nameForDisplay) as String + let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String let cancel = { completion(true) } @@ -1041,13 +1041,13 @@ extension MainFeedCollectionViewController { } func getInfoAction(indexPath: IndexPath) -> UIAction? { - guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else { + guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else { return nil } let title = NSLocalizedString("Get Info", comment: "Get Info") let action = UIAction(title: title, image: AppAssets.infoImage) { [weak self] action in - self?.coordinator.showFeedInspector(for: webFeed) + self?.coordinator.showFeedInspector(for: feed) } return action } @@ -1069,13 +1069,13 @@ extension MainFeedCollectionViewController { } func getInfoAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else { + guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else { return nil } let title = NSLocalizedString("Get Info", comment: "Get Info") let action = UIAlertAction(title: title, style: .default) { [weak self] action in - self?.coordinator.showFeedInspector(for: webFeed) + self?.coordinator.showFeedInspector(for: feed) completion(true) } return action