diff --git a/Evergreen.xcodeproj/project.pbxproj b/Evergreen.xcodeproj/project.pbxproj index 4d165b2cf..907dc45b4 100644 --- a/Evergreen.xcodeproj/project.pbxproj +++ b/Evergreen.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 842E45E51ED8C6B7000A8B52 /* MainWindowSplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842E45E41ED8C6B7000A8B52 /* MainWindowSplitView.swift */; }; 842E45E71ED8C747000A8B52 /* DB5.plist in Resources */ = {isa = PBXBuildFile; fileRef = 842E45E61ED8C747000A8B52 /* DB5.plist */; }; 84411E711FE5FBFA004B527F /* SmallIconProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84411E701FE5FBFA004B527F /* SmallIconProvider.swift */; }; + 8444C8F21FED81840051386C /* OPMLExporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8444C8F11FED81840051386C /* OPMLExporter.swift */; }; 844B5B591FE9FE4F00C7C76A /* SidebarKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B5B581FE9FE4F00C7C76A /* SidebarKeyboardDelegate.swift */; }; 844B5B5B1FEA00FB00C7C76A /* TimelineKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B5B5A1FEA00FB00C7C76A /* TimelineKeyboardDelegate.swift */; }; 844B5B651FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 844B5B641FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist */; }; @@ -425,6 +426,7 @@ 842E45E41ED8C6B7000A8B52 /* MainWindowSplitView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindowSplitView.swift; sourceTree = ""; }; 842E45E61ED8C747000A8B52 /* DB5.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = DB5.plist; path = Evergreen/Resources/DB5.plist; sourceTree = ""; }; 84411E701FE5FBFA004B527F /* SmallIconProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmallIconProvider.swift; sourceTree = ""; }; + 8444C8F11FED81840051386C /* OPMLExporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPMLExporter.swift; sourceTree = ""; }; 844B5B581FE9FE4F00C7C76A /* SidebarKeyboardDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarKeyboardDelegate.swift; sourceTree = ""; }; 844B5B5A1FEA00FB00C7C76A /* TimelineKeyboardDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineKeyboardDelegate.swift; sourceTree = ""; }; 844B5B641FEA11F200C7C76A /* GlobalKeyboardShortcuts.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = GlobalKeyboardShortcuts.plist; sourceTree = ""; }; @@ -596,6 +598,14 @@ path = Evergreen/MainWindow; sourceTree = ""; }; + 8444C9011FED81880051386C /* Exporters */ = { + isa = PBXGroup; + children = ( + 8444C8F11FED81840051386C /* OPMLExporter.swift */, + ); + path = Exporters; + sourceTree = ""; + }; 844B5B6A1FEA224000C7C76A /* Keyboard */ = { isa = PBXGroup; children = ( @@ -857,6 +867,7 @@ 849A978B1ED9EE4D007D329B /* Feed List */, 849A97901ED9EF65007D329B /* Progress Window */, 84DAEE201F86CAE00058304B /* Importers */, + 8444C9011FED81880051386C /* Exporters */, 84F2D5341FC22FCB00998D64 /* SmartFeeds */, 849A97561ED9EB0D007D329B /* Data */, 8426119C1FCB6ED40086A189 /* HTMLMetadata */, @@ -1401,6 +1412,7 @@ 842E45DD1ED8C54B000A8B52 /* Browser.swift in Sources */, 842E45E31ED8C681000A8B52 /* KeyboardDelegateProtocol.swift in Sources */, 845F52ED1FB2B9FC00C10BF0 /* FeedPasteboardWriter.swift in Sources */, + 8444C8F21FED81840051386C /* OPMLExporter.swift in Sources */, 849A975E1ED9EB72007D329B /* MainWindowController.swift in Sources */, 842E45E51ED8C6B7000A8B52 /* MainWindowSplitView.swift in Sources */, 84F2D53A1FC2308B00998D64 /* UnreadFeed.swift in Sources */, diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index 7d922525e..5fe91725b 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -388,7 +388,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, let result = panel.runModal() if result == NSApplication.ModalResponse.OK, let url = panel.url { DispatchQueue.main.async { - let opmlString = AccountManager.shared.localAccount.OPMLString(indentLevel: 0) + let filename = url.lastPathComponent + let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.localAccount, title: filename) do { try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8) } diff --git a/Exporters/OPMLExporter.swift b/Exporters/OPMLExporter.swift new file mode 100644 index 000000000..dde3d18a0 --- /dev/null +++ b/Exporters/OPMLExporter.swift @@ -0,0 +1,41 @@ +// +// OPMLExporter.swift +// Evergreen +// +// Created by Brent Simmons on 12/22/17. +// Copyright © 2017 Ranchero Software. All rights reserved. +// + +import Foundation +import Account +import RSCore + +struct OPMLExporter { + + static func OPMLString(with account: Account, title: String) -> String { + + let escapedTitle = title.rs_stringByEscapingSpecialXMLCharacters() + let openingText = + """ + + + + + \(escapedTitle) + + + + """ + + let middleText = account.OPMLString(indentLevel: 0) + + let closingText = + """ + + + """ + + let opml = openingText + middleText + closingText + return opml + } +}