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

View File

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