mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-30 01:10:38 +00:00
Add thumbnail storage.
This commit is contained in:
1 parent
3838725d0d
commit
2c17fb77c9
13 files changed
+23
-5
No files matched your search
@@ -838,7 +838,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
let longTitle = "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
|
||||
let prototypeID = "prototype"
|
||||
let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date())
|
||||
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, markdown: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, datePublished: nil, dateModified: nil, authors: nil, attachments: nil, status: status)
|
||||
let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, markdown: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, thumbnailURL: nil, datePublished: nil, dateModified: nil, authors: nil, attachments: nil, status: status)
|
||||
|
||||
let prototypeCellData = TimelineCellData(article: prototypeArticle, showFeedName: .feed, feedName: "Prototype Feed Name", byline: nil, iconImage: nil, showIcon: false)
|
||||
let height = TimelineCellLayout.height(for: 100, cellData: prototypeCellData, appearance: cellAppearance)
|
||||
|
||||
@@ -167,6 +167,7 @@ nonisolated func makeParsedItem(_ articleRecord: CKRecord) -> ParsedItem? {
|
||||
markdown: nil,
|
||||
summary: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.summary] as? String,
|
||||
imageURL: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.imageURL] as? String,
|
||||
thumbnailURL: nil,
|
||||
bannerImageURL: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.imageURL] as? String,
|
||||
datePublished: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.datePublished] as? Date,
|
||||
dateModified: articleRecord[CloudKitArticlesZone.CloudKitArticle.Fields.dateModified] as? Date,
|
||||
|
||||
@@ -982,7 +982,7 @@ private extension FeedbinAccountDelegate {
|
||||
|
||||
let parsedItems: [ParsedItem] = entries.map { entry in
|
||||
let authors = Set([ParsedAuthor(name: entry.authorName, url: entry.jsonFeed?.jsonFeedAuthor?.url, avatarURL: entry.jsonFeed?.jsonFeedAuthor?.avatarURL, emailAddress: nil)])
|
||||
return ParsedItem(syncServiceID: String(entry.articleID), uniqueID: String(entry.articleID), feedURL: String(entry.feedID), url: entry.url, externalURL: entry.jsonFeed?.jsonFeedExternalURL, title: entry.title, language: nil, contentHTML: entry.contentHTML, contentText: nil, markdown: nil, summary: entry.summary, imageURL: nil, bannerImageURL: nil, datePublished: entry.parsedDatePublished, dateModified: nil, authors: authors, tags: nil, attachments: nil)
|
||||
return ParsedItem(syncServiceID: String(entry.articleID), uniqueID: String(entry.articleID), feedURL: String(entry.feedID), url: entry.url, externalURL: entry.jsonFeed?.jsonFeedExternalURL, title: entry.title, language: nil, contentHTML: entry.contentHTML, contentText: nil, markdown: nil, summary: entry.summary, imageURL: nil, thumbnailURL: nil, bannerImageURL: nil, datePublished: entry.parsedDatePublished, dateModified: nil, authors: authors, tags: nil, attachments: nil)
|
||||
}
|
||||
|
||||
return Set(parsedItems)
|
||||
|
||||
@@ -290,6 +290,7 @@ struct FeedlyEntryParser {
|
||||
markdown: nil,
|
||||
summary: summary,
|
||||
imageURL: nil,
|
||||
thumbnailURL: nil,
|
||||
bannerImageURL: nil,
|
||||
datePublished: datePublished,
|
||||
dateModified: dateModified,
|
||||
|
||||
+1
-1
@@ -259,7 +259,7 @@ import os
|
||||
|
||||
let parsedItems: [ParsedItem] = stories.map { story in
|
||||
let author = Set([ParsedAuthor(name: story.authorName, url: nil, avatarURL: nil, emailAddress: nil)])
|
||||
return ParsedItem(syncServiceID: story.storyID, uniqueID: String(story.storyID), feedURL: String(story.feedID), url: story.url, externalURL: nil, title: story.title, language: nil, contentHTML: story.contentHTML, contentText: nil, markdown: nil, summary: nil, imageURL: story.imageURL, bannerImageURL: nil, datePublished: story.datePublished, dateModified: nil, authors: author, tags: Set(story.tags ?? []), attachments: nil)
|
||||
return ParsedItem(syncServiceID: story.storyID, uniqueID: String(story.storyID), feedURL: String(story.feedID), url: story.url, externalURL: nil, title: story.title, language: nil, contentHTML: story.contentHTML, contentText: nil, markdown: nil, summary: nil, imageURL: story.imageURL, thumbnailURL: nil, bannerImageURL: nil, datePublished: story.datePublished, dateModified: nil, authors: author, tags: Set(story.tags ?? []), attachments: nil)
|
||||
}
|
||||
|
||||
return Set(parsedItems)
|
||||
|
||||
@@ -1154,6 +1154,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
markdown: nil,
|
||||
summary: entry.summary.content,
|
||||
imageURL: nil,
|
||||
thumbnailURL: nil,
|
||||
bannerImageURL: nil,
|
||||
datePublished: entry.parseDatePublished(),
|
||||
dateModified: nil,
|
||||
|
||||
@@ -24,13 +24,14 @@ public final class Article: Hashable, Sendable {
|
||||
public let rawExternalLink: String? // We store raw source value, but use computed externalURL or externalLink other than where raw value required.
|
||||
public let summary: String?
|
||||
public let rawImageLink: String? // We store raw source value, but use computed imageURL or imageLink other than where raw value required.
|
||||
public let rawThumbnailLink: String? // We store raw source value, but use computed thumbnailURL or thumbnailLink other than where raw value required.
|
||||
public let datePublished: Date?
|
||||
public let dateModified: Date?
|
||||
public let authors: Set<Author>?
|
||||
public let attachments: Set<Attachment>?
|
||||
public let status: ArticleStatus
|
||||
|
||||
public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, markdown: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set<Author>?, attachments: Set<Attachment>?, status: ArticleStatus) {
|
||||
public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, markdown: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, thumbnailURL: String?, datePublished: Date?, dateModified: Date?, authors: Set<Author>?, attachments: Set<Attachment>?, status: ArticleStatus) {
|
||||
self.accountID = accountID
|
||||
self.feedID = feedID
|
||||
self.uniqueID = uniqueID
|
||||
@@ -42,6 +43,7 @@ public final class Article: Hashable, Sendable {
|
||||
self.rawExternalLink = externalURL
|
||||
self.summary = summary
|
||||
self.rawImageLink = imageURL
|
||||
self.rawThumbnailLink = thumbnailURL
|
||||
self.datePublished = datePublished
|
||||
self.dateModified = dateModified
|
||||
self.authors = authors
|
||||
@@ -68,7 +70,7 @@ public final class Article: Hashable, Sendable {
|
||||
// MARK: - Equatable
|
||||
|
||||
static public func ==(lhs: Article, rhs: Article) -> Bool {
|
||||
return lhs.articleID == rhs.articleID && lhs.accountID == rhs.accountID && lhs.feedID == rhs.feedID && lhs.uniqueID == rhs.uniqueID && lhs.title == rhs.title && lhs.contentHTML == rhs.contentHTML && lhs.contentText == rhs.contentText && lhs.markdown == rhs.markdown && lhs.rawLink == rhs.rawLink && lhs.rawExternalLink == rhs.rawExternalLink && lhs.summary == rhs.summary && lhs.rawImageLink == rhs.rawImageLink && lhs.datePublished == rhs.datePublished && lhs.dateModified == rhs.dateModified && lhs.authors == rhs.authors && lhs.attachments == rhs.attachments
|
||||
return lhs.articleID == rhs.articleID && lhs.accountID == rhs.accountID && lhs.feedID == rhs.feedID && lhs.uniqueID == rhs.uniqueID && lhs.title == rhs.title && lhs.contentHTML == rhs.contentHTML && lhs.contentText == rhs.contentText && lhs.markdown == rhs.markdown && lhs.rawLink == rhs.rawLink && lhs.rawExternalLink == rhs.rawExternalLink && lhs.summary == rhs.summary && lhs.rawImageLink == rhs.rawImageLink && lhs.rawThumbnailLink == rhs.rawThumbnailLink && lhs.datePublished == rhs.datePublished && lhs.dateModified == rhs.dateModified && lhs.authors == rhs.authors && lhs.attachments == rhs.attachments
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ extension Article {
|
||||
return URL.encodeSpacesIfNeeded(rawImageLink)
|
||||
}
|
||||
|
||||
var thumbnailURL: URL? {
|
||||
URL.encodeSpacesIfNeeded(rawThumbnailLink)
|
||||
}
|
||||
|
||||
var link: String? {
|
||||
// Prefer link from URL, if one can be created, as these are repaired if required.
|
||||
// Provide the raw link if URL creation fails.
|
||||
@@ -70,6 +74,10 @@ extension Article {
|
||||
return imageURL?.absoluteString ?? rawImageLink
|
||||
}
|
||||
|
||||
var thumbnailLink: String? {
|
||||
thumbnailURL?.absoluteString ?? rawThumbnailLink
|
||||
}
|
||||
|
||||
var preferredLink: String? {
|
||||
if let link = link, !link.isEmpty {
|
||||
return link
|
||||
|
||||
@@ -394,6 +394,7 @@ import XCTest
|
||||
externalURL: nil,
|
||||
summary: nil,
|
||||
imageURL: nil,
|
||||
thumbnailURL: nil,
|
||||
datePublished: date,
|
||||
dateModified: nil,
|
||||
authors: nil,
|
||||
|
||||
@@ -118,6 +118,7 @@ import XCTest
|
||||
externalURL: nil,
|
||||
summary: nil,
|
||||
imageURL: nil,
|
||||
thumbnailURL: nil,
|
||||
datePublished: Date(),
|
||||
dateModified: nil,
|
||||
authors: nil,
|
||||
|
||||
@@ -230,6 +230,7 @@ import Testing
|
||||
externalURL: nil,
|
||||
summary: nil,
|
||||
imageURL: nil,
|
||||
thumbnailURL: nil,
|
||||
datePublished: Date(),
|
||||
dateModified: nil,
|
||||
authors: nil,
|
||||
|
||||
@@ -52,6 +52,7 @@ import XCTest
|
||||
externalURL: nil,
|
||||
summary: nil,
|
||||
imageURL: nil,
|
||||
thumbnailURL: nil,
|
||||
datePublished: nil,
|
||||
dateModified: nil,
|
||||
authors: nil,
|
||||
|
||||
@@ -32,6 +32,7 @@ class TimelineCustomizerCollectionViewController: UICollectionViewController {
|
||||
externalURL: nil,
|
||||
summary: nil,
|
||||
imageURL: nil,
|
||||
thumbnailURL: nil,
|
||||
datePublished: date,
|
||||
dateModified: nil,
|
||||
authors: Set([Author(authorID: "_testAuthorID", name: "J. R. R. Tolkien", url: nil, avatarURL: nil, emailAddress: nil)!]),
|
||||
|
||||
Reference in new issue
Block a user