diff --git a/public/question.css b/public/question.css index adee934..dfe40d8 100644 --- a/public/question.css +++ b/public/question.css @@ -117,13 +117,25 @@ img { cursor: text; } +.comment-top { + display: flex; +} + +.comment-score { + border-right: 1px solid white; + padding-right: .5rem; +} + .comment-body { font-size: 0.95rem; + padding-left: .5rem; } .comment-author { color: var(--muted-text-color); font-size: 0.8rem; + padding-left: 1.5rem; + margin-top: .25rem; } .s-notice { diff --git a/src/types/comment.go b/src/types/comment.go index 118a547..b1a6b68 100644 --- a/src/types/comment.go +++ b/src/types/comment.go @@ -7,4 +7,5 @@ type FilteredComment struct { Timestamp string AuthorName string AuthorURL string + Upvotes string } diff --git a/src/utils/comments.go b/src/utils/comments.go index 15d7ae0..7865aae 100644 --- a/src/utils/comments.go +++ b/src/utils/comments.go @@ -17,6 +17,14 @@ func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (commen allComments := commentsList2.Find("li.comment") allComments.Each(func(i int, s *goquery.Selection) { + commentScoreParent := s.Find("div.comment-score") + + // find the first span within commentScoreParent + commentScore := commentScoreParent.Find("span").First().Text() + if commentScore == "" { + commentScore = "0" + } + commentText := s.Find("div.comment-text") commentBody := commentText.Find("div.comment-body") @@ -45,6 +53,7 @@ func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (commen Timestamp: commentTimestamp, AuthorName: commentAuthor.Text(), AuthorURL: commentAuthorURL, + Upvotes: commentScore, } comments = append(comments, newFilteredComment) diff --git a/templates/comments.html b/templates/comments.html index 37e2af7..70a1ce3 100644 --- a/templates/comments.html +++ b/templates/comments.html @@ -6,8 +6,13 @@ {{ range $comment := .Comments }}
-
- {{ $comment.Text }} +
+
+ {{ $comment.Upvotes }} +
+
+ {{ $comment.Text }} +
Commented {{ $comment.Timestamp }} by diff --git a/templates/question.html b/templates/question.html index 7dbd909..61b2012 100644 --- a/templates/question.html +++ b/templates/question.html @@ -21,7 +21,7 @@ alt="4 circles with alternating colors between green and white" /> - {{ template "themeSwitcher.html" .}} + {{ template "themeSwitcher.html" . }}