mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Make the Styles folder configurable so that it can be in different places on macOS and iOS.
This commit is contained in:
parent
2e7bb5b752
commit
ba279d2a6e
@ -120,6 +120,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
|
||||
SecretsManager.provider = Secrets()
|
||||
AccountManager.shared = AccountManager(accountsFolder: Platform.dataSubfolder(forApplication: nil, folderName: "Accounts")!)
|
||||
ArticleStylesManager.shared = ArticleStylesManager(folderPath: Platform.dataSubfolder(forApplication: nil, folderName: "Styles")!)
|
||||
FeedProviderManager.shared.delegate = ExtensionPointManager.shared
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
|
@ -19,7 +19,6 @@ let CurrentArticleStyleDidChangeNotification = "CurrentArticleStyleDidChangeNoti
|
||||
|
||||
private let styleKey = "style"
|
||||
private let defaultStyleName = "Default"
|
||||
private let stylesFolderName = "Styles"
|
||||
private let stylesInResourcesFolderName = "Styles"
|
||||
private let styleSuffix = ".netnewswirestyle"
|
||||
private let nnwStyleSuffix = ".nnwstyle"
|
||||
@ -28,8 +27,8 @@ private let styleSuffixes = [styleSuffix, nnwStyleSuffix, cssStyleSuffix];
|
||||
|
||||
final class ArticleStylesManager {
|
||||
|
||||
static let shared = ArticleStylesManager()
|
||||
private let folderPath = Platform.dataSubfolder(forApplication: nil, folderName: stylesFolderName)!
|
||||
static var shared: ArticleStylesManager!
|
||||
private let folderPath: String
|
||||
|
||||
var currentStyleName: String {
|
||||
get {
|
||||
@ -54,18 +53,17 @@ final class ArticleStylesManager {
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
init(folderPath: String) {
|
||||
self.folderPath = folderPath
|
||||
|
||||
do {
|
||||
try FileManager.default.createDirectory(atPath: folderPath, withIntermediateDirectories: true, attributes: nil)
|
||||
} catch {
|
||||
assertionFailure("Could not create folder for Styles.")
|
||||
abort()
|
||||
}
|
||||
|
||||
UserDefaults.standard.register(defaults: [styleKey: defaultStyleName])
|
||||
//
|
||||
// let defaultStylesFolder = (Bundle.main.resourcePath! as NSString).appendingPathComponent(stylesInResourcesFolderName)
|
||||
// do {
|
||||
// try FileManager.default.rs_copyFiles(inFolder: defaultStylesFolder, destination: folderPath)
|
||||
// }
|
||||
// catch {
|
||||
// print(error)
|
||||
// }
|
||||
|
||||
currentStyle = ArticleStyle.defaultStyle
|
||||
|
||||
updateStyleNames()
|
||||
|
@ -63,10 +63,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
appDelegate = self
|
||||
|
||||
SecretsManager.provider = Secrets()
|
||||
let documentAccountURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||
let documentAccountsFolder = documentAccountURL.appendingPathComponent("Accounts").absoluteString
|
||||
let documentFolder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||
let documentAccountsFolder = documentFolder.appendingPathComponent("Accounts").absoluteString
|
||||
let documentAccountsFolderPath = String(documentAccountsFolder.suffix(from: documentAccountsFolder.index(documentAccountsFolder.startIndex, offsetBy: 7)))
|
||||
AccountManager.shared = AccountManager(accountsFolder: documentAccountsFolderPath)
|
||||
|
||||
let documentStylesFolder = documentFolder.appendingPathComponent("Styles").absoluteString
|
||||
let documentStylesFolderPath = String(documentStylesFolder.suffix(from: documentAccountsFolder.index(documentStylesFolder.startIndex, offsetBy: 7)))
|
||||
ArticleStylesManager.shared = ArticleStylesManager(folderPath: documentStylesFolderPath)
|
||||
|
||||
FeedProviderManager.shared.delegate = ExtensionPointManager.shared
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
|
Loading…
Reference in New Issue
Block a user