From 4295b029a5125221d2ad8f347e19e420dae03b81 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Mon, 16 May 2022 09:29:39 -0700 Subject: [PATCH] use site name to display site on feed and grid cards --- .../CoreDataModel.xcdatamodel/contents | 3 ++- apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift | 4 ++-- .../Services/DataService/Queries/ArticleContentQuery.swift | 1 + .../Services/DataService/Queries/LibraryItemsQuery.swift | 1 + .../Sources/Services/InternalModels/InternalLinkedItem.swift | 3 +++ apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift | 2 +- .../OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift | 2 +- 7 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents b/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents index 183be56df..3556a931c 100644 --- a/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents +++ b/apple/OmnivoreKit/Sources/Models/CoreData/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents @@ -38,6 +38,7 @@ + @@ -85,7 +86,7 @@ - + diff --git a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift index c6b8421a3..27bfc1144 100644 --- a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift +++ b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift @@ -45,8 +45,8 @@ public extension LinkedItem { return (pageURLString ?? "").hasSuffix("pdf") } - var publisherHostname: String? { - URL(string: publisherURLString ?? pageURLString ?? "")?.host + var publisherDisplayName: String? { + siteName ?? URL(string: publisherURLString ?? pageURLString ?? "")?.host } var imageURL: URL? { diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift index b4ec3ffbe..bbea73ead 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ArticleContentQuery.swift @@ -105,6 +105,7 @@ extension DataService { pageURLString: try $0.url(), descriptionText: try $0.description(), publisherURLString: try $0.originalArticleUrl(), + siteName: try $0.siteName(), author: try $0.author(), publishDate: try $0.publishedAt()?.value, slug: try $0.slug(), diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift index ac6152ac3..3534ce291 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift @@ -95,6 +95,7 @@ private let articleSelection = Selection.Article { pageURLString: try $0.url(), descriptionText: try $0.description(), publisherURLString: try $0.originalArticleUrl(), + siteName: try $0.siteName(), author: try $0.author(), publishDate: try $0.publishedAt()?.value, slug: try $0.slug(), diff --git a/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift b/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift index fb69d1fcb..7214897c9 100644 --- a/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift +++ b/apple/OmnivoreKit/Sources/Services/InternalModels/InternalLinkedItem.swift @@ -15,6 +15,7 @@ struct InternalLinkedItem { let pageURLString: String let descriptionText: String? let publisherURLString: String? + let siteName: String? let author: String? let publishDate: Date? let slug: String @@ -37,6 +38,7 @@ struct InternalLinkedItem { linkedItem.pageURLString = pageURLString linkedItem.descriptionText = descriptionText linkedItem.publisherURLString = publisherURLString + linkedItem.siteName = siteName linkedItem.author = author linkedItem.publishDate = publishDate linkedItem.slug = slug @@ -93,6 +95,7 @@ extension JSONArticle { pageURLString: url, descriptionText: title, publisherURLString: nil, + siteName: nil, author: nil, publishDate: nil, slug: slug, diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index bd1f03cd1..b3fc58521 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -100,7 +100,7 @@ public struct GridCard: View { .lineLimit(1) } - if let publisherURL = item.publisherHostname { + if let publisherURL = item.publisherDisplayName { Text(publisherURL) .font(.appCaptionTwo) .foregroundColor(.appGrayText) diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift index 52a477c39..d8dbea657 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift @@ -26,7 +26,7 @@ public struct FeedCard: View { .lineLimit(1) } - if let publisherURL = item.publisherHostname { + if let publisherURL = item.publisherDisplayName { Text(publisherURL) .font(.appCaption) .foregroundColor(.appGrayText)