Added timestamp to retweets

This commit is contained in:
Maurice Parker 2020-04-18 16:27:19 -05:00
parent b31e43419c
commit ac41c7af69
3 changed files with 21 additions and 4 deletions

View File

@ -66,12 +66,21 @@ final class TwitterStatus: Codable {
return renderAsOriginalHTML(topLevel: topLevel)
}
func renderAsTweetHTML(_ status: TwitterStatus) -> String {
return status.displayText ?? ""
func renderAsTweetHTML(_ status: TwitterStatus, topLevel: Bool) -> String {
var html = "<div>\(status.displayText ?? "")</div>"
if !topLevel, let createdAt = status.createdAt {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .short
html += "<div class=\"twitterTimestamp\">\(dateFormatter.string(from: createdAt))</div>"
}
return html
}
func renderAsOriginalHTML(topLevel: Bool) -> String {
var html = renderAsTweetHTML(self)
var html = renderAsTweetHTML(self, topLevel: topLevel)
if topLevel {
html += extendedEntities?.renderAsHTML() ?? ""
}
@ -93,7 +102,7 @@ final class TwitterStatus: Codable {
func renderAsQuoteHTML(_ quotedStatus: TwitterStatus, topLevel: Bool) -> String {
var html = String()
html += renderAsTweetHTML(self)
html += renderAsTweetHTML(self, topLevel: topLevel)
html += "<blockquote>"
if let userHTML = quotedStatus.user?.renderAsHTML() {
html += userHTML

View File

@ -258,6 +258,10 @@ blockquote {
vertical-align: middle;
}
.twitterTimestamp {
font-size: 66%;
}
/*Block ads and junk*/
iframe[src*="feedads"],

View File

@ -287,6 +287,10 @@ blockquote {
vertical-align: middle;
}
.twitterTimestamp {
font-size: 66%;
}
/*Block ads and junk*/
iframe[src*="feedads"],