mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-01 19:46:56 +01:00
Add x-netnewswire-feed to the list of scheme prefixes for adding a feed to NetNewsWire, and modify the behavior of the Safari App Extension plugin so that it consults the host app preference for opening in NetNewsWire or with the default feed handler, before choosing which scheme to prepend to the feed URL.
This commit is contained in:
parent
75fd9e1e13
commit
8191f2476a
@ -33,6 +33,7 @@
|
||||
<array>
|
||||
<string>feed</string>
|
||||
<string>feeds</string>
|
||||
<string>x-netnewswire-feed</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
@ -40,13 +40,24 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]?) {
|
||||
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]?) {
|
||||
if (messageName == "subscribeToFeed") {
|
||||
if let feedURLString = userInfo?["url"] as? String {
|
||||
if var feedURLString = userInfo?["url"] as? String {
|
||||
// Ask for the user default from NetNewsWire's defaults to determine whether to open the feed URL
|
||||
// using whatever the system configured default is, or to always hard-code it to NetNewsWire itself.
|
||||
if let pluginBundleID = Bundle.main.bundleIdentifier {
|
||||
// By convention we assume that our bundle ID will always be the same as the host app's, with
|
||||
// the addition of ".Subscribe-to-Feed".
|
||||
let hostAppBundleID = pluginBundleID.replacingOccurrences(of: ".Subscribe-to-Feed", with: "")
|
||||
|
||||
if let sharedDefaults = UserDefaults(suiteName: hostAppBundleID) {
|
||||
let openInNNW = sharedDefaults.bool(forKey: "subscribeToFeedsInNetNewsWire")
|
||||
if openInNNW {
|
||||
feedURLString = feedURLString.replacingOccurrences(of: "feed:", with: "x-netnewswire-feed")
|
||||
}
|
||||
}
|
||||
}
|
||||
if let feedURL = URL(string: feedURLString) {
|
||||
// We could do something more NetNewsWire-specific like invoke an app-specific scheme
|
||||
// to subscribe in the app. For starters we just let NSWorkspace open the URL in the
|
||||
// default "feed:" URL scheme handler.
|
||||
NSWorkspace.shared.open(feedURL)
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,9 @@
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.$(ORGANIZATION_IDENTIFIER).NetNewsWire-Evergreen</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
Loading…
x
Reference in New Issue
Block a user