mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
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:
@@ -8,6 +8,7 @@
|
||||
|
||||
import Cocoa
|
||||
import Account
|
||||
import Data
|
||||
|
||||
extension NSApplication : ScriptingObjectContainer {
|
||||
|
||||
@@ -25,6 +26,21 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
return accounts.map { ScriptableAccount($0) } as NSArray
|
||||
}
|
||||
|
||||
/*
|
||||
accessing feeds from the application object skips the 'account' containment hierarchy
|
||||
this allows a script like 'articles of feed "The Shape of Everything"' as a shorthand
|
||||
for 'articles of feed "The Shape of Everything" of account "On My Mac"'
|
||||
*/
|
||||
@objc(feeds)
|
||||
func feeds() -> NSArray {
|
||||
let accounts = AccountManager.shared.accounts
|
||||
let emptyFeeds:[Feed] = []
|
||||
let feeds = accounts.reduce(emptyFeeds) { (result, nthAccount) -> [Feed] in
|
||||
let accountFeeds = nthAccount.children.flatMap { $0 as? Feed }
|
||||
return result + accountFeeds
|
||||
}
|
||||
return feeds.map { ScriptableFeed($0, container:self) } as NSArray
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user