mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 00:04:25 +00:00
Adds Miniflux as a first-class account type alongside Feedbin, Feedly,
NewsBlur, and Reader API accounts, on both macOS and iOS.
Refreshes are incremental: the changed_after parameter means read and
starred status ride along with the entries in a single pass instead of
needing separate status scans. Articles missing locally are backfilled by
ID via GET /v1/entries/{id}; a 404 means the entry is gone server-side, so
its statuses are deleted and it is not requested again on every refresh.
Starred changes go out as idempotent batch updates.
Requires Miniflux 2.0.49 or newer. The server version is detected at
runtime via GET /v1/version and persisted in AccountSettings. Servers
older than 2.3.2 have no /v1/entries/ids and no batch starred updates, so
those paths fall back transparently to paged /v1/entries and per-entry
bookmark toggles.
Both HTTP Basic and API-token authentication are supported, selectable in
the account sheet on either platform. Entered URLs are normalized (scheme
added, trailing slash and /v1 suffix stripped), and adding a second
account for a server that already has one is rejected.
Tests cover folder sync, model decoding, version parsing, the pre-2.3.2
fallback paths, and duplicate-endpoint detection, with JSON fixtures for
the API responses.
The runtime version detection and the duplicate-endpoint check were
informed by IngmarStein's independent Miniflux implementation in #5335.
Written with help from Claude Code.
Co-Authored-By: Ingmar Stein <490610+IngmarStein@users.noreply.github.com>
228 lines
11 KiB
Swift
228 lines
11 KiB
Swift
//
|
||
// Assets.swift
|
||
// NetNewsWire
|
||
//
|
||
// Created by Brent Simmons on 11/18/25.
|
||
// Copyright © 2025 Ranchero Software. All rights reserved.
|
||
//
|
||
|
||
import Foundation
|
||
|
||
#if canImport(UIKit)
|
||
import UIKit
|
||
#endif
|
||
|
||
import RSCore
|
||
import Account
|
||
import Images
|
||
|
||
#if os(macOS)
|
||
typealias RSColor = NSColor
|
||
#else
|
||
typealias RSColor = UIColor
|
||
#endif
|
||
|
||
struct Assets {
|
||
@MainActor struct Images {
|
||
static var accountBazQux: RSImage { RSImage(named: "accountBazQux")! }
|
||
static var accountCloudKit: RSImage { RSImage(named: "accountCloudKit")! }
|
||
static var accountFeedbin: RSImage { RSImage(named: "accountFeedbin")! }
|
||
static var accountFeedly: RSImage { RSImage(named: "accountFeedly")! }
|
||
static var accountFreshRSS: RSImage { RSImage(named: "accountFreshRSS")! }
|
||
static var accountInoreader: RSImage { RSImage(named: "accountInoreader")! }
|
||
static var accountMiniflux: RSImage { RSImage(named: "accountMiniflux")! }
|
||
static var accountNewsBlur: RSImage { RSImage(named: "accountNewsBlur")! }
|
||
static var accountTheOldReader: RSImage { RSImage(named: "accountTheOldReader")! }
|
||
|
||
static let starOpen = RSImage(symbol: "star")!
|
||
static let starClosed = RSImage(symbol: "star.fill")!
|
||
static let copy = RSImage(symbol: "document.on.document")
|
||
static var markAllAsRead: RSImage { RSImage(named: "markAllAsRead")! }
|
||
static let nextUnread = RSImage(symbol: "chevron.down.circle")!
|
||
|
||
nonisolated static var nnwFeedIcon: RSImage { RSImage(named: "nnwFeedIcon")! }
|
||
static var faviconTemplate: RSImage { RSImage(named: "faviconTemplateImage")! }
|
||
|
||
static let articleExtractorOff: RSImage = RSImage(symbol: "text.page")!
|
||
static let articleExtractorOn: RSImage = RSImage(symbol: "text.page.fill")!
|
||
static let articleExtractorError: RSImage = RSImage(symbol: "text.page.slash")!
|
||
static let share = RSImage(symbol: "square.and.arrow.up")!
|
||
static let folder = RSImage(symbol: "folder")!
|
||
static let starredFeed = IconImage(starClosed, isSymbol: true, isBackgroundSuppressed: true, preferredColor: Assets.Colors.star)
|
||
static var preferencesToolbarAppearance: RSImage { RSImage(named: "preferencesToolbarAppearance")! }
|
||
|
||
#if os(macOS)
|
||
static var accountLocal: RSImage { RSImage(named: "accountLocal")! }
|
||
static let addNewSidebarItem = RSImage(symbol: "plus")!
|
||
static let articleTheme = RSImage(symbol: "doc.richtext")!
|
||
static let cleanUp = RSImage(symbol: "bubbles.and.sparkles")!
|
||
static var marsEdit: RSImage { RSImage(named: "MarsEditIcon")! }
|
||
static var microblog: RSImage { RSImage(named: "MicroblogIcon")! }
|
||
static let filterActive = RSImage(symbol: "line.horizontal.3.decrease.circle.fill")!
|
||
static let filterInactive = RSImage(symbol: "line.horizontal.3.decrease.circle")!
|
||
static let openInBrowser = RSImage(symbol: "safari")!
|
||
static let preferencesToolbarAccounts = RSImage(symbol: "at")!
|
||
static let preferencesToolbarGeneral = RSImage(symbol: "gearshape")!
|
||
static let preferencesToolbarTimeline = RSImage(symbol: "list.bullet.rectangle")!
|
||
static let preferencesToolbarAdvanced = RSImage(symbol: "gearshape.2")!
|
||
static let readClosed = RSImage(symbol: "largecircle.fill.circle")!
|
||
static let readOpen = RSImage(symbol: "circle")!
|
||
static let refresh = RSImage(symbol: "arrow.clockwise")!
|
||
static let swipeMarkUnstarred = RSImage(symbol: "star")!
|
||
static var timelineStar: RSImage { RSImage(named: "timelineStar")! }
|
||
static var markBelowAsRead: RSImage { RSImage(named: "markBelowAsRead")! }
|
||
static var markAboveAsRead: RSImage { RSImage(named: "markAboveAsRead")! }
|
||
static let searchFeed = IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true, isBackgroundSuppressed: true)
|
||
static let swipeMarkStarred = RSImage(systemSymbolName: "star.fill", accessibilityDescription: "Star")!
|
||
static let swipeMarkRead = RSImage(systemSymbolName: "circle", accessibilityDescription: "Mark Read")!
|
||
static let swipeMarkUnread = RSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: "Mark Unread")!
|
||
static let mainFolder = IconImage(folder, isSymbol: true, isBackgroundSuppressed: true, preferredColor: Assets.Colors.primaryAccent)
|
||
static let todayFeed = IconImage(RSImage(symbol: "sun.max.fill")!, isSymbol: true, isBackgroundSuppressed: true, preferredColor: NSColor.orange)
|
||
static let unreadFeed = IconImage(RSImage(symbol: "largecircle.fill.circle")!, isSymbol: true, isBackgroundSuppressed: true, preferredColor: Assets.Colors.primaryAccent)
|
||
|
||
#else // iOS
|
||
static var accountLocalPadImage: RSImage { RSImage(named: "accountLocalPad")! }
|
||
static var accountLocalPhoneImage: RSImage { RSImage(named: "accountLocalPhone")! }
|
||
static var timelinePreviewThumbnail: RSImage { RSImage(named: "timelinePreviewThumbnail")! }
|
||
|
||
static let circleClosed = RSImage(symbol: "largecircle.fill.circle")!
|
||
static let markBelowAsRead = RSImage(symbol: "arrowtriangle.down.circle")!
|
||
static let markAboveAsRead = RSImage(symbol: "arrowtriangle.up.circle")!
|
||
static let more = RSImage(symbol: "ellipsis.circle")!
|
||
static let nextArticle = RSImage(symbol: "chevron.down")!
|
||
static let circleOpen = RSImage(symbol: "circle")!
|
||
static var disclosure: RSImage { RSImage(named: "disclosure")! }
|
||
static let deactivate = RSImage(symbol: "minus.circle")!
|
||
static let currentActivity = RSImage(symbol: "text.pad.header")!
|
||
static let edit = RSImage(symbol: "square.and.pencil")!
|
||
static let filter = RSImage(symbol: "line.3.horizontal.decrease")!
|
||
static let folderOutlinePlus = RSImage(symbol: "folder.badge.plus")!
|
||
static let info = RSImage(symbol: "info.circle")!
|
||
static let plus = RSImage(symbol: "plus")!
|
||
static let prevArticle = RSImage(symbol: "chevron.up")!
|
||
static let openInSidebar = RSImage(symbol: "arrow.turn.down.left")!
|
||
static let safari = RSImage(symbol: "safari")!
|
||
static let smartFeed = RSImage(symbol: "gear")!
|
||
static let trash = RSImage(symbol: "trash")!
|
||
|
||
static let settingsSystemSettings = RSImage(symbol: "gear")!
|
||
static let settingsImportSubscriptions = RSImage(symbol: "square.and.arrow.down")!
|
||
static let settingsExportSubscriptions = RSImage(symbol: "square.and.arrow.up")!
|
||
static var settingsSidebar: RSImage { RSImage(named: "settingsSidebar")! }
|
||
static var settingsTimeline: RSImage { RSImage(named: "settingsTimeline")! }
|
||
static var settingsArticles: RSImage { RSImage(named: "settingsArticles")! }
|
||
static let settingsErrorLog = RSImage(symbol: "exclamationmark.triangle")!
|
||
static let settingsActivityLog = RSImage(symbol: "clock.arrow.circlepath")!
|
||
static let settingsAccountStats = RSImage(symbol: "chart.bar")!
|
||
static let settingsDinosaurs: RSImage = {
|
||
let emoji = "🦖" as NSString
|
||
let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: settingsEmojiFontSize)]
|
||
let emojiSize = emoji.size(withAttributes: attributes)
|
||
// Template, mirrored so the dinosaur faces the row’s text.
|
||
let image = UIGraphicsImageRenderer(size: settingsIconSize).image { context in
|
||
context.cgContext.translateBy(x: settingsIconSize.width, y: 0.0)
|
||
context.cgContext.scaleBy(x: -1.0, y: 1.0)
|
||
let origin = CGPoint(x: (settingsIconSize.width - emojiSize.width) / 2.0, y: (settingsIconSize.height - emojiSize.height) / 2.0)
|
||
emoji.draw(at: origin, withAttributes: attributes)
|
||
}
|
||
return image.withRenderingMode(.alwaysTemplate)
|
||
}()
|
||
static let settingsCloudKitStats = RSImage(symbol: "icloud")!
|
||
static let settingsHelp = RSImage(symbol: "questionmark.circle")!
|
||
static let settingsForum = RSImage(symbol: "bubble.left.and.bubble.right")!
|
||
static let settingsThemesGallery = RSImage(symbol: "paintpalette")!
|
||
static let settingsReleaseNotes = RSImage(symbol: "doc.text")!
|
||
static let settingsBugTracker = RSImage(symbol: "ant")!
|
||
static let settingsNetNewsWireNewsFeed: RSImage = {
|
||
let rect = CGRect(origin: .zero, size: settingsIconSize)
|
||
return UIGraphicsImageRenderer(size: settingsIconSize).image { _ in
|
||
UIBezierPath(roundedRect: rect, cornerRadius: settingsIconCornerRadius).addClip()
|
||
nnwFeedIcon.draw(in: rect)
|
||
}
|
||
}()
|
||
static let settingsIconSize = CGSize(width: 22, height: 22)
|
||
private static let settingsIconCornerRadius = 5.0
|
||
private static let settingsEmojiFontSize = 21.0
|
||
|
||
static let searchFeed = IconImage(RSImage(symbol: "magnifyingglass")!, isSymbol: true)
|
||
static let mainFolder = IconImage(folder, isSymbol: true, isBackgroundSuppressed: true, preferredColor: Assets.Colors.primaryAccent)
|
||
static let todayFeed = IconImage(RSImage(symbol: "sun.max.fill")!, isSymbol: true, isBackgroundSuppressed: true, preferredColor: UIColor.systemOrange)
|
||
static let unreadFeed = IconImage(RSImage(symbol: "largecircle.fill.circle")!, isSymbol: true, isBackgroundSuppressed: true, preferredColor: Assets.Colors.secondaryAccent)
|
||
static var timelineStar: RSImage {
|
||
let image = RSImage(symbol: "star.fill")!
|
||
return image.withTintColor(Assets.Colors.star, renderingMode: .alwaysOriginal)
|
||
}
|
||
static let unreadCellIndicator = IconImage(RSImage(symbol: "circle.fill")!, isSymbol: true, isBackgroundSuppressed: true, preferredColor: Assets.Colors.secondaryAccent)
|
||
#endif
|
||
}
|
||
|
||
@MainActor static func accountImage(_ accountType: AccountType) -> RSImage {
|
||
switch accountType {
|
||
case .onMyMac:
|
||
#if os(macOS)
|
||
return Assets.Images.accountLocal
|
||
#else // iOS
|
||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||
return Assets.Images.accountLocalPadImage
|
||
} else {
|
||
return Assets.Images.accountLocalPhoneImage
|
||
}
|
||
#endif
|
||
case .cloudKit:
|
||
return Assets.Images.accountCloudKit
|
||
case .bazQux:
|
||
return Assets.Images.accountBazQux
|
||
case .feedbin:
|
||
return Assets.Images.accountFeedbin
|
||
case .feedly:
|
||
return Assets.Images.accountFeedly
|
||
case .freshRSS:
|
||
return Assets.Images.accountFreshRSS
|
||
case .inoreader:
|
||
return Assets.Images.accountInoreader
|
||
case .miniflux:
|
||
return Assets.Images.accountMiniflux
|
||
case .newsBlur:
|
||
return Assets.Images.accountNewsBlur
|
||
case .theOldReader:
|
||
return Assets.Images.accountTheOldReader
|
||
}
|
||
}
|
||
|
||
@MainActor struct Colors {
|
||
#if os(macOS)
|
||
static let primaryAccent = RSColor(named: "AccentColor")!
|
||
/// Behind icons that wouldn’t otherwise stand out from the background.
|
||
static let iconBackground = NSColor.tertiarySystemFill
|
||
static let star = RSColor(named: "StarColor")!
|
||
static let sidebarUnreadCountBackground = RSColor(named: "SidebarUnreadCountBackground")!
|
||
static let sidebarUnreadCountText = RSColor(named: "SidebarUnreadCountText")!
|
||
/// A faint gray, shown until a timeline thumbnail arrives.
|
||
static let thumbnailPlaceholder = NSColor.tertiarySystemFill
|
||
#else // iOS
|
||
static let primaryAccent = RSColor(named: "primaryAccentColor")!
|
||
static let secondaryAccent = RSColor(named: "secondaryAccentColor")!
|
||
static let star = RSColor(named: "starColor")!
|
||
static let vibrantText = RSColor(named: "vibrantTextColor")!
|
||
static let controlBackground = RSColor(named: "controlBackgroundColor")!
|
||
/// Behind icons that wouldn’t otherwise stand out from the background.
|
||
static let iconBackground = UIColor.quaternarySystemFill
|
||
static let fullScreenBackground = RSColor(named: "fullScreenBackgroundColor")!
|
||
static let sectionHeader = RSColor(named: "sectionHeaderColor")!
|
||
/// A faint gray, shown until a timeline thumbnail arrives.
|
||
static let thumbnailPlaceholder = UIColor.quaternarySystemFill
|
||
#endif
|
||
}
|
||
}
|
||
|
||
extension RSImage {
|
||
|
||
convenience init?(symbol: String) {
|
||
#if os(macOS)
|
||
self.init(systemSymbolName: symbol, accessibilityDescription: nil)
|
||
#else // iOS
|
||
self.init(systemName: symbol)
|
||
#endif
|
||
}
|
||
}
|