Scripting support for articles and basic article properties

Also, added support for accessing feeds directly from the top level
container, essentially skipping account as a hierarchy level.

With this change, a script like

tell app “Evergreen”
   title of every article of feed "Six Colors" where read is true
end tell

produces the expected result.
This commit is contained in:
Olof Hellman
2018-01-24 00:06:34 -08:00
parent c4542ac668
commit 31bd9d918c
6 changed files with 197 additions and 4 deletions

View File

@@ -90,5 +90,15 @@ class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContaine
let feedAuthors = feed.authors ?? []
return feedAuthors.map { ScriptableAuthor($0, container:self) } as NSArray
}
@objc(articles)
var articles:NSArray {
let feedArticles = feed.fetchArticles()
// the articles are a set, use the sorting algorithm from the viewer
let sortedArticles = feedArticles.sorted(by:{
return $0.logicalDatePublished > $1.logicalDatePublished
})
return sortedArticles.map { ScriptableArticle($0, container:self) } as NSArray
}
}