Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于评论系统的疑惑? #16

Closed
shaoting0730 opened this issue Mar 25, 2018 · 14 comments
Closed

对于评论系统的疑惑? #16

shaoting0730 opened this issue Mar 25, 2018 · 14 comments

Comments

@shaoting0730
Copy link

shaoting0730 commented Mar 25, 2018

我按照你的说明,注册了Gitment账号,也按照你的说明文档填好了各项参数,但是对于一开始的https://imsun.net/posts/gitment-introduction/ 里面说的2.引入 Gitment 3. 初始化评论评论看不懂.

@ZEROKISEKI
Copy link
Owner

ZEROKISEKI commented Mar 25, 2018

其实这个你稍微看下gitment的代码和github Issues API就明白的。。, 把那个gitment Class和utils.js封装的请求api.github.com的http对象大概看一遍就懂了,初始化评论实际上就是在目标repo创建一个issue来存储对应文章的评论

@shaoting0730
Copy link
Author

我新建仓库,填写完参数之后.
b8c37eb6-7cd3-4992-9f13-691a90778233

@ZEROKISEKI
Copy link
Owner

@pheromone 可能是你的config.yml的配置repo填写了整个的地址,填一下repo的名称

@shaoting0730
Copy link
Author

朋友,我快弄了1周评论了,最终还是没弄成功.可以详细说说他的第2,3步怎么操作吗?
2018-03-30 10 33 55

@ZEROKISEKI
Copy link
Owner

你new这篇文章的名字是不是比较长或者是有中文。。,应该是超过了github labels长度的限制,可以看下这个issue, 也可以看下gitment的这个issue

@ZEROKISEKI
Copy link
Owner

ZEROKISEKI commented Mar 30, 2018

如果不想改标题的话,你可以尝试用文章的发表时间戳作为gitment的id, 在layout/layout.ejs下添加Id:

<script>
    if(window.commentConfig) {
      window.commentConfig.id = '<%= page.date %>',
      window.commentConfig.owner = '<%= theme.comment.gitment.owner %>'
      window.commentConfig.repo = '<%= theme.comment.gitment.repo %>'
      window.commentConfig.client_id = '<%= theme.comment.gitment.oauth.client_id %>'
      window.commentConfig.client_secret = '<%= theme.comment.gitment.oauth.client_secret %>'
      window.commentConfig.redirect_uri = '<%= theme.comment.gitment.oauth.redirect_uri %>'
    } else {
      window.commentConfig = {
        id: '<%= page.date %>',
        owner: '<%= theme.comment.gitment.owner %>',
        repo: '<%= theme.comment.gitment.repo %>',
        client_id: '<%= theme.comment.gitment.oauth.client_id %>',
        client_secret: '<%= theme.comment.gitment.oauth.client_secret %>',
        redirect_uri: '<%= theme.comment.gitment.oauth.redirect_uri %>'
      }
    }
</script>

然后在source/js/comment/gitment.js下面对初始化gitment进行修改:

var gitment = new Gitment({
        id: window.commentConfig.id,
	owner: window.commentConfig.owner,
	repo: window.commentConfig.repo,
	oauth: {
		client_id: window.commentConfig.client_id,
		client_secret: window.commentConfig.client_secret
	},
	perPage: 10,
	title: window.commentConfig.title,
	theme: galTheme
})

@ZEROKISEKI
Copy link
Owner

ZEROKISEKI commented Mar 30, 2018

@pheromone 我更新了代码,你试着拉下来后重新部署上去,试试能不能初始化评论

@shaoting0730
Copy link
Author

谢谢

@shaoting0730
Copy link
Author

重新拉取代码.可以在短文章里面评论,但是长文章无法评论,出现Error:Validation Failed,无法解决么?还有怎么评论仓库出现在文章里面了,还有一年空白文章.
a8d89c08-bf08-4ffb-afb5-4d85c68514bb

@ZEROKISEKI
Copy link
Owner

ZEROKISEKI commented Mar 31, 2018

@pheromone 你那条评论是在哪里评论的? 存储评论的repo是这个对吧?https://github.com/pheromone/comments/issues, 我看了下issue, label应该是时间戳才对, 我看了下你的博客仓库的js并没有更新https://github.com/pheromone/pheromone.github.io/blob/master/js/comment/gitment.js

更新的主题的source/js/comment/gitment.js初始化gitment应该是加了id的:

2018-03-31 19 47 08

2018-03-31 19 38 03

空白文章这个,你看一下leancloud的Counter里面那篇空白文章对应的url是什么,可能是bug :(

2018-03-31 19 42 35

@shaoting0730
Copy link
Author

我刚才没有上传,现在上传了.我的仓库现在换为博客仓库了,但是还是不行.
249b8539-5a0b-4c33-81af-14064a8eff85
下面这个是leancloud截图.

@ZEROKISEKI
Copy link
Owner

@pheromone source/about/index.md的title是不是空的?

@ZEROKISEKI
Copy link
Owner

博客仓库还是pheromone.github.io这个吧? 我看了跟我主题的代码还是不一样, 没有带idhttps://github.com/pheromone/pheromone.github.io/blob/master/js/comment/gitment.js#L302, 试试hexo clean清除下缓存后再重新生成部署

@shaoting0730
Copy link
Author

非常感谢.终于搞定了.希望博客继续优化.祝君生活愉快.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants