Merge branch 'mac-release'

This commit is contained in:
Maurice Parker 2019-09-25 17:09:21 -05:00
commit b721f74e17
9 changed files with 25 additions and 14 deletions

View File

@ -394,6 +394,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
if let folder = ensureFolder(with: folderName) {
folder.externalID = item.attributes?["nnw_externalID"] as? String
if let itemChildren = item.children {
loadOPMLItems(itemChildren, parentFolder: folder)
}
@ -1023,13 +1024,13 @@ extension Account {
extension Account: OPMLRepresentable {
public func OPMLString(indentLevel: Int) -> String {
public func OPMLString(indentLevel: Int, strictConformance: Bool) -> String {
var s = ""
for feed in topLevelFeeds {
s += feed.OPMLString(indentLevel: indentLevel + 1)
s += feed.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance)
}
for folder in folders! {
s += folder.OPMLString(indentLevel: indentLevel + 1)
s += folder.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance)
}
return s
}

View File

@ -225,7 +225,7 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha
extension Feed: OPMLRepresentable {
public func OPMLString(indentLevel: Int) -> String {
public func OPMLString(indentLevel: Int, strictConformance: Bool) -> String {
// https://github.com/brentsimmons/NetNewsWire/issues/527
// Dont use nameForDisplay because that can result in a feed name "Untitled" written to disk,
// which NetNewsWire may take later to be the actual name.

View File

@ -24,6 +24,7 @@ public final class Folder: DisplayNameProvider, Renamable, Container, UnreadCoun
static let untitledName = NSLocalizedString("Untitled ƒ", comment: "Folder name")
public let folderID: Int // not saved: per-run only
public var externalID: String? = nil
static var incrementingID = 0
// MARK: - DisplayNameProvider
@ -136,20 +137,29 @@ private extension Folder {
extension Folder: OPMLRepresentable {
public func OPMLString(indentLevel: Int) -> String {
public func OPMLString(indentLevel: Int, strictConformance: Bool) -> String {
let attrExternalID: String = {
if !strictConformance, let externalID = externalID {
return " nnw_externalID=\"\(externalID)\""
} else {
return ""
}
}()
let escapedTitle = nameForDisplay.rs_stringByEscapingSpecialXMLCharacters()
var s = "<outline text=\"\(escapedTitle)\" title=\"\(escapedTitle)\">\n"
var s = "<outline text=\"\(escapedTitle)\" title=\"\(escapedTitle)\"\(attrExternalID)>\n"
s = s.rs_string(byPrependingNumberOfTabs: indentLevel)
var hasAtLeastOneChild = false
for feed in topLevelFeeds {
s += feed.OPMLString(indentLevel: indentLevel + 1)
s += feed.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance)
hasAtLeastOneChild = true
}
if !hasAtLeastOneChild {
s = "<outline text=\"\(escapedTitle)\" title=\"\(escapedTitle)\"/>\n"
s = "<outline text=\"\(escapedTitle)\" title=\"\(escapedTitle)\"\(attrExternalID)/>\n"
s = s.rs_string(byPrependingNumberOfTabs: indentLevel)
return s
}

View File

@ -122,7 +122,7 @@ private extension OPMLFile {
"""
let middleText = account.OPMLString(indentLevel: 0)
let middleText = account.OPMLString(indentLevel: 0, strictConformance: false)
let closingText =
"""

View File

@ -150,7 +150,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
@objc(opmlRepresentation)
var opmlRepresentation:String {
return self.account.OPMLString(indentLevel:0)
return self.account.OPMLString(indentLevel:0, strictConformance: true)
}
@objc(accountType)

View File

@ -146,7 +146,7 @@ class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContaine
@objc(opmlRepresentation)
var opmlRepresentation:String {
return self.feed.OPMLString(indentLevel:0)
return self.feed.OPMLString(indentLevel:0, strictConformance: true)
}
// MARK: --- scriptable elements ---

View File

@ -101,7 +101,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
@objc(opmlRepresentation)
var opmlRepresentation:String {
return self.folder.OPMLString(indentLevel:0)
return self.folder.OPMLString(indentLevel:0, strictConformance: true)
}
}

View File

@ -27,7 +27,7 @@ struct OPMLExporter {
"""
let middleText = account.OPMLString(indentLevel: 0)
let middleText = account.OPMLString(indentLevel: 0, strictConformance: true)
let closingText =
"""

@ -1 +1 @@
Subproject commit b3a3178b00810c9e2c668a8c3b17080501cf1f33
Subproject commit d70c24feb4bdad8fdbe7e0beb6edd12d3383c7dc