mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-31 11:14:54 +01:00
Merge branch 'mac-release'
This commit is contained in:
commit
786a4e48c4
@ -37,6 +37,9 @@ struct AppDefaults {
|
||||
static let timelineShowsSeparators = "CorreiaSeparators"
|
||||
static let showTitleOnMainWindow = "KafasisTitleMode"
|
||||
static let hideDockUnreadCount = "JustinMillerHideDockUnreadCount"
|
||||
|
||||
static let webInspectorEnabled = "WebInspectorEnabled"
|
||||
static let webInspectorStartsAttached = "__WebInspectorPageGroupLevel1__.WebKit2InspectorStartsAttached"
|
||||
}
|
||||
|
||||
private static let smallestFontSizeRawValue = FontSize.small.rawValue
|
||||
@ -139,6 +142,24 @@ struct AppDefaults {
|
||||
return bool(for: Key.hideDockUnreadCount)
|
||||
}
|
||||
|
||||
static var webInspectorEnabled: Bool {
|
||||
get {
|
||||
return bool(for: Key.webInspectorEnabled)
|
||||
}
|
||||
set {
|
||||
setBool(for: Key.webInspectorEnabled, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var webInspectorStartsAttached: Bool {
|
||||
get {
|
||||
return bool(for: Key.webInspectorStartsAttached)
|
||||
}
|
||||
set {
|
||||
setBool(for: Key.webInspectorStartsAttached, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var timelineSortDirection: ComparisonResult {
|
||||
get {
|
||||
return sortDirection(for: Key.timelineSortDirection)
|
||||
|
@ -314,6 +314,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
if item.action == #selector(showAddFeedWindow(_:)) || item.action == #selector(showAddFolderWindow(_:)) {
|
||||
return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty
|
||||
}
|
||||
if item.action == #selector(toggleWebInspectorEnabled(_:)) {
|
||||
(item as! NSMenuItem).state = AppDefaults.webInspectorEnabled ? .on : .off
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ -535,6 +538,18 @@ extension AppDelegate {
|
||||
@IBAction func debugSearch(_ sender: Any?) {
|
||||
AccountManager.shared.defaultAccount.debugRunSearch()
|
||||
}
|
||||
|
||||
@IBAction func toggleWebInspectorEnabled(_ sender: Any?) {
|
||||
let newValue = !AppDefaults.webInspectorEnabled
|
||||
AppDefaults.webInspectorEnabled = newValue
|
||||
|
||||
// An attached inspector can display incorrectly on certain setups (like mine); default to displaying in a separate window,
|
||||
// and reset the default to a separate window when the preference is toggled off and on again in case the inspector is
|
||||
// accidentally reattached.
|
||||
|
||||
AppDefaults.webInspectorStartsAttached = false
|
||||
NotificationCenter.default.post(name: .WebInspectorEnabledDidChange, object: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
private extension AppDelegate {
|
||||
|
@ -476,6 +476,13 @@
|
||||
<action selector="debugSearch:" target="Ady-hI-5gd" id="HvM-F7-u7s"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="OOI-Hk-eqi"/>
|
||||
<menuItem title="Enable Web Inspector" id="EwI-z4-ZA3">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleWebInspectorEnabled:" target="Voe-Tx-rLC" id="nsd-PV-Tz2"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
|
@ -27,6 +27,15 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var webInspectorEnabled: Bool {
|
||||
get {
|
||||
return webView.configuration.preferences._developerExtrasEnabled
|
||||
}
|
||||
set {
|
||||
webView.configuration.preferences._developerExtrasEnabled = newValue
|
||||
}
|
||||
}
|
||||
|
||||
private var waitingForFirstReload = false
|
||||
private let keyboardDelegate = DetailKeyboardDelegate()
|
||||
@ -87,6 +96,10 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
|
||||
webView.isHidden = true
|
||||
waitingForFirstReload = true
|
||||
|
||||
webInspectorEnabled = AppDefaults.webInspectorEnabled
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(webInspectorEnabledDidChange(_:)), name: .WebInspectorEnabledDidChange, object: nil)
|
||||
|
||||
reloadHTML()
|
||||
}
|
||||
|
||||
@ -185,6 +198,10 @@ private extension DetailWebViewController {
|
||||
callback(scrollInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func webInspectorEnabledDidChange(_ notification: Notification) {
|
||||
self.webInspectorEnabled = notification.object! as! Bool
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ScrollInfo
|
||||
|
9
Mac/NetNewsWire-Bridging-Header.h
Normal file
9
Mac/NetNewsWire-Bridging-Header.h
Normal file
@ -0,0 +1,9 @@
|
||||
//
|
||||
// NetNewsWire-Bridging-Header.h
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Nate Weaver on 2019-09-17.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WKPreferencesPrivate.h"
|
15
Mac/WKPreferencesPrivate.h
Normal file
15
Mac/WKPreferencesPrivate.h
Normal file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// WKPreferencesPrivate.h
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Nate Weaver on 2019-09-17.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
@interface WKPreferences (Private)
|
||||
|
||||
@property (nonatomic, setter=_setDeveloperExtrasEnabled:) BOOL _developerExtrasEnabled API_AVAILABLE(macos(10.11), ios(9.0));
|
||||
|
||||
@end
|
@ -1037,6 +1037,8 @@
|
||||
84FB9A2D1EDCD6B8003D53B9 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Frameworks/Vendor/Sparkle.framework; sourceTree = SOURCE_ROOT; };
|
||||
84FF69B01FC3793300DC198E /* FaviconURLFinder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconURLFinder.swift; sourceTree = "<group>"; };
|
||||
D519E74722EE553300923F27 /* NetNewsWire_safariextension_target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = NetNewsWire_safariextension_target.xcconfig; sourceTree = "<group>"; };
|
||||
B24EFD482330FF99006C6242 /* NetNewsWire-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NetNewsWire-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
B24EFD5923310109006C6242 /* WKPreferencesPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKPreferencesPrivate.h; sourceTree = "<group>"; };
|
||||
D553737C20186C1F006D8857 /* Article+Scriptability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Article+Scriptability.swift"; sourceTree = "<group>"; };
|
||||
D57BE6DF204CD35F00D11AAC /* NSScriptCommand+NetNewsWire.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSScriptCommand+NetNewsWire.swift"; sourceTree = "<group>"; };
|
||||
D5907CDC2002F0BE005947E5 /* NetNewsWire_project_release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = NetNewsWire_project_release.xcconfig; sourceTree = "<group>"; };
|
||||
@ -1785,6 +1787,8 @@
|
||||
6581C73620CED60100F4AD34 /* SafariExtension */,
|
||||
84C9FC8322629E8F00D921D6 /* Resources */,
|
||||
84FB9A2C1EDCD6A4003D53B9 /* Frameworks */,
|
||||
B24EFD482330FF99006C6242 /* NetNewsWire-Bridging-Header.h */,
|
||||
B24EFD5923310109006C6242 /* WKPreferencesPrivate.h */,
|
||||
);
|
||||
path = Mac;
|
||||
sourceTree = "<group>";
|
||||
|
@ -13,6 +13,7 @@ extension Notification.Name {
|
||||
static let InspectableObjectsDidChange = Notification.Name("TimelineSelectionDidChangeNotification")
|
||||
static let UserDidAddFeed = Notification.Name("UserDidAddFeedNotification")
|
||||
static let UserDidRequestSidebarSelection = Notification.Name("UserDidRequestSidebarSelectionNotification")
|
||||
static let WebInspectorEnabledDidChange = Notification.Name("WebInspectorEnabledDidChange")
|
||||
}
|
||||
|
||||
typealias UserInfoDictionary = [AnyHashable: Any]
|
||||
|
@ -342,6 +342,9 @@ private extension ArticleRenderer {
|
||||
anchors[i].addEventListener("mouseenter", function() { mouseDidEnterLink(this) });
|
||||
anchors[i].addEventListener("mouseleave", function() { mouseDidExitLink(this) });
|
||||
}
|
||||
|
||||
document.getElementsByTagName("body")[0].querySelectorAll("style, link[rel=stylesheet]").forEach(element => element.remove());
|
||||
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => element.removeAttribute("style"));
|
||||
}
|
||||
|
||||
function mouseDidEnterLink(anchor) {
|
||||
@ -376,7 +379,20 @@ private extension ArticleRenderer {
|
||||
s += "<meta name=\"viewport\" content=\"width=device-width\">\n"
|
||||
s += title.htmlBySurroundingWithTag("title")
|
||||
s += styleString().htmlBySurroundingWithTag("style")
|
||||
s += "\n\n</head><body>\n\n"
|
||||
s += """
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function startup() {
|
||||
document.getElementsByTagName("body")[0].querySelectorAll("style, link[rel=stylesheet]").forEach(element => element.remove());
|
||||
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => element.removeAttribute("style"));
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
"""
|
||||
|
||||
s += "\n\n</head><body onload='startup()'>\n\n"
|
||||
s += body
|
||||
s += "\n\n</body></html>"
|
||||
|
||||
|
@ -38,4 +38,5 @@ CODE_SIGN_ENTITLEMENTS = Mac/Resources/NetNewsWire.entitlements
|
||||
INFOPLIST_FILE = Mac/Resources/Info.plist
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.ranchero.NetNewsWire-Evergreen
|
||||
PRODUCT_NAME = NetNewsWire
|
||||
PRODUCT_NAME = NetNewsWire
|
||||
SWIFT_OBJC_BRIDGING_HEADER = Mac/NetNewsWire-Bridging-Header.h
|
||||
|
Loading…
x
Reference in New Issue
Block a user