2018-01-11 09:51:25 +01:00
|
|
|
//
|
|
|
|
// Feed+Scriptability.swift
|
|
|
|
// Evergreen
|
|
|
|
//
|
|
|
|
// Created by Olof Hellman on 1/10/18.
|
|
|
|
// Copyright © 2018 Olof Hellman. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Account
|
|
|
|
import Data
|
|
|
|
|
|
|
|
@objc(ScriptableFeed)
|
2018-01-20 07:31:17 +01:00
|
|
|
class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContainer{
|
2018-01-11 09:51:25 +01:00
|
|
|
|
|
|
|
let feed:Feed
|
|
|
|
let container:ScriptingObjectContainer
|
|
|
|
|
|
|
|
init (_ feed:Feed, container:ScriptingObjectContainer) {
|
|
|
|
self.feed = feed
|
|
|
|
self.container = container
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc(objectSpecifier)
|
|
|
|
override var objectSpecifier: NSScriptObjectSpecifier? {
|
|
|
|
let scriptObjectSpecifier = self.container.makeFormUniqueIDScriptObjectSpecifier(forObject:self)
|
|
|
|
return (scriptObjectSpecifier)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: --- ScriptingObject protocol ---
|
|
|
|
|
|
|
|
var scriptingKey: String {
|
|
|
|
return "feeds"
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: --- UniqueIdScriptingObject protocol ---
|
|
|
|
|
|
|
|
// I am not sure if account should prefer to be specified by name or by ID
|
|
|
|
// but in either case it seems like the accountID would be used as the keydata, so I chose ID
|
|
|
|
|
|
|
|
var scriptingUniqueId:Any {
|
|
|
|
return feed.feedID
|
|
|
|
}
|
2018-01-20 07:31:17 +01:00
|
|
|
|
|
|
|
// MARK: --- ScriptingObjectContainer protocol ---
|
2018-01-11 09:51:25 +01:00
|
|
|
|
2018-01-20 07:31:17 +01:00
|
|
|
var scriptingClassDescription: NSScriptClassDescription {
|
|
|
|
return self.classDescription as! NSScriptClassDescription
|
|
|
|
}
|
|
|
|
|
2018-01-11 09:51:25 +01:00
|
|
|
// MARK: --- Scriptable properties ---
|
|
|
|
|
|
|
|
@objc(url)
|
|
|
|
var url:String {
|
|
|
|
return self.feed.url
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc(uniqueId)
|
|
|
|
var uniqueId:String {
|
|
|
|
return self.feed.feedID
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc(name)
|
|
|
|
var name:String {
|
|
|
|
return self.feed.name ?? ""
|
|
|
|
}
|
|
|
|
|
2018-01-20 07:31:17 +01:00
|
|
|
@objc(homePageURL)
|
|
|
|
var homePageURL:String {
|
|
|
|
return self.feed.homePageURL ?? ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc(iconURL)
|
|
|
|
var iconURL:String {
|
|
|
|
return self.feed.iconURL ?? ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc(faviconURL)
|
|
|
|
var faviconURL:String {
|
|
|
|
return self.feed.faviconURL ?? ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc(authors)
|
|
|
|
var authors:NSArray {
|
|
|
|
let feedAuthors = feed.authors ?? []
|
|
|
|
return feedAuthors.map { ScriptableAuthor($0, container:self) } as NSArray
|
|
|
|
}
|
|
|
|
|
2018-01-11 09:51:25 +01:00
|
|
|
}
|