mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
49 lines
1.2 KiB
Swift
49 lines
1.2 KiB
Swift
//
|
|
// AboutData.swift
|
|
// NetNewsWire-iOS
|
|
//
|
|
// Created by Stuart Breckenridge on 02/10/2022.
|
|
// Copyright © 2022 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
@available(iOS 15, *)
|
|
@available(macOS 12, *)
|
|
protocol LoadableAboutData {
|
|
var about: AboutData { get }
|
|
}
|
|
|
|
@available(iOS 15, *)
|
|
@available(macOS 12, *)
|
|
extension LoadableAboutData {
|
|
|
|
var about: AboutData {
|
|
guard let path = Bundle.main.path(forResource: "About", ofType: "plist") else {
|
|
fatalError("The about plist really should exist.")
|
|
}
|
|
let url = URL(fileURLWithPath: path)
|
|
let data = try! Data(contentsOf: url)
|
|
return try! PropertyListDecoder().decode(AboutData.self, from: data)
|
|
}
|
|
|
|
}
|
|
|
|
@available(iOS 15, *)
|
|
@available(macOS 12, *)
|
|
struct AboutData: Codable {
|
|
var PrimaryContributors: [Contributor]
|
|
var AdditionalContributors: [Contributor]
|
|
|
|
var ThanksMarkdown: AttributedString {
|
|
let dataURL = Bundle.main.url(forResource: "Thanks", withExtension: "md")!
|
|
return try! AttributedString(markdown: Data(contentsOf: dataURL), options: AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace))
|
|
}
|
|
|
|
struct Contributor: Codable {
|
|
var name: String
|
|
var url: String?
|
|
var role: String?
|
|
}
|
|
}
|