docs: comments
This commit is contained in:
parent
4db7b4795b
commit
634c7f1ad0
@ -123,6 +123,7 @@ type viewQuestionInputs struct {
|
|||||||
Sub string
|
Sub string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parseAndValidateParameters consolidates the URL and query parameters into an easily-accessible struct.
|
||||||
func parseAndValidateParameters(c *gin.Context) (inputs viewQuestionInputs, err error) {
|
func parseAndValidateParameters(c *gin.Context) (inputs viewQuestionInputs, err error) {
|
||||||
|
|
||||||
questionId := c.Param("id")
|
questionId := c.Param("id")
|
||||||
@ -156,6 +157,7 @@ func parseAndValidateParameters(c *gin.Context) (inputs viewQuestionInputs, err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fetchQuestionData sends the request to StackOverflow.
|
||||||
func fetchQuestionData(soLink string) (resp *resty.Response, err error) {
|
func fetchQuestionData(soLink string) (resp *resty.Response, err error) {
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
resp, err = client.R().Get(soLink)
|
resp, err = client.R().Get(soLink)
|
||||||
@ -261,15 +263,14 @@ func extractAnswersData(doc *goquery.Document, domain string) ([]types.FilteredA
|
|||||||
|
|
||||||
// processAnswerBody highlights syntax and processes code blocks within an answer's body.
|
// processAnswerBody highlights syntax and processes code blocks within an answer's body.
|
||||||
func processAnswerBody(bodyHTML string, domain string) string {
|
func processAnswerBody(bodyHTML string, domain string) string {
|
||||||
// Example placeholder function to process and highlight syntax in code blocks.
|
|
||||||
// You would replace this with your actual logic for syntax highlighting.
|
|
||||||
highlightedBody := utils.HighlightSyntaxViaContent(bodyHTML)
|
highlightedBody := utils.HighlightSyntaxViaContent(bodyHTML)
|
||||||
return highlightedBody
|
return highlightedBody
|
||||||
}
|
}
|
||||||
|
|
||||||
// extractAnswerAuthorInfo extracts the author name, URL, and timestamp from an answer block.
|
// extractAnswerAuthorInfo extracts the author name, URL, and timestamp from an answer block.
|
||||||
|
// It directly mutates the answer.
|
||||||
func extractAnswerAuthorInfo(selection *goquery.Selection, answer *types.FilteredAnswer, domain string) {
|
func extractAnswerAuthorInfo(selection *goquery.Selection, answer *types.FilteredAnswer, domain string) {
|
||||||
authorDetails := selection.Find("div.post-signature").Last() // Assuming the last post signature contains the author info.
|
authorDetails := selection.Find("div.post-signature").Last()
|
||||||
|
|
||||||
authorName := html.EscapeString(authorDetails.Find("div.user-details a").First().Text())
|
authorName := html.EscapeString(authorDetails.Find("div.user-details a").First().Text())
|
||||||
authorURL := "https://" + domain + authorDetails.Find("div.user-details a").AttrOr("href", "")
|
authorURL := "https://" + domain + authorDetails.Find("div.user-details a").AttrOr("href", "")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user