Changed how images are placed in Twitter articles so that you can better see who Tweeted the image.

This commit is contained in:
Maurice Parker 2021-07-05 14:24:50 -05:00
parent 2b9d3657e7
commit 893fd8e91f
1 changed files with 3 additions and 17 deletions

View File

@ -48,7 +48,7 @@ final class TwitterStatus: Codable {
func renderAsHTML(topLevel: Bool = true) -> String { func renderAsHTML(topLevel: Bool = true) -> String {
if let retweetedStatus = retweetedStatus { if let retweetedStatus = retweetedStatus {
return renderAsRetweetHTML(retweetedStatus, topLevel: topLevel) return renderAsRetweetHTML(retweetedStatus)
} }
if let quotedStatus = quotedStatus { if let quotedStatus = quotedStatus {
return renderAsQuoteHTML(quotedStatus, topLevel: topLevel) return renderAsQuoteHTML(quotedStatus, topLevel: topLevel)
@ -139,26 +139,17 @@ private extension TwitterStatus {
func renderAsOriginalHTML(topLevel: Bool) -> String { func renderAsOriginalHTML(topLevel: Bool) -> String {
var html = renderAsTweetHTML(self, topLevel: topLevel) var html = renderAsTweetHTML(self, topLevel: topLevel)
if topLevel {
html += extendedEntities?.renderAsHTML() ?? "" html += extendedEntities?.renderAsHTML() ?? ""
html += retweetedStatus?.extendedEntities?.renderAsHTML() ?? ""
html += quotedStatus?.extendedEntities?.renderAsHTML() ?? ""
}
return html return html
} }
func renderAsRetweetHTML(_ status: TwitterStatus, topLevel: Bool) -> String { func renderAsRetweetHTML(_ status: TwitterStatus) -> String {
var html = "<blockquote>" var html = "<blockquote>"
if let userHTML = status.user?.renderAsHTML() { if let userHTML = status.user?.renderAsHTML() {
html += userHTML html += userHTML
} }
html += status.renderAsHTML(topLevel: false) html += status.renderAsHTML(topLevel: false)
html += "</blockquote>" html += "</blockquote>"
if topLevel {
html += status.extendedEntities?.renderAsHTML() ?? ""
html += status.retweetedStatus?.extendedEntities?.renderAsHTML() ?? ""
html += status.quotedStatus?.extendedEntities?.renderAsHTML() ?? ""
}
return html return html
} }
@ -172,11 +163,6 @@ private extension TwitterStatus {
} }
html += quotedStatus.renderAsHTML(topLevel: false) html += quotedStatus.renderAsHTML(topLevel: false)
html += "</blockquote>" html += "</blockquote>"
if topLevel {
html += quotedStatus.extendedEntities?.renderAsHTML() ?? ""
html += quotedStatus.retweetedStatus?.extendedEntities?.renderAsHTML() ?? ""
html += quotedStatus.quotedStatus?.extendedEntities?.renderAsHTML() ?? ""
}
return html return html
} }