Merge pull request #2294 from Wevah/applescript-article-feed

AppleScript: Add a "feed" property to articles
This commit is contained in:
Maurice Parker 2020-07-28 21:29:39 -05:00 committed by GitHub
commit d7caad9f7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -150,6 +150,7 @@
</property>
<property name="email address" code="eMal" type="text" access="r" description="email address for the author avatar (optional)">
<cocoa key="emailAddress"/>
<synonym name="email"/>
</property>
</class>
@ -215,6 +216,9 @@
</property>
<property name="image url" code="IURL" type="text" access="r" description="an image url for the article">
<cocoa key="imageURL"/>
</property>
<property name="feed" code="Feed" type="webFeed" access="r" description="the containing feed">
<cocoa key="feed"/>
</property>
<element type="author">
<cocoa key="authors"/>

View File

@ -101,14 +101,13 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
@objc(valueInWebFeedsWithUniqueID:)
func valueInWebFeeds(withUniqueID id:String) -> ScriptableWebFeed? {
let feeds = Array(account.topLevelWebFeeds)
guard let feed = feeds.first(where:{$0.webFeedID == id}) else { return nil }
guard let feed = account.existingWebFeed(withWebFeedID: id) else { return nil }
return ScriptableWebFeed(feed, container:self)
}
@objc(valueInWebFeedsWithName:)
func valueInWebFeeds(withName name:String) -> ScriptableWebFeed? {
let feeds = Array(account.topLevelWebFeeds)
let feeds = Array(account.flattenedWebFeeds())
guard let feed = feeds.first(where:{$0.name == name}) else { return nil }
return ScriptableWebFeed(feed, container:self)
}

View File

@ -141,4 +141,13 @@ class ScriptableArticle: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
return articleAuthors.map { ScriptableAuthor($0, container:self) } as NSArray
}
@objc(feed)
var feed: ScriptableWebFeed? {
guard let parentFeed = self.article.webFeed,
let account = parentFeed.account
else { return nil }
return ScriptableWebFeed(parentFeed, container: ScriptableAccount(account))
}
}