This commit is contained in:
Maurice Parker 2019-08-02 05:03:40 -05:00
commit 509afd6b0e
4 changed files with 22 additions and 22 deletions

View File

@ -88,9 +88,9 @@
<property name="active" code="Actv" type="boolean" access="rw" description="Whether or not the account is active"> <property name="active" code="Actv" type="boolean" access="rw" description="Whether or not the account is active">
<cocoa key="scriptingIsActive"/> <cocoa key="scriptingIsActive"/>
</property> </property>
<property name="contents" code="Cnts" access="r" description="The type of the account"> <property name="allFeeds" code="Feds" access="r" description="All feeds, including feeds inside folders">
<cocoa key="contents"/> <cocoa key="allFeeds"/>
<type type="account item" list="yes"/> <type type="feed" list="yes"/>
</property> </property>
<property name="opml representation" code="OPML" type="text" access="r" description="OPML representation for the account"> <property name="opml representation" code="OPML" type="text" access="r" description="OPML representation for the account">
<cocoa key="opmlRepresentation"/> <cocoa key="opmlRepresentation"/>
@ -103,10 +103,7 @@
</element> </element>
</class> </class>
<class name="account item" code="AItm" plural="account items" description="a folder or feed"> <class name="feed" code="Feed" plural="feeds" description="An RSS feeds">
</class>
<class name="feed" code="Feed" plural="feeds" description="An RSS feeds" inherits="account item">
<cocoa class="ScriptableFeed"/> <cocoa class="ScriptableFeed"/>
<property name="name" code="pnam" type="text" access="r" description="The name of the feed"> <property name="name" code="pnam" type="text" access="r" description="The name of the feed">
<cocoa key="name"/> <cocoa key="name"/>
@ -156,7 +153,7 @@
</property> </property>
</class> </class>
<class name="folder" code="fold" plural="folders" description="A folder for organizing feeds" inherits="account item"> <class name="folder" code="fold" plural="folders" description="A folder for organizing feeds">
<cocoa class="ScriptableFolder"/> <cocoa class="ScriptableFolder"/>
<property name="name" code="pnam" type="text" access="r" description="The name of the account"> <property name="name" code="pnam" type="text" access="r" description="The name of the account">
<cocoa key="name"/> <cocoa key="name"/>

View File

@ -121,18 +121,21 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
// MARK: --- Scriptable properties --- // MARK: --- Scriptable properties ---
@objc(contents) @objc(allFeeds)
var contents:NSArray { var allFeeds: NSArray {
var contentsArray:[AnyObject] = [] var feeds = [ScriptableFeed]()
for feed in account.topLevelFeeds { for feed in account.topLevelFeeds {
contentsArray.append(ScriptableFeed(feed, container: self)) feeds.append(ScriptableFeed(feed, container: self))
} }
if let folders = account.folders { if let folders = account.folders {
for folder in folders { for folder in folders {
contentsArray.append(ScriptableFolder(folder, container:self)) let scriptableFolder = ScriptableFolder(folder, container: self)
for feed in folder.topLevelFeeds {
feeds.append(ScriptableFeed(feed, container: scriptableFolder))
}
} }
} }
return contentsArray as NSArray return feeds as NSArray
} }
@objc(opmlRepresentation) @objc(opmlRepresentation)

View File

@ -56,7 +56,7 @@ extension NSApplication : ScriptingObjectContainer {
@objc(accounts) @objc(accounts)
func accounts() -> NSArray { func accounts() -> NSArray {
let accounts = AccountManager.shared.activeAccounts let accounts = AccountManager.shared.accounts
return accounts.map { ScriptableAccount($0) } as NSArray return accounts.map { ScriptableAccount($0) } as NSArray
} }

View File

@ -56,13 +56,13 @@ class ScriptingTests: AppleScriptXCTestCase {
_ = doIndividualScript(filename: "testFeedOPML") _ = doIndividualScript(filename: "testFeedOPML")
} }
func testTitleOfArticlesWhoseScript() { // func testTitleOfArticlesWhoseScript() {
_ = doIndividualScript(filename: "testTitleOfArticlesWhose") // _ = doIndividualScript(filename: "testTitleOfArticlesWhose")
} // }
//
func testIterativeCreateAndDeleteScript() { // func testIterativeCreateAndDeleteScript() {
_ = doIndividualScriptWithExpectation(filename: "testIterativeCreateAndDeleteFeed") // _ = doIndividualScriptWithExpectation(filename: "testIterativeCreateAndDeleteFeed")
} // }
func doIndividualScriptWithExpectation(filename:String) { func doIndividualScriptWithExpectation(filename:String) {
let queue = DispatchQueue(label:"testQueue") let queue = DispatchQueue(label:"testQueue")