From e93144426237d764d17863a9349a0b5971cb4c84 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 30 Jun 2023 21:15:51 -0700 Subject: [PATCH] Begin removing Reddit and ExtensionPoint code. --- Mac/AppAssets.swift | 4 - .../Contents.json | 25 --- .../reddit24x24.png | Bin 2472 -> 0 bytes .../reddit48x48.png | Bin 4440 -> 0 bytes NetNewsWire.xcodeproj/project.pbxproj | 32 ---- Shared/ExtensionPoints/ExtensionPoint.swift | 60 ------- .../ExtensionPointIdentifer.swift | 85 ---------- .../ExtensionPointManager.swift | 158 ------------------ .../RedditFeedProvider-Extensions.swift | 36 ---- .../SendToMarsEditCommand.swift | 33 +--- .../SendToMicroBlogCommand.swift | 28 +--- iOS/AppAssets.swift | 4 - 12 files changed, 7 insertions(+), 458 deletions(-) delete mode 100644 Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/Contents.json delete mode 100644 Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/reddit24x24.png delete mode 100644 Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/reddit48x48.png delete mode 100644 Shared/ExtensionPoints/ExtensionPoint.swift delete mode 100644 Shared/ExtensionPoints/ExtensionPointIdentifer.swift delete mode 100644 Shared/ExtensionPoints/ExtensionPointManager.swift delete mode 100644 Shared/ExtensionPoints/RedditFeedProvider-Extensions.swift diff --git a/Mac/AppAssets.swift b/Mac/AppAssets.swift index 6af2d6a6a..79a32cb85 100644 --- a/Mac/AppAssets.swift +++ b/Mac/AppAssets.swift @@ -80,10 +80,6 @@ struct AppAssets { return RSImage(named: "extensionPointMicroblog")! }() - static var extensionPointReddit: RSImage = { - return RSImage(named: "extensionPointReddit")! - }() - static var faviconTemplateImage: RSImage = { return RSImage(named: "faviconTemplateImage")! }() diff --git a/Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/Contents.json b/Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/Contents.json deleted file mode 100644 index a3c8f225b..000000000 --- a/Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/Contents.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "images" : [ - { - "filename" : "reddit24x24.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "filename" : "reddit48x48.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "original" - } -} diff --git a/Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/reddit24x24.png b/Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/reddit24x24.png deleted file mode 100644 index c925e31b430ded98a21f164f45f7ec4bcf533b0f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2472 zcmZ`*2UJsO7XAYS91vj<#~_vv5ETh26gM$M5kvw65dwzdNPxhEgd`+EnvMbkY;-JC zH6Q~BDpG?1k)_Cibq1x(0*kxD3ZaZNE25%+%uBGauD)~byZ68Mez*Pio%6)*Zu_(~ z*J%O(v?)#w9uP+;XoWiTmPgsnLQE~xj%o*h^sLrA0}h>$K~5f20Afu6IPoI@Zz0u* zaR4H*089n|K)e9JT7FL50TN`WWYQ@iR4OooqFdR^Ubc)oz zFuYRMhh#wt3#dU{;hzkV;&FmVaaM9iP7I41ilj0bBBWgqPryamSlC$L0UnFT5^-3f zB^HUZB3cuOSONg5c`%@=L__#Im5-4Td8(ge$PNLh4+qEhaOh-<`d%dB6ET>ms3?mlOADSL6oVrW z2pB9LgU6#G5413bD`G^WxkBTmARpp5Foi(^7GK2TagmC+j6hzb$QFfCB>MQguQQzg zF%ehzzALCdOf-X!!C7E2Uji|sS)a=LAC$uKRhWns@)elEvIJ8OW2r_GG*P0x0J>kE zfX3r-$X~f}66SNqPkkz5P_Dkev?=Y{hH zOrf$mYZB)Fbf5dvJ(xlsCsMH=WJNPdz;fm10G}@bmMh-_NEpSsEnB~(-BxO$emEW<`uivJ{PkDl_K>uR9Zr^DLhgIey z@jnI7A0khY4()ACtpWb`Ow&=ui6f5}uR8b0ZB7dAUi1=3#)7!#kA%=m7aW=2_3V79 zCeJ=rSe$aROnqZ34js=v6N(i`twJ;tt_fm}x1-#Su-VBIRpPUxzE`&!k5~QOAMC$< zy^$^v7Kz^Kux1al7^-fB(c;{+kXm}`8_!ey#fRRR)JTTsk)->0=WAEuvy)qX0l7j(rWHN!Rqy1)UgYra#Mf* zIlXakl~<-m>$hY1ft$-g-x~LZ<{HA`lba)(exIj?q^ z93RXNPBbOO*=}s!#Ce`-Wqj0=tc|&thFhKE zd7#pI8x^kW{m!6y9$BrnVYVu`aqh1%h$MD-SbXrte;Y^YP;A|^+MecAWqU?W`$Z(o zop?NYVP?QHtqU%SbJb4633Q87ze{spBh`32l|gIzo7u%}4R61ZYZPXdi2JI#+MdF% zUHA2E{o}4s$2D2QM99g^3~;jbFt;T<2~U}h1(B03BK>p5yWkq|0>70`Eoh@5^n{(N8pIoEGwNDRo&9<{`ys`OPimhk&&sM!ig`_*K&KrW-n!)!`k!!Oc<%V%m7xax^;RXTI*}3` zstW5b4b9xjg}PEN--xE(TK~GjRq(q*mciVnnGJ9Lvwv4rFHI%a-7&R^du%4D=;(=L z|5p)mvaIs8%b<%m@hJUZ;lSfoK!f=+tm9p8zeL1tpAMVxo)$Nm$k?J{$wXmX=gp}{ zp0_;MgtnAMYDV5Y>B(D1O}$4R{@S{`6eh{2rEPnD=eNMLFl%{#_cm9{%qjU!&L&Qy zgSj7KA$MO%lHQJrQJ$`sV?=)?YR4t*8@Nu&0&TRP^zDW5S*a_&g654rzzt|wH*ljt zyjMrIw*L?NkwXQ(D3$Hw+9RZv70Es8FW~Qqf36sA8S1_JeIV7ox2U~ru%}6cxZ7y- ls_VaN=M54wo>o`4Et=Dwd)LgFnJE4#D0|%;%J&2${0aAT%Ju*N diff --git a/Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/reddit48x48.png b/Mac/Resources/Assets.xcassets/extensionPointReddit.imageset/reddit48x48.png deleted file mode 100644 index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1nsN83zBI(L(h@Er+3Z0-aLpW8sBR* z6ka=?jtnoj}O9fmIV9L0{JO4Uj+A z(42&j0S8euYT8ICBxOvLp7p!bHhbBG6Q$~2q-++gZg=80Wo~`_^elBvAG6?{4TmUi zVPKc|Q<4#luA`D%a!)R=epp@QlB-T4bl_P7VNx|x;HlZJ9`HE*IRK< u{ZH0E`bOMVg%8b NSMutableAttributedString { - let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.alignment = .center - - #if os(macOS) - let attrs = [ - NSAttributedString.Key.paragraphStyle: paragraphStyle, - NSAttributedString.Key.font: NSFont.systemFont(ofSize: NSFont.systemFontSize), - NSAttributedString.Key.foregroundColor: NSColor.textColor - ] - #else - let attrs = [ - NSAttributedString.Key.paragraphStyle: paragraphStyle, - NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body), - NSAttributedString.Key.foregroundColor: UIColor.label - ] - #endif - - return NSMutableAttributedString(string: text, attributes: attrs) - } - -} diff --git a/Shared/ExtensionPoints/ExtensionPointIdentifer.swift b/Shared/ExtensionPoints/ExtensionPointIdentifer.swift deleted file mode 100644 index db2a2d6b0..000000000 --- a/Shared/ExtensionPoints/ExtensionPointIdentifer.swift +++ /dev/null @@ -1,85 +0,0 @@ -// -// ExtensionPointIdentifer.swift -// NetNewsWire -// -// Created by Maurice Parker on 4/8/20. -// Copyright © 2020 Ranchero Software. All rights reserved. -// - -import Foundation -import Account -import RSCore - -enum ExtensionPointIdentifer: Hashable { - #if os(macOS) - case marsEdit - case microblog - #endif - case reddit(String) - - var extensionPointType: ExtensionPoint.Type { - switch self { - #if os(macOS) - case .marsEdit: - return SendToMarsEditCommand.self - case .microblog: - return SendToMicroBlogCommand.self - #endif - case .reddit: - return RedditFeedProvider.self - } - } - - public var userInfo: [AnyHashable: AnyHashable] { - switch self { - #if os(macOS) - case .marsEdit: - return [ - "type": "marsEdit" - ] - case .microblog: - return [ - "type": "microblog" - ] - #endif - case .reddit(let username): - return [ - "type": "reddit", - "username": username - ] - } - } - - public init?(userInfo: [AnyHashable: AnyHashable]) { - guard let type = userInfo["type"] as? String else { return nil } - - switch type { - #if os(macOS) - case "marsEdit": - self = ExtensionPointIdentifer.marsEdit - case "microblog": - self = ExtensionPointIdentifer.microblog - #endif - case "reddit": - guard let username = userInfo["username"] as? String else { return nil } - self = ExtensionPointIdentifer.reddit(username) - default: - return nil - } - } - - public func hash(into hasher: inout Hasher) { - switch self { - #if os(macOS) - case .marsEdit: - hasher.combine("marsEdit") - case .microblog: - hasher.combine("microblog") - #endif - case .reddit(let username): - hasher.combine("reddit") - hasher.combine(username) - } - } - -} diff --git a/Shared/ExtensionPoints/ExtensionPointManager.swift b/Shared/ExtensionPoints/ExtensionPointManager.swift deleted file mode 100644 index 1cac7f967..000000000 --- a/Shared/ExtensionPoints/ExtensionPointManager.swift +++ /dev/null @@ -1,158 +0,0 @@ -// -// ExtensionPointManager.swift -// NetNewsWire -// -// Created by Maurice Parker on 4/7/20. -// Copyright © 2020 Ranchero Software. All rights reserved. -// - -import Foundation -import Account -import RSCore -import OAuthSwift - -public extension Notification.Name { - static let ActiveExtensionPointsDidChange = Notification.Name(rawValue: "ActiveExtensionPointsDidChange") -} - -public enum ExtensionPointManagerError: LocalizedError { - case unableToCreate - - public var localizedDescription: String { - switch self { - case .unableToCreate: - return NSLocalizedString("error.message.unable-to-create-extension", comment: "Unable to create extension.") - } - } -} - - -final class ExtensionPointManager: FeedProviderManagerDelegate { - - static let shared = ExtensionPointManager() - - var activeExtensionPoints = [ExtensionPointIdentifer: ExtensionPoint]() - let possibleExtensionPointTypes: [ExtensionPoint.Type] - var availableExtensionPointTypes: [ExtensionPoint.Type] { - - let activeExtensionPointTypes = activeExtensionPoints.keys.compactMap({ ObjectIdentifier($0.extensionPointType) }) - var available = [ExtensionPoint.Type]() - for possibleExtensionPointType in possibleExtensionPointTypes { - if !(AppDefaults.shared.isDeveloperBuild && possibleExtensionPointType.isDeveloperBuildRestricted) { - if possibleExtensionPointType.isSinglton { - if !activeExtensionPointTypes.contains(ObjectIdentifier(possibleExtensionPointType)) { - available.append(possibleExtensionPointType) - } - } else { - available.append(possibleExtensionPointType) - } - } - } - - return available - - } - - var activeSendToCommands: [SendToCommand] { - var commands = activeExtensionPoints.values.compactMap({ return $0 as? SendToCommand }) - - // These two SendToCommands don't need logins and are always active - #if os(macOS) - commands.append(SendToMarsEditCommand()) - commands.append(SendToMicroBlogCommand()) - #endif - - return commands - } - - var activeFeedProviders: [FeedProvider] { - return activeExtensionPoints.values.compactMap({ return $0 as? FeedProvider }) - } - - var isRedditEnabled: Bool { - return activeExtensionPoints.values.contains(where: { $0 is RedditFeedProvider }) - } - - init() { - possibleExtensionPointTypes = [RedditFeedProvider.self] - loadExtensionPoints() - } - - func activateExtensionPoint(_ extensionPointType: ExtensionPoint.Type, tokenSuccess: OAuthSwift.TokenSuccess? = nil, completion: @escaping (Result) -> Void) { - self.extensionPoint(for: extensionPointType, tokenSuccess: tokenSuccess) { result in - switch result { - case .success(let extensionPoint): - self.activeExtensionPoints[extensionPoint.extensionPointID] = extensionPoint - self.saveExtensionPointIDs() - completion(.success(())) - case .failure(let error): - completion(.failure(error)) - } - } - } - - func deactivateExtensionPoint(_ extensionPointID: ExtensionPointIdentifer) { - activeExtensionPoints[extensionPointID] = nil - saveExtensionPointIDs() - } - -} - -private extension ExtensionPointManager { - - func loadExtensionPoints() { - if let extensionPointUserInfos = AppDefaults.shared.activeExtensionPointIDs { - for extensionPointUserInfo in extensionPointUserInfos { - if let extensionPointID = ExtensionPointIdentifer(userInfo: extensionPointUserInfo) { - activeExtensionPoints[extensionPointID] = extensionPoint(for: extensionPointID) - } - } - } - } - - func saveExtensionPointIDs() { - AppDefaults.shared.activeExtensionPointIDs = activeExtensionPoints.keys.map({ $0.userInfo }) - NotificationCenter.default.post(name: .ActiveExtensionPointsDidChange, object: nil, userInfo: nil) - } - - func extensionPoint(for extensionPointType: ExtensionPoint.Type, tokenSuccess: OAuthSwift.TokenSuccess?, completion: @escaping (Result) -> Void) { - switch extensionPointType { - case is RedditFeedProvider.Type: - if let tokenSuccess = tokenSuccess { - RedditFeedProvider.create(tokenSuccess: tokenSuccess) { result in - switch result { - case .success(let reddit): - completion(.success(reddit)) - case .failure(let error): - completion(.failure(error)) - } - } - } else { - completion(.failure(ExtensionPointManagerError.unableToCreate)) - } - default: - break - } - } - - func extensionPoint(for extensionPointID: ExtensionPointIdentifer) -> ExtensionPoint? { - switch extensionPointID { - case .reddit(let username): - return RedditFeedProvider(username: username) - #if os(macOS) - default: - return nil - #endif - } - } - - func feedProviderMatching(_ offered: URLComponents, ability: FeedProviderAbility) -> FeedProvider? { - for extensionPoint in activeExtensionPoints.values { - if let feedProvider = extensionPoint as? FeedProvider, feedProvider.ability(offered) == ability { - return feedProvider - } - } - return nil - } - -} diff --git a/Shared/ExtensionPoints/RedditFeedProvider-Extensions.swift b/Shared/ExtensionPoints/RedditFeedProvider-Extensions.swift deleted file mode 100644 index de21775fe..000000000 --- a/Shared/ExtensionPoints/RedditFeedProvider-Extensions.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// RedditFeedProvider-Extensions.swift -// NetNewsWire -// -// Created by Maurice Parker on 5/2/20. -// Copyright © 2020 Ranchero Software. All rights reserved. -// - -import Foundation -import Account - -extension RedditFeedProvider: ExtensionPoint { - - static var isSinglton = false - static var isDeveloperBuildRestricted = true - static var title = "Reddit" // not localized - product name - static var image = AppAssets.extensionPointReddit - static var description: NSAttributedString = { - return RedditFeedProvider.makeAttrString("This extension enables you to subscribe to Reddit URLs as if they were RSS feeds. It only works with \(Account.defaultLocalAccountName) or iCloud accounts.") - }() - - var extensionPointID: ExtensionPointIdentifer { - guard let username = username else { - fatalError() - } - return ExtensionPointIdentifer.reddit(username) - } - - var title: String { - guard let username = username else { - fatalError() - } - return "u/\(username)" - } - -} diff --git a/Shared/ExtensionPoints/SendToMarsEditCommand.swift b/Shared/ExtensionPoints/SendToMarsEditCommand.swift index 2f24bf82f..b86a661d1 100644 --- a/Shared/ExtensionPoints/SendToMarsEditCommand.swift +++ b/Shared/ExtensionPoints/SendToMarsEditCommand.swift @@ -10,40 +10,15 @@ import AppKit import RSCore import Articles -final class SendToMarsEditCommand: ExtensionPoint, SendToCommand { +final class SendToMarsEditCommand: SendToCommand { - static var isSinglton = true - static var isDeveloperBuildRestricted = false - static var title = "MarsEdit" // not localized - static var image = AppAssets.extensionPointMarsEdit - static var description: NSAttributedString = { - let attrString = SendToMarsEditCommand.makeAttrString(NSLocalizedString("label.text.marsedit.explainer", comment: "This extension enables share menu functionality to send selected article text to MarsEdit. You need the MarsEdit application for this to work.")) - let range = NSRange(location: 81, length: 8) - attrString.beginEditing() - attrString.addAttribute(NSAttributedString.Key.link, value: "https://red-sweater.com/marsedit/", range: range) - attrString.addAttribute(NSAttributedString.Key.foregroundColor, value: NSColor.systemBlue, range: range) - attrString.endEditing() - return attrString - }() - - let extensionPointID = ExtensionPointIdentifer.marsEdit - - var title: String { - return extensionPointID.extensionPointType.title - } - - var image: NSImage? { - return appToUse()?.icon ?? nil - } + let title = "MarsEdit" + let image: RSImage? = AppAssets.marsEditIcon private let marsEditApps = [UserApp(bundleID: "com.red-sweater.marsedit4"), UserApp(bundleID: "com.red-sweater.marsedit")] func canSendObject(_ object: Any?, selectedText: String?) -> Bool { - - if let _ = appToUse() { - return true - } - return false + appToUse() != nil } func sendObject(_ object: Any?, selectedText: String?) { diff --git a/Shared/ExtensionPoints/SendToMicroBlogCommand.swift b/Shared/ExtensionPoints/SendToMicroBlogCommand.swift index c87314bda..bd5d000d2 100644 --- a/Shared/ExtensionPoints/SendToMicroBlogCommand.swift +++ b/Shared/ExtensionPoints/SendToMicroBlogCommand.swift @@ -12,32 +12,10 @@ import RSCore // Not undoable. -final class SendToMicroBlogCommand: ExtensionPoint, SendToCommand { +final class SendToMicroBlogCommand: SendToCommand { - static var isSinglton = true - static var isDeveloperBuildRestricted = false - static var title: String = "Micro.blog" // not localized - static var image = AppAssets.extensionPointMicroblog - static var description: NSAttributedString = { - let attrString = SendToMicroBlogCommand.makeAttrString(NSLocalizedString("label.text.micro-blog-expaliner", comment: "This extension enables share menu functionality to send selected article text to Micro.blog. You need the Micro.blog application for this to work.")) - let range = NSRange(location: 81, length: 10) - attrString.beginEditing() - attrString.addAttribute(NSAttributedString.Key.link, value: "https://micro.blog", range: range) - attrString.addAttribute(NSAttributedString.Key.foregroundColor, value: NSColor.systemBlue, range: range) - attrString.endEditing() - return attrString - - }() - - let extensionPointID = ExtensionPointIdentifer.microblog - - var title: String { - return extensionPointID.extensionPointType.title - } - - var image: NSImage? { - return microBlogApp.icon - } + let title = "Micro.blog" + let image: RSImage? = AppAssets.microblogIcon private let microBlogApp = UserApp(bundleID: "blog.micro.mac") diff --git a/iOS/AppAssets.swift b/iOS/AppAssets.swift index f4435713a..1a120467d 100644 --- a/iOS/AppAssets.swift +++ b/iOS/AppAssets.swift @@ -125,10 +125,6 @@ struct AppAssets { UIImage(systemName: "square.and.pencil")! }() - static var extensionPointReddit: RSImage = { - return RSImage(named: "extensionPointReddit")! - }() - static var faviconTemplateImage: RSImage = { return RSImage(named: "faviconTemplateImage")! }()