2018-01-19 22:31:17 -08:00
|
|
|
//
|
|
|
|
|
// Author+Scriptability.swift
|
2018-08-28 22:18:24 -07:00
|
|
|
// NetNewsWire
|
2018-01-19 22:31:17 -08:00
|
|
|
//
|
|
|
|
|
// Created by Olof Hellman on 1/19/18.
|
|
|
|
|
// Copyright © 2018 Olof Hellman. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
import Account
|
2018-07-23 18:29:08 -07:00
|
|
|
import Articles
|
2018-01-19 22:31:17 -08:00
|
|
|
|
|
|
|
|
@objc(ScriptableAuthor)
|
2025-11-18 13:25:47 -08:00
|
|
|
@MainActor final class ScriptableAuthor: NSObject, UniqueIDScriptingObject {
|
|
|
|
|
let author: Author
|
2025-11-18 15:29:29 -08:00
|
|
|
nonisolated(unsafe) let container: ScriptingObjectContainer
|
2018-01-19 22:31:17 -08:00
|
|
|
|
2026-01-02 10:17:41 -08:00
|
|
|
init(_ author: Author, container: ScriptingObjectContainer) {
|
2018-01-19 22:31:17 -08:00
|
|
|
self.author = author
|
|
|
|
|
self.container = container
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc(objectSpecifier)
|
2025-11-18 15:29:29 -08:00
|
|
|
nonisolated override var objectSpecifier: NSScriptObjectSpecifier? {
|
2025-11-18 13:25:47 -08:00
|
|
|
let scriptObjectSpecifier = container.makeFormUniqueIDScriptObjectSpecifier(forObject: self)
|
|
|
|
|
return scriptObjectSpecifier
|
2018-01-19 22:31:17 -08:00
|
|
|
}
|
|
|
|
|
|
2019-07-10 00:02:20 -07:00
|
|
|
@objc(scriptingSpecifierDescriptor)
|
|
|
|
|
func scriptingSpecifierDescriptor() -> NSScriptObjectSpecifier {
|
2026-01-02 10:17:41 -08:00
|
|
|
objectSpecifier ?? NSScriptObjectSpecifier()
|
2019-07-10 00:02:20 -07:00
|
|
|
}
|
|
|
|
|
|
2026-01-02 10:17:41 -08:00
|
|
|
// MARK: - ScriptingObject protocol
|
2018-01-19 22:31:17 -08:00
|
|
|
|
2025-11-18 15:29:29 -08:00
|
|
|
nonisolated var scriptingKey: String {
|
2026-01-02 10:17:41 -08:00
|
|
|
"authors"
|
2018-01-19 22:31:17 -08:00
|
|
|
}
|
|
|
|
|
|
2026-01-02 10:17:41 -08:00
|
|
|
// MARK: - UniqueIdScriptingObject protocol
|
2018-01-19 22:31:17 -08:00
|
|
|
|
2018-04-25 21:40:50 -07:00
|
|
|
@objc(uniqueId)
|
2026-01-02 10:17:41 -08:00
|
|
|
nonisolated var scriptingUniqueID: Any {
|
|
|
|
|
author.authorID
|
2018-01-19 22:31:17 -08:00
|
|
|
}
|
2025-11-05 11:22:10 -08:00
|
|
|
|
2026-01-02 10:17:41 -08:00
|
|
|
// MARK: - Scriptable properties
|
2025-11-05 11:22:10 -08:00
|
|
|
|
2018-01-19 22:31:17 -08:00
|
|
|
@objc(url)
|
2026-01-02 17:50:35 -08:00
|
|
|
var url: String {
|
2026-01-02 10:17:41 -08:00
|
|
|
author.url ?? ""
|
2018-01-19 22:31:17 -08:00
|
|
|
}
|
2025-11-05 11:22:10 -08:00
|
|
|
|
2018-01-19 22:31:17 -08:00
|
|
|
@objc(name)
|
2026-01-02 17:50:35 -08:00
|
|
|
var name: String {
|
2026-01-02 10:17:41 -08:00
|
|
|
author.name ?? ""
|
2018-01-19 22:31:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc(avatarURL)
|
2026-01-02 17:50:35 -08:00
|
|
|
var avatarURL: String {
|
2026-01-02 10:17:41 -08:00
|
|
|
author.avatarURL ?? ""
|
2018-01-19 22:31:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc(emailAddress)
|
2026-01-02 17:50:35 -08:00
|
|
|
var emailAddress: String {
|
2026-01-02 10:17:41 -08:00
|
|
|
author.emailAddress ?? ""
|
2018-01-19 22:31:17 -08:00
|
|
|
}
|
|
|
|
|
}
|