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 100823e57e
commit c10aa8412b

View File

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