mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Update to latest RSCore
This commit is contained in:
@@ -48,7 +48,7 @@ struct ArticleRenderer {
|
||||
private extension ArticleRenderer {
|
||||
|
||||
private var articleHTML: String {
|
||||
let body = RSMacroProcessor.renderedText(withTemplate: template(), substitutions: substitutions(), macroStart: "[[", macroEnd: "]]")
|
||||
let body = try! MacroProcessor.renderedText(withTemplate: template(), substitutions: substitutions())
|
||||
return renderHTML(withBody: body)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ struct ArticleStyle: Equatable {
|
||||
|
||||
self.path = path
|
||||
|
||||
let isFolder = FileManager.default.rs_fileIsFolder(path)
|
||||
let isFolder = FileManager.default.isFolder(atPath: path)
|
||||
|
||||
if isFolder {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ private let styleSuffixes = [styleSuffix, nnwStyleSuffix, cssStyleSuffix];
|
||||
final class ArticleStylesManager {
|
||||
|
||||
static let shared = ArticleStylesManager()
|
||||
private let folderPath = RSDataSubfolder(nil, stylesFolderName)!
|
||||
private let folderPath = Platform.dataSubfolder(forApplication: nil, folderName: stylesFolderName)!
|
||||
|
||||
var currentStyleName: String {
|
||||
get {
|
||||
@@ -133,7 +133,7 @@ final class ArticleStylesManager {
|
||||
|
||||
private func allStylePaths(_ folder: String) -> [String] {
|
||||
|
||||
let filepaths = FileManager.default.rs_filepaths(inFolder: folder)
|
||||
let filepaths = FileManager.default.filePaths(inFolder: folder)!
|
||||
return filepaths.filter { fileAtPathIsStyle($0) }
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ private func filenameWithStyleSuffixRemoved(_ filename: String) -> String {
|
||||
|
||||
for oneSuffix in styleSuffixes {
|
||||
if filename.hasSuffix(oneSuffix) {
|
||||
return (filename as NSString).rs_string(byStrippingSuffix: oneSuffix, caseSensitive: false)
|
||||
return filename.stripping(suffix: oneSuffix)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ private extension SendToMarsEditCommand {
|
||||
let body = article.contentHTML ?? article.contentText ?? article.summary
|
||||
let authorName = article.authors?.first?.name
|
||||
|
||||
let sender = SendToBlogEditorApp(targetDesciptor: targetDescriptor, title: article.title, body: body, summary: article.summary, link: article.externalURL, permalink: article.url, subject: nil, creator: authorName, commentsURL: nil, guid: article.uniqueID, sourceName: article.feed?.nameForDisplay, sourceHomeURL: article.feed?.homePageURL, sourceFeedURL: article.feed?.url)
|
||||
let sender = SendToBlogEditorApp(targetDescriptor: targetDescriptor, title: article.title, body: body, summary: article.summary, link: article.externalURL, permalink: article.url, subject: nil, creator: authorName, commentsURL: nil, guid: article.uniqueID, sourceName: article.feed?.nameForDisplay, sourceHomeURL: article.feed?.homePageURL, sourceFeedURL: article.feed?.url)
|
||||
let _ = sender.send()
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ struct OPMLExporter {
|
||||
|
||||
static func OPMLString(with account: Account, title: String) -> String {
|
||||
|
||||
let escapedTitle = title.rs_stringByEscapingSpecialXMLCharacters()
|
||||
let escapedTitle = title.escapingSpecialXMLCharacters
|
||||
let openingText =
|
||||
"""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -27,7 +27,7 @@ struct OPMLExporter {
|
||||
|
||||
"""
|
||||
|
||||
let middleText = account.OPMLString(indentLevel: 0, strictConformance: true)
|
||||
let middleText = account.OPMLString(indentLevel: 0, allowCustomAttributes: false)
|
||||
|
||||
let closingText =
|
||||
"""
|
||||
|
||||
@@ -23,7 +23,7 @@ extension RSImage {
|
||||
}
|
||||
|
||||
static func scaledForAvatar(_ data: Data) -> RSImage? {
|
||||
let scaledMaxPixelSize = Int(ceil(CGFloat(RSImage.avatarSize) * RSScreen.mainScreenScale))
|
||||
let scaledMaxPixelSize = Int(ceil(CGFloat(RSImage.avatarSize) * RSScreen.maxScreenScale))
|
||||
guard var cgImage = RSImage.scaleImage(data, maxPixelSize: scaledMaxPixelSize) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ final class FaviconDownloader {
|
||||
|
||||
func favicon(withHomePageURL homePageURL: String) -> RSImage? {
|
||||
|
||||
let url = homePageURL.rs_normalizedURL()
|
||||
let url = homePageURL.normalizedURL
|
||||
if homePageURLsWithNoFaviconURL.contains(url) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ final class SingleFaviconDownloader {
|
||||
private let queue: DispatchQueue
|
||||
|
||||
private var diskKey: String {
|
||||
return (faviconURL as NSString).rs_md5Hash()
|
||||
return faviconURL.md5String
|
||||
}
|
||||
|
||||
init(faviconURL: String, homePageURL: String?, diskCache: BinaryDiskCache, queue: DispatchQueue) {
|
||||
@@ -102,7 +102,7 @@ private extension SingleFaviconDownloader {
|
||||
queue.async {
|
||||
|
||||
if let data = self.diskCache[self.diskKey], !data.isEmpty {
|
||||
RSImage.rs_image(with: data, imageResultBlock: callback)
|
||||
RSImage.image(with: data, imageResultBlock: callback)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ private extension SingleFaviconDownloader {
|
||||
|
||||
if let data = data, !data.isEmpty, let response = response, response.statusIsOK, error == nil {
|
||||
self.saveToDisk(data)
|
||||
RSImage.rs_image(with: data, imageResultBlock: callback)
|
||||
RSImage.image(with: data, imageResultBlock: callback)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ private extension ImageDownloader {
|
||||
|
||||
func diskKey(_ url: String) -> String {
|
||||
|
||||
return (url as NSString).rs_md5Hash()
|
||||
return url.md5String
|
||||
}
|
||||
|
||||
func postImageDidBecomeAvailableNotification(_ url: String) {
|
||||
|
||||
@@ -65,8 +65,8 @@ struct TimelineStringFormatter {
|
||||
s = s.replacingOccurrences(of: "\r", with: "")
|
||||
s = s.replacingOccurrences(of: "\t", with: "")
|
||||
s = s.rsparser_stringByDecodingHTMLEntities()
|
||||
s = s.rs_stringByTrimmingWhitespace()
|
||||
s = s.rs_stringWithCollapsedWhitespace()
|
||||
s = s.trimmingWhitespace
|
||||
s = s.collapsingWhitespace
|
||||
|
||||
let maxLength = 1000
|
||||
if s.count < maxLength {
|
||||
@@ -89,9 +89,9 @@ struct TimelineStringFormatter {
|
||||
return cachedBody
|
||||
}
|
||||
var s = body.rsparser_stringByDecodingHTMLEntities()
|
||||
s = s.rs_string(byStrippingHTML: 150)
|
||||
s = s.rs_stringByTrimmingWhitespace()
|
||||
s = s.rs_stringWithCollapsedWhitespace()
|
||||
s = s.strippingHTML(maxCharacters: 150)
|
||||
s = s.trimmingWhitespace
|
||||
s = s.collapsingWhitespace
|
||||
if s == "Comments" { // Hacker News.
|
||||
s = ""
|
||||
}
|
||||
@@ -100,7 +100,7 @@ struct TimelineStringFormatter {
|
||||
}
|
||||
|
||||
static func dateString(_ date: Date) -> String {
|
||||
if NSCalendar.rs_dateIsToday(date) {
|
||||
if Calendar.dateIsToday(date) {
|
||||
return timeFormatter.string(from: date)
|
||||
}
|
||||
return dateFormatter.string(from: date)
|
||||
|
||||
Reference in New Issue
Block a user