feat: get stackexchange posts
fix: comment author distinguishing
This commit is contained in:
parent
f81b726612
commit
45644a0503
9
main.go
9
main.go
@ -59,6 +59,15 @@ func main() {
|
||||
// redirect user to the answer with the title
|
||||
c.Redirect(302, fmt.Sprintf("/questions/%s/%s#%s", c.Param("id"), c.Param("title"), c.Param("answerId")))
|
||||
})
|
||||
r.GET("/exchange/:sub/questions/:id/:title", routes.ViewQuestion)
|
||||
r.GET("/exchange/:sub/questions/:id", func(c *gin.Context) {
|
||||
// redirect user to the question with the title
|
||||
c.Redirect(302, fmt.Sprintf("/exchange/%s/questions/%s/placeholder", c.Param("sub"), c.Param("id")))
|
||||
})
|
||||
r.GET("/exchange/:sub/questions/:id/:title/:answerId", func(c *gin.Context) {
|
||||
// redirect user to the answer with the title
|
||||
c.Redirect(302, fmt.Sprintf("/exchange/%s/questions/%s/%s#%s", c.Param("sub"), c.Param("id"), c.Param("title"), c.Param("answerId")))
|
||||
})
|
||||
|
||||
r.GET("/proxy", routes.GetImage)
|
||||
|
||||
|
@ -53,7 +53,15 @@ func ViewQuestion(c *gin.Context) {
|
||||
soSortValue = soSortValues["votes"]
|
||||
}
|
||||
|
||||
soLink := fmt.Sprintf("https://stackoverflow.com/questions/%s/%s?answertab=%s", questionId, questionTitle, soSortValue)
|
||||
sub := c.Param("sub")
|
||||
|
||||
domain := "stackoverflow.com"
|
||||
|
||||
if sub != "" {
|
||||
domain = fmt.Sprintf("%s.stackexchange.com", sub)
|
||||
}
|
||||
|
||||
soLink := fmt.Sprintf("https://%s/questions/%s/%s?answertab=%s", domain, questionId, questionTitle, soSortValue)
|
||||
|
||||
resp, err := client.R().Get(soLink)
|
||||
if err != nil {
|
||||
@ -218,7 +226,7 @@ func ViewQuestion(c *gin.Context) {
|
||||
answerTimestamp := ""
|
||||
|
||||
answerFooter.Find("div.post-signature").Each(func(i int, s *goquery.Selection) {
|
||||
questionAuthorDetails := questionMetadata.Find("div.user-details")
|
||||
questionAuthorDetails := s.Find("div.user-details")
|
||||
|
||||
if questionAuthorDetails.Length() > 0 {
|
||||
questionAuthor := questionAuthorDetails.Find("a").First()
|
||||
|
Loading…
x
Reference in New Issue
Block a user