Merge pull request #2294 from Wevah/applescript-article-feed
AppleScript: Add a "feed" property to articles
This commit is contained in:
commit
d7caad9f7b
|
@ -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"/>
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue