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

GitHub限制label长度导致gitment/gitalk可能无法创建issue #622

Open
4 of 6 tasks
codgician opened this issue Mar 9, 2018 · 4 comments
Open
4 of 6 tasks

Comments

@codgician
Copy link

codgician commented Mar 9, 2018

I certify that I have first consulted (check all with "x")

我确认我已经查看了 (使用 "x" 选择)


I'm submitting a (check one with "x")

我正在申请 (使用 "x" 选择)

  • bug report | 反馈一个 bug
  • feature request | 申请添加新的特性或功能
  • support request | 请求技术支持

由于 GitHub 最近限制 label 长度为 50 字符以内,导致对于 url 过长的文章无法创建相应 label,因此无法初始化评论。

详细情况可以参见 Issue #102 - gitalk/gitalk

可行的解决方案之一是使用 url 的 md5 作为 label,但是这样会导致用户需要手动在 GitHub 上修改之前所有文章对应的 label。


Recently GitHub has decided to limit the length of label name to no more than 50 characters, so that creating label may fail when the length of url exceeds 50 characters while using gitment / gitalk as comment system.

For further details, please check out Issue #102 - gitalk/gitalk.

One possible solution is using md5 hash of url as label name, but this will require users to manually change label names for previous posts.

@NewGr8Player
Copy link

对于全新安装有如下解决方案,解决方案如下:
hexo根目录\themes\material\layout\_widget\comment\gitalk
在此目录下编辑main.ejs文件
在其中新增如下内容

<script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>

在gittalk下增加id属性,增加后完整文件内容如下:

<!-- Gitalk 评论框 -->
<div id="gitalk-container"></div>

<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">

<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>

<script>
    var gitalk = new Gitalk({
            clientID: '<%= theme.comment.gitalk_client_id %>',
            clientSecret: '<%= theme.comment.gitalk_client_secret %>',
            repo: '<%= theme.comment.gitalk_repo %>',
            owner: '<%= theme.comment.gitalk_owner %>',
            admin: ['<%= theme.comment.gitalk_owner %>'],
            id: md5(window.location.pathname),
            // facebook-like distraction free mode
            distractionFreeMode: false
        })
   gitalk.render('gitalk-container')
</script>

对于已经存在文章的用户可用一个固定时间作为分界线,具体请参考如下博文:
链接地址

@Hiwensen
Copy link

@NewGr8Player 谢谢给出的解决方案, 简便好用

@ElderJames
Copy link
Contributor

你好,集成gitalk的pr是我提的,我会重新提一个pr修复一下。

ElderJames added a commit to ElderJames/hexo-theme-material that referenced this issue Jun 6, 2018
@ElderJames
Copy link
Contributor

已提pr修复此问题 #664 😃

ShixiangWang added a commit to ShixiangWang/home that referenced this issue Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants