From 708e46ed18b185afdc9f2bf66916648f01f41189 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 29 Dec 2017 12:21:19 -0800 Subject: [PATCH] Make progress on showing avatars in the detail view. --- .../MainWindow/Detail/ArticleRenderer.swift | 36 ++++++++++++++----- Evergreen/Resources/styleSheet.css | 10 ++++++ Evergreen/Resources/template.html | 4 ++- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Evergreen/MainWindow/Detail/ArticleRenderer.swift b/Evergreen/MainWindow/Detail/ArticleRenderer.swift index 53251f23b..3e082485b 100644 --- a/Evergreen/MainWindow/Detail/ArticleRenderer.swift +++ b/Evergreen/MainWindow/Detail/ArticleRenderer.swift @@ -167,6 +167,16 @@ class ArticleRenderer { if let feedURL = article.feed?.homePageURL { feedLink = linkWithTextAndClass(feedTitle, feedURL, "feedLink") } + if let feedIcon = article.feed?.iconURL { + let feedIconImage = "" + if let feedURL = article.feed?.homePageURL { + let feedIconImageLink = linkWithText(feedIconImage, feedURL) + feedLink = feedIconImageLink + " " + feedLink + } + else { + feedLink = feedIconImage + " " + feedLink + } + } } d["feedlink"] = feedLink d["feedlink_withfavicon"] = feedLink @@ -181,10 +191,27 @@ class ArticleRenderer { d["date_short"] = shortDate d["byline"] = byline() + d["author_avatar"] = authorAvatar() return d } + private func authorAvatar() -> String { + + guard let authors = article.authors, authors.count == 1, let author = authors.first else { + return "" + } + guard let avatarURL = author.avatarURL else { + return "" + } + + var imageTag = "" + if let authorURL = author.url { + imageTag = linkWithText(imageTag, authorURL) + } + return "
\(imageTag)
" + } + private func byline() -> String { guard let authors = article.authors ?? article.feed?.authors, !authors.isEmpty else { @@ -221,15 +248,8 @@ class ArticleRenderer { } } - byline = "By " + byline - if authors.count == 1, let author = authors.first { - if let avatarURL = author.avatarURL { - byline = " " + byline - } - } - - return byline + return " • " + byline } private func renderedHTML() -> String { diff --git a/Evergreen/Resources/styleSheet.css b/Evergreen/Resources/styleSheet.css index b187e62bb..f2c18fc2b 100644 --- a/Evergreen/Resources/styleSheet.css +++ b/Evergreen/Resources/styleSheet.css @@ -31,6 +31,16 @@ a:hover { #articleDescription { line-height: 1.5em; } +#authorAvatar { + margin-top: 2em; + text-align: left; +} +#authorAvatar img { + border-radius: 5px; +} +.feedIcon { + border-radius: 5px; +} h1 { line-height: 1.15em; font-weight: medium; diff --git a/Evergreen/Resources/template.html b/Evergreen/Resources/template.html index 4aaf20969..e009a1b1b 100644 --- a/Evergreen/Resources/template.html +++ b/Evergreen/Resources/template.html @@ -1,3 +1,5 @@ -
[[feedlink_withfavicon]] •
+
[[feedlink_withfavicon]] [[byline]]
+

[[newsitem_title]]

[[newsitem_description]]
+