diff --git a/Mac/MainWindow/Detail/DetailIconSchemeHandler.swift b/Mac/MainWindow/Detail/DetailIconSchemeHandler.swift index 39c2904da..9b18aa1f5 100644 --- a/Mac/MainWindow/Detail/DetailIconSchemeHandler.swift +++ b/Mac/MainWindow/Detail/DetailIconSchemeHandler.swift @@ -16,7 +16,7 @@ final class DetailIconSchemeHandler: NSObject, WKURLSchemeHandler { func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) { - guard let responseURL = urlSchemeTask.request.url, let iconImage = self.currentArticle?.iconImage() else { + guard let responseURL = urlSchemeTask.request.url, let iconImage = self.currentArticle?.articleViewIconImage() else { urlSchemeTask.didFailWithError(URLError(.fileDoesNotExist)) return } diff --git a/Shared/ArticleStyles/ArticleTheme.swift b/Shared/ArticleStyles/ArticleTheme.swift index e99a92f8d..e628d8650 100644 --- a/Shared/ArticleStyles/ArticleTheme.swift +++ b/Shared/ArticleStyles/ArticleTheme.swift @@ -43,11 +43,15 @@ struct ArticleTheme: Equatable, Sendable { return String(describing: info?.version ?? 0) } + var usesGrayscaleIcon: Bool { + info?.grayscaleIcon ?? false + } + private let info: ArticleThemePlist? init() { self.url = nil - self.info = ArticleThemePlist(name: "Article Theme", themeIdentifier: "com.ranchero.netnewswire.theme.article", creatorHomePage: "https://netnewswire.com/", creatorName: "Ranchero Software", version: 1) + self.info = ArticleThemePlist(name: "Article Theme", themeIdentifier: "com.ranchero.netnewswire.theme.article", creatorHomePage: "https://netnewswire.com/", creatorName: "Ranchero Software", version: 1, grayscaleIcon: nil) let corePath = Bundle.main.path(forResource: "core", ofType: "css")! let stylesheetPath = Bundle.main.path(forResource: "stylesheet", ofType: "css")! diff --git a/Shared/ArticleStyles/ArticleThemePlist.swift b/Shared/ArticleStyles/ArticleThemePlist.swift index bac3ac888..aff5b713e 100644 --- a/Shared/ArticleStyles/ArticleThemePlist.swift +++ b/Shared/ArticleStyles/ArticleThemePlist.swift @@ -14,6 +14,7 @@ public struct ArticleThemePlist: Codable, Equatable, Sendable { public let creatorHomePage: String public let creatorName: String public let version: Int + public let grayscaleIcon: Bool? enum CodingKeys: String, CodingKey { case name = "Name" @@ -21,5 +22,6 @@ public struct ArticleThemePlist: Codable, Equatable, Sendable { case creatorHomePage = "CreatorHomePage" case creatorName = "CreatorName" case version = "Version" + case grayscaleIcon = "grayscaleIcon" } } diff --git a/Shared/Extensions/ArticleUtilities.swift b/Shared/Extensions/ArticleUtilities.swift index fcc94db88..59d2a3c30 100644 --- a/Shared/Extensions/ArticleUtilities.swift +++ b/Shared/Extensions/ArticleUtilities.swift @@ -107,6 +107,14 @@ extension Article { return IconImageCache.shared.imageForArticle(self) } + /// Grayscale when the current theme’s Info.plist sets `grayscaleIcon`. + func articleViewIconImage() -> IconImage? { + guard let iconImage = iconImage() else { + return nil + } + return ArticleThemesManager.shared.currentTheme.usesGrayscaleIcon ? iconImage.grayscaleIconImage : iconImage + } + /// True when an icon notification is about an icon this article might show: /// its feed’s icon, or one of its authors’ avatars. func mightShowIcon(in notification: Notification) -> Bool { diff --git a/Technotes/Themes.md b/Technotes/Themes.md index 2e14b9d5c..c2566a542 100644 --- a/Technotes/Themes.md +++ b/Technotes/Themes.md @@ -19,7 +19,13 @@ The `Info.plist` requires the following keys/types: |`CreatorName`|`String`|| |`Version`|`Integer`|| -These keys are optional. They fill in the theme's Get Info window in the Finder, and NetNewsWire ignores them: +This key is optional: + +|Key|Type|Notes| +|---|---|---| +|`grayscaleIcon`|`Boolean`|When `true`, the feed icon or author avatar in the article view is grayscale.| + +These keys are optional too. They fill in the theme's Get Info window in the Finder, and NetNewsWire ignores them: |Key|Type|Notes| |---|---|---| @@ -35,7 +41,7 @@ The page loads with the article's link as its base URL, else the feed's home pag NetNewsWire 7.3 and later use this file instead of `template.html` when a theme includes it, and older versions ignore it. Put `[[primary_media]]` and `[[enclosures]]` here, since older versions would show them as literal text. [Verdana Revival](../Themes/Verdana%20Revival.nnwtheme/template7.3.html) is an example. ### stylesheet.css -This provides a starting point for editing the style of the page. +This provides a starting point for editing the style of the page. ## Article Media diff --git a/iOS/Article/ArticleIconSchemeHandler.swift b/iOS/Article/ArticleIconSchemeHandler.swift index 7633f619f..0c4c09c2c 100644 --- a/iOS/Article/ArticleIconSchemeHandler.swift +++ b/iOS/Article/ArticleIconSchemeHandler.swift @@ -29,7 +29,7 @@ final class ArticleIconSchemeHandler: NSObject, WKURLSchemeHandler { return } let articleID = components.path - guard let iconImage = coordinator.articleFor(articleID)?.iconImage() else { + guard let iconImage = coordinator.articleFor(articleID)?.articleViewIconImage() else { urlSchemeTask.didFailWithError(URLError(.fileDoesNotExist)) return }