diff --git a/Importers/DefaultFeeds.plist b/Importers/DefaultFeeds.plist deleted file mode 100644 index 9dd1695b2..000000000 --- a/Importers/DefaultFeeds.plist +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - note - By Brent Simmons, NetNewsWire developer - editedName - Inessential - homePageURL - http://inessential.com/ - url - http://inessential.com/feed.json - - - editedName - Xcoders - homePageURL - https://xcoders.org/ - url - https://xcoders.org/feed.json - - - homePageURL - https://daringfireball.net/ - editedName - Daring Fireball - url - https://daringfireball.net/feeds/json - - - homePageURL - https://jvns.ca/ - editedName - Julia Evans - url - https://jvns.ca/atom.xml - - - homePageURL - https://kottke.org/ - editedName - Jason Kottke - url - http://feeds.kottke.org/json - - - homePageURL - http://becky.coffee/ - note - iOS developer & corgi enthusiast - editedName - Becky Hansmeyer - url - http://beckyhansmeyer.com/feed/ - - - homePageURL - http://shapeof.com/ - note - By Gus Mueller, Acorn developer - editedName - The Shape of Everything - url - http://shapeof.com/feed.json - - - homePageURL - https://cate.blog - note - Cate Huston - editedName - Accidentally in Code - url - https://cate.blog/feed/ - - - homePageURL - http://www.manton.org/ - editedName - Manton Reece - url - http://www.manton.org/feed/json - - - homePageURL - http://sixcolors.com/ - note - By Jason Snell & friends - editedName - Six Colors - url - https://sixcolors.com/feed.json - - - homePageURL - http://www.loopinsight.com/ - note - Jim Dalrymple and Dave Mark - editedName - Loop Insight - url - http://www.loopinsight.com/feed/ - - - homePageURL - https://nnw.ranchero.com/ - editedName - NetNewsWire Blog - url - https://nnw.ranchero.com/feed.json - - - homePageURL - http://scripting.com/ - editedName - Scripting News - note - Dave Winer - url - http://scripting.com/rss.json - - - homePageURL - http://ericasadun.com/ - editedName - Erica Sadun - note - Lots of Swift goodness. - url - http://ericasadun.com/feed/ - - - homePageURL - http://onefoottsunami.com/ - editedName - One Foot Tsunami - note - Paul Kafasis - url - https://onefoottsunami.com/feed/json/ - - - homePageURL - https://www.omnigroup.com/blog/ - editedName - The Omni Blog - url - https://www.omnigroup.com/blog/rss/ - - - homePageURL - https://om.co/ - editedName - Om Malik - url - https://om.co/feed - - - diff --git a/Importers/DefaultFeedsImporter.swift b/Importers/DefaultFeedsImporter.swift index 905266045..cb31a2c30 100644 --- a/Importers/DefaultFeedsImporter.swift +++ b/Importers/DefaultFeedsImporter.swift @@ -7,30 +7,22 @@ // import Foundation -import Articles import Account import RSCore -typealias DiskFeedDictionary = [String: Any] - struct DefaultFeedsImporter { - static func importIfNeeded(_ firstRun: Bool, account: Account) { - - if shouldImportDefaultFeeds(firstRun) { - appDelegate.logDebugMessage("Importing default feeds.") - FeedsImporter.importFeeds(defaultFeeds(), account: account) + static func importIfNeeded(_ isFirstRun: Bool, account: Account) { + guard shouldImportDefaultFeeds(isFirstRun) else { + return } + + appDelegate.logDebugMessage("Importing default feeds.") + let defaultFeedsURL = Bundle.main.url(forResource: "DefaultFeeds", withExtension: "opml")! + try! OPMLImporter.parseAndImport(fileURL: defaultFeedsURL, account: AccountManager.shared.localAccount) } - - private static func defaultFeeds() -> [DiskFeedDictionary] { - - let f = Bundle.main.path(forResource: "DefaultFeeds", ofType: "plist")! - return NSArray(contentsOfFile: f)! as! [DiskFeedDictionary] - } - + private static func shouldImportDefaultFeeds(_ isFirstRun: Bool) -> Bool { - if !isFirstRun || AccountManager.shared.anyAccountHasAtLeastOneFeed() { return false } @@ -38,22 +30,3 @@ struct DefaultFeedsImporter { } } -struct FeedsImporter { - - static func importFeeds(_ feedDictionaries: [DiskFeedDictionary], account: Account) { - - let feedsToImport = feeds(with: feedDictionaries, account: account) - - BatchUpdate.shared.perform { - feedsToImport.forEach{ account.addFeed($0) } - } - account.structureDidChange() - } - - private static func feeds(with feedDictionaries: [DiskFeedDictionary], account: Account) -> Set { - - let feedArray = feedDictionaries.compactMap { Feed(account: account, dictionary: $0) } - return Set(feedArray) - } -} - diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 81ef65e2c..f03d17506 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -153,7 +153,6 @@ 840F7C9721BDA4B40057E851 /* KeyboardShortcuts.html in Resources */ = {isa = PBXBuildFile; fileRef = 84EB38101FBA8B9F000D2111 /* KeyboardShortcuts.html */; }; 840F7C9821BDA4B40057E851 /* IndeterminateProgressWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849A97931ED9EF7A007D329B /* IndeterminateProgressWindow.xib */; }; 840F7C9921BDA4B40057E851 /* GlobalKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 844B5B641FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist */; }; - 840F7C9A21BDA4B40057E851 /* DefaultFeeds.plist in Resources */ = {isa = PBXBuildFile; fileRef = 849A978E1ED9EE72007D329B /* DefaultFeeds.plist */; }; 840F7C9B21BDA4B40057E851 /* TimelineKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 845479871FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist */; }; 840F7C9C21BDA4B40057E851 /* template.html in Resources */ = {isa = PBXBuildFile; fileRef = 849A979B1ED9EFEB007D329B /* template.html */; }; 840F7C9D21BDA4B40057E851 /* AddFeedSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849A97A71ED9F9AA007D329B /* AddFeedSheet.xib */; }; @@ -252,7 +251,6 @@ 849A97851ED9ECCD007D329B /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97841ED9ECCD007D329B /* PreferencesWindowController.swift */; }; 849A97891ED9ECEF007D329B /* ArticleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97871ED9ECEF007D329B /* ArticleStyle.swift */; }; 849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97881ED9ECEF007D329B /* ArticleStylesManager.swift */; }; - 849A978F1ED9EE72007D329B /* DefaultFeeds.plist in Resources */ = {isa = PBXBuildFile; fileRef = 849A978E1ED9EE72007D329B /* DefaultFeeds.plist */; }; 849A97921ED9EF65007D329B /* IndeterminateProgressWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97911ED9EF65007D329B /* IndeterminateProgressWindowController.swift */; }; 849A97951ED9EF7A007D329B /* IndeterminateProgressWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849A97931ED9EF7A007D329B /* IndeterminateProgressWindow.xib */; }; 849A97981ED9EFAA007D329B /* Node-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97971ED9EFAA007D329B /* Node-Extensions.swift */; }; @@ -849,7 +847,6 @@ 849A97871ED9ECEF007D329B /* ArticleStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArticleStyle.swift; sourceTree = ""; }; 849A97881ED9ECEF007D329B /* ArticleStylesManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArticleStylesManager.swift; sourceTree = ""; }; 849A978C1ED9EE4D007D329B /* FeedListWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedListWindowController.swift; sourceTree = ""; }; - 849A978E1ED9EE72007D329B /* DefaultFeeds.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = DefaultFeeds.plist; path = Importers/DefaultFeeds.plist; sourceTree = SOURCE_ROOT; }; 849A97911ED9EF65007D329B /* IndeterminateProgressWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndeterminateProgressWindowController.swift; sourceTree = ""; }; 849A97941ED9EF7A007D329B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = NetNewsWire/Base.lproj/IndeterminateProgressWindow.xib; sourceTree = SOURCE_ROOT; }; 849A97971ED9EFAA007D329B /* Node-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Node-Extensions.swift"; sourceTree = ""; }; @@ -1595,7 +1592,6 @@ children = ( 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */, 849A97591ED9EB0D007D329B /* DefaultFeedsImporter.swift */, - 849A978E1ED9EE72007D329B /* DefaultFeeds.plist */, 84A3EE52223B667F00557320 /* DefaultFeeds.opml */, ); path = Importers; @@ -2228,7 +2224,6 @@ 840F7C9821BDA4B40057E851 /* IndeterminateProgressWindow.xib in Resources */, 840F7C9921BDA4B40057E851 /* GlobalKeyboardShortcuts.plist in Resources */, 84A3EE60223B667F00557320 /* DefaultFeeds.opml in Resources */, - 840F7C9A21BDA4B40057E851 /* DefaultFeeds.plist in Resources */, 8405DDA322168920008CE1BF /* TimelineTableView.xib in Resources */, 840F7C9B21BDA4B40057E851 /* TimelineKeyboardShortcuts.plist in Resources */, 840F7C9C21BDA4B40057E851 /* template.html in Resources */, @@ -2266,7 +2261,6 @@ 84EB381F1FBA8B9F000D2111 /* KeyboardShortcuts.html in Resources */, 849A97951ED9EF7A007D329B /* IndeterminateProgressWindow.xib in Resources */, 844B5B651FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist in Resources */, - 849A978F1ED9EE72007D329B /* DefaultFeeds.plist in Resources */, 5127B23A222B4849006D641D /* DetailKeyboardShortcuts.plist in Resources */, 845479881FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist in Resources */, 849A979D1ED9EFEB007D329B /* template.html in Resources */,