diff --git a/disqus.go b/disqus.go index 8a932df..19d79cd 100644 --- a/disqus.go +++ b/disqus.go @@ -17,6 +17,7 @@ import ( type result struct { Code int Response []struct { + Id string Posts int Identifiers []string } @@ -66,6 +67,7 @@ func PostsCount() { artc := Ei.MapArticles[v.Identifiers[0][i+1:]] if artc != nil { artc.Count = v.Posts + artc.Thread = v.Id } } } diff --git a/docker-compose.yml b/docker-compose.yml index 5ff61f4..6721694 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: volumes: - /data/eiblog/mgodb:/data/db restart: always + ports: + - 27017:27017 elasticsearch: image: elasticsearch:2.4.1 container_name: eisearch diff --git a/front.go b/front.go index 27f833c..f80dd50 100644 --- a/front.go +++ b/front.go @@ -207,6 +207,7 @@ func HandleDisqusFrom(c *gin.Context) { "Title": "发表评论 | " + Ei.BTitle, "ATitle": artc.Title, "Thread": params[1], + "Slug": artc.Slug, } err := Tmpl.ExecuteTemplate(c.Writer, "disqus.html", data) if err != nil { @@ -296,7 +297,11 @@ type commentsDetail struct { func HandleDisqus(c *gin.Context) { slug := c.Param("slug") cursor := c.Query("cursor") + dcs := DisqusComments{} + if artc := Ei.MapArticles[slug]; artc != nil { + dcs.Data.Thread = artc.Thread + } postsList := PostsList(slug, cursor) if postsList != nil { dcs.ErrNo = postsList.Code diff --git a/model.go b/model.go index d9ad28f..c899948 100644 --- a/model.go +++ b/model.go @@ -121,6 +121,8 @@ type Article struct { Excerpt string `bson:"-"` // 一句话描述,文章第一句 Desc string `bson:"-"` + // disqus thread + Thread string `bson:"-"` } type SortArticles []*Article diff --git a/views/disqus.html b/views/disqus.html index 5a348bf..438f94f 100644 --- a/views/disqus.html +++ b/views/disqus.html @@ -1,2 +1 @@ - -{{.Title}}

对「{{.ATitle}}」发表评论

  • 昵称:
  • 邮箱:
  • 内容:
  • 注:通过本表单提交的数据,会原样转发给 Disqus,本站不做任何存储和记录。
  • 放弃评论
+{{.Title}}

对「{{.ATitle}}」发表评论

  • 昵称:
  • 邮箱:
  • 内容:
  • 注:通过本表单提交的数据,会原样转发给 Disqus,本站不做任何存储和记录。
  • 放弃评论
\ No newline at end of file