From 1e1fce59da3501ac4bd4d21a3cbc5a83a84cba59 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 20 Mar 2020 06:41:38 -0500 Subject: [PATCH 1/4] Use system accent color to tint the article view --- Mac/MainWindow/Detail/styleSheet.css | 16 ++++++++------ .../Article Rendering/ArticleRenderer.swift | 22 ++++++++++++++----- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Mac/MainWindow/Detail/styleSheet.css b/Mac/MainWindow/Detail/styleSheet.css index 2f64566e5..bac3b2b14 100644 --- a/Mac/MainWindow/Detail/styleSheet.css +++ b/Mac/MainWindow/Detail/styleSheet.css @@ -35,14 +35,15 @@ a:hover { :root { --body-color: #444; --body-background-color: -apple-system-text-background; - --accent-color: hsla(215, 99%, 43%, 1); + --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], 1.0); + --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .75); --block-quote-border-color: hsla(215, 99%, 43%, 0.75); --header-table-border-color: rgba(0, 0, 0, 0.1); --header-color: rgba(0, 0, 0, 0.3); - --header-link-color: rgba(0, 0, 0, 0.3); --body-code-color: #666; --system-message-color: #cbcbcb; --feedlink-color: rgba(0, 0, 0, 0.6); + --article-title-color: #333; --table-cell-border-color: lightgray; } @@ -50,13 +51,13 @@ a:hover { :root { --body-color: #d2d2d2; --body-background-color: #2d2d2d; - --accent-color: #4490e2; - --block-quote-border-color: rgba(68, 144, 226, 0.75); + --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], 1.0); + --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .75); --header-table-border-color: rgba(255, 255, 255, 0.1); --header-color: #d2d2d2; - --header-link-color: #4490e2; --body-code-color: #b2b2b2; --system-message-color: #5f5f5f; + --article-title-color: #e0e0e0; --table-cell-border-color: dimgray; } } @@ -76,7 +77,7 @@ body .header { color: var(--header-color); } body .header a:link, body .header a:visited { - color: var(--header-link-color); + color: var(--accent-color); } body .articleDateline, body .articleDateLine.a:link, body .articleDateline a:visited { color: var(--header-color); @@ -106,7 +107,8 @@ body > .systemMessage { text-align: left; } -.articleTitle { +.articleTitle a:link, .articleTitle a:visited { + color: var(--article-title-color); margin-top: 26px; } diff --git a/Shared/Article Rendering/ArticleRenderer.swift b/Shared/Article Rendering/ArticleRenderer.swift index 0be3508d3..8d80b5403 100644 --- a/Shared/Article Rendering/ArticleRenderer.swift +++ b/Shared/Article Rendering/ArticleRenderer.swift @@ -112,12 +112,7 @@ private extension ArticleRenderer { } private var articleCSS: String { - #if os(iOS) - let style = try! MacroProcessor.renderedText(withTemplate: styleString(), substitutions: styleSubstitutions()) - return style - #else - return styleString() - #endif + return try! MacroProcessor.renderedText(withTemplate: styleString(), substitutions: styleSubstitutions()) } static var defaultStyleSheet: String = { @@ -260,6 +255,21 @@ private extension ArticleRenderer { d["font-size"] = String(describing: bodyFont.pointSize) return d } + #else + func styleSubstitutions() -> [String: String] { + var d = [String: String]() + guard let linkColor = NSColor.controlAccentColor.usingColorSpace(.deviceRGB) else { + return d + } + let red = Int(round(linkColor.redComponent * 0xFF)) + let green = Int(round(linkColor.greenComponent * 0xFF)) + let blue = Int(round(linkColor.blueComponent * 0xFF)) + + d["accent-r"] = String(red) + d["accent-g"] = String(green) + d["accent-b"] = String(blue) + return d + } #endif } From 6a384d99e68ed569ef97237ae6da9547eb106060 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 20 Mar 2020 08:13:39 -0500 Subject: [PATCH 2/4] Darken and lighten the accent color for the article view. --- .../Detail/DetailWebViewController.swift | 17 ++++++++++++++ .../Article Rendering/ArticleRenderer.swift | 22 ++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 362c3de81..8b4cdfc08 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -12,6 +12,11 @@ import RSCore import RSWeb import Articles +extension Notification.Name { + static let appleColorPreferencesChangedNotification = Notification.Name("AppleColorPreferencesChangedNotification") + static let appleInterfaceThemeChangedNotification = Notification.Name("AppleInterfaceThemeChangedNotification") +} + protocol DetailWebViewControllerDelegate: class { func mouseDidEnter(_: DetailWebViewController, link: String) func mouseDidExit(_: DetailWebViewController, link: String) @@ -118,6 +123,10 @@ final class DetailWebViewController: NSViewController, WKUIDelegate { NotificationCenter.default.addObserver(self, selector: #selector(webFeedIconDidBecomeAvailable(_:)), name: .WebFeedIconDidBecomeAvailable, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(avatarDidBecomeAvailable(_:)), name: .AvatarDidBecomeAvailable, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil) + + DistributedNotificationCenter.default().addObserver(self, selector: #selector(appleColorPreferencesChanged(_:)), name: .appleColorPreferencesChangedNotification, object: nil) + DistributedNotificationCenter.default().addObserver(self, selector: #selector(appleInterfaceThemeChanged(_:)), name: .appleInterfaceThemeChangedNotification, object: nil) webView.loadFileURL(ArticleRenderer.blank.url, allowingReadAccessTo: ArticleRenderer.blank.baseURL) } @@ -136,6 +145,14 @@ final class DetailWebViewController: NSViewController, WKUIDelegate { reloadArticleImage() } + @objc func appleColorPreferencesChanged(_ note: Notification) { + reloadHTML() + } + + @objc func appleInterfaceThemeChanged(_ note: Notification) { + reloadHTML() + } + // MARK: Media Functions func stopMediaPlayback() { diff --git a/Shared/Article Rendering/ArticleRenderer.swift b/Shared/Article Rendering/ArticleRenderer.swift index 8d80b5403..56ba9531e 100644 --- a/Shared/Article Rendering/ArticleRenderer.swift +++ b/Shared/Article Rendering/ArticleRenderer.swift @@ -261,9 +261,25 @@ private extension ArticleRenderer { guard let linkColor = NSColor.controlAccentColor.usingColorSpace(.deviceRGB) else { return d } - let red = Int(round(linkColor.redComponent * 0xFF)) - let green = Int(round(linkColor.greenComponent * 0xFF)) - let blue = Int(round(linkColor.blueComponent * 0xFF)) + + let red: Int + let green: Int + let blue: Int + + if NSApplication.shared.effectiveAppearance.isDarkMode { + let brighten = CGFloat(0.25) + let baseRed = linkColor.redComponent * 0xFF + red = Int(round(((255 - baseRed) * brighten)) + round(baseRed)) + let baseGreen = linkColor.greenComponent * 0xFF + green = Int(round(((255 - baseGreen) * brighten)) + round(baseGreen)) + let baseBlue = linkColor.blueComponent * 0xFF + blue = Int(round(((255 - baseBlue) * brighten)) + round(baseBlue)) + } else { + let darken = CGFloat(0.75) + red = Int(round(linkColor.redComponent * 0xFF * darken)) + green = Int(round(linkColor.greenComponent * 0xFF * darken)) + blue = Int(round(linkColor.blueComponent * 0xFF * darken)) + } d["accent-r"] = String(red) d["accent-g"] = String(green) From cc7887857ab86d5461fa920a716925e466e61049 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 20 Mar 2020 08:34:25 -0500 Subject: [PATCH 3/4] Fix block quote css bug. --- Mac/MainWindow/Detail/styleSheet.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Mac/MainWindow/Detail/styleSheet.css b/Mac/MainWindow/Detail/styleSheet.css index bac3b2b14..872a639ac 100644 --- a/Mac/MainWindow/Detail/styleSheet.css +++ b/Mac/MainWindow/Detail/styleSheet.css @@ -35,9 +35,8 @@ a:hover { :root { --body-color: #444; --body-background-color: -apple-system-text-background; - --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], 1.0); --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .75); - --block-quote-border-color: hsla(215, 99%, 43%, 0.75); + --block-quote-border-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .50); --header-table-border-color: rgba(0, 0, 0, 0.1); --header-color: rgba(0, 0, 0, 0.3); --body-code-color: #666; @@ -51,8 +50,8 @@ a:hover { :root { --body-color: #d2d2d2; --body-background-color: #2d2d2d; - --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], 1.0); --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .75); + --block-quote-border-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .50); --header-table-border-color: rgba(255, 255, 255, 0.1); --header-color: #d2d2d2; --body-code-color: #b2b2b2; From a03f475f8f116e0a917101fe01480defe7db9298 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 22 Mar 2020 20:29:21 -0500 Subject: [PATCH 4/4] Added encryption information to build script --- buildscripts/ci-build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/buildscripts/ci-build.sh b/buildscripts/ci-build.sh index 1babfdfe5..aa1876bab 100755 --- a/buildscripts/ci-build.sh +++ b/buildscripts/ci-build.sh @@ -3,6 +3,12 @@ set -v set -e # Unencrypt our provisioning profiles, certificates, and private key +# +# Encrypt the profiles, certs, and key using the following example command where +# "secret-key" is the key stored in the Github Secrets variable ENCRYPTION_SECRET +# +# openssl aes-256-cbc -k "secret-key" -in buildscripts/profile/NetNewsWire.provisionprofile -out buildscripts/profile/NetNewsWire.provisionprofile.enc -a +# openssl aes-256-cbc -k "$ENCRYPTION_SECRET" -in buildscripts/profile/NetNewsWire.provisionprofile.enc -d -a -out buildscripts/profile/NetNewsWire.provisionprofile openssl aes-256-cbc -k "$ENCRYPTION_SECRET" -in buildscripts/profile/NetNewsWireiOS.mobileprovision.enc -d -a -out buildscripts/profile/NetNewsWireiOS.mobileprovision openssl aes-256-cbc -k "$ENCRYPTION_SECRET" -in buildscripts/certs/mac-dist.cer.enc -d -a -out buildscripts/certs/mac-dist.cer