fix: pass down domain to comment for author URLs
This commit is contained in:
parent
d935ce72f6
commit
f1370c29b6
@ -137,7 +137,7 @@ func ViewQuestion(c *gin.Context) {
|
|||||||
|
|
||||||
newFilteredQuestion.ShortenedBody = shortenedBody
|
newFilteredQuestion.ShortenedBody = shortenedBody
|
||||||
|
|
||||||
comments := utils.FindAndReturnComments(questionBodyParentHTML, questionPostLayout)
|
comments := utils.FindAndReturnComments(questionBodyParentHTML, domain, questionPostLayout)
|
||||||
newFilteredQuestion.Comments = comments
|
newFilteredQuestion.Comments = comments
|
||||||
|
|
||||||
// parse any code blocks and highlight them
|
// parse any code blocks and highlight them
|
||||||
@ -256,7 +256,7 @@ func ViewQuestion(c *gin.Context) {
|
|||||||
answerBodyHTML = strings.Replace(answerBodyHTML, codeBlock, highlightedCodeBlock, 1)
|
answerBodyHTML = strings.Replace(answerBodyHTML, codeBlock, highlightedCodeBlock, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
comments = utils.FindAndReturnComments(answerBodyHTML, postLayout)
|
comments = utils.FindAndReturnComments(answerBodyHTML, domain, postLayout)
|
||||||
|
|
||||||
newFilteredAnswer.Comments = comments
|
newFilteredAnswer.Comments = comments
|
||||||
newFilteredAnswer.Body = template.HTML(utils.ReplaceImgTags(answerBodyHTML))
|
newFilteredAnswer.Body = template.HTML(utils.ReplaceImgTags(answerBodyHTML))
|
||||||
|
@ -8,4 +8,5 @@ type FilteredComment struct {
|
|||||||
AuthorName string
|
AuthorName string
|
||||||
AuthorURL string
|
AuthorURL string
|
||||||
Upvotes string
|
Upvotes string
|
||||||
|
Domain string
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (comments []types.FilteredComment) {
|
func FindAndReturnComments(inHtml, domain string, postLayout *goquery.Selection) (comments []types.FilteredComment) {
|
||||||
|
|
||||||
commentsComponent := postLayout.Find("div.js-post-comments-component")
|
commentsComponent := postLayout.Find("div.js-post-comments-component")
|
||||||
|
|
||||||
@ -54,6 +54,7 @@ func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (commen
|
|||||||
AuthorName: commentAuthor.Text(),
|
AuthorName: commentAuthor.Text(),
|
||||||
AuthorURL: commentAuthorURL,
|
AuthorURL: commentAuthorURL,
|
||||||
Upvotes: commentScore,
|
Upvotes: commentScore,
|
||||||
|
Domain: domain,
|
||||||
}
|
}
|
||||||
|
|
||||||
comments = append(comments, newFilteredComment)
|
comments = append(comments, newFilteredComment)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<div class="comment-author">
|
<div class="comment-author">
|
||||||
Commented {{ $comment.Timestamp }} by
|
Commented {{ $comment.Timestamp }} by
|
||||||
<a
|
<a
|
||||||
href="https://stackoverflow.com{{ $comment.AuthorURL }}"
|
href="https://{{ $comment.Domain }}{{ $comment.AuthorURL }}"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>{{ $comment.AuthorName }}</a
|
>{{ $comment.AuthorName }}</a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user