2017-12-22 19:28:26 +01:00
|
|
|
//
|
|
|
|
// OPMLExporter.swift
|
2018-08-29 07:18:24 +02:00
|
|
|
// NetNewsWire
|
2017-12-22 19:28:26 +01:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 12/22/17.
|
|
|
|
// Copyright © 2017 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Account
|
|
|
|
|
|
|
|
struct OPMLExporter {
|
|
|
|
|
|
|
|
static func OPMLString(with account: Account, title: String) -> String {
|
|
|
|
|
2020-01-17 03:09:18 +01:00
|
|
|
let escapedTitle = title.escapingSpecialXMLCharacters
|
2017-12-22 19:28:26 +01:00
|
|
|
let openingText =
|
|
|
|
"""
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
2018-08-29 07:18:24 +02:00
|
|
|
<!-- OPML generated by NetNewsWire -->
|
2017-12-22 19:28:26 +01:00
|
|
|
<opml version="1.1">
|
|
|
|
<head>
|
|
|
|
<title>\(escapedTitle)</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2020-01-14 05:20:20 +01:00
|
|
|
let middleText = account.OPMLString(indentLevel: 0)
|
2017-12-22 19:28:26 +01:00
|
|
|
|
|
|
|
let closingText =
|
|
|
|
"""
|
|
|
|
</body>
|
|
|
|
</opml>
|
|
|
|
"""
|
|
|
|
|
|
|
|
let opml = openingText + middleText + closingText
|
|
|
|
return opml
|
|
|
|
}
|
|
|
|
}
|