Skip to content

Commit

Permalink
Add Disqus protection, see #2
Browse files Browse the repository at this point in the history
  • Loading branch information
mzlogin committed Apr 9, 2016
1 parent 2e7ddcb commit 03e32f1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 36 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Fork 本项目之后,还需要做一些事情才能让你的页面「正确」

3. 修改配置。

网站的配置基本都集中在 _config.yml 文件中,将其中与个人信息相关的部分替换成你自己的,比如网站的 title、subtitle 和 disqus 的用户名等。
网站的配置基本都集中在 \_config.yml 文件中,将其中与个人信息相关的部分替换成你自己的,比如网站的 title、subtitle 和 disqus 的用户名等。

4. 删除我的文章。

如下文件夹中除了 template.md 文件外,都可以全部删除,然后添加你自己的内容。

* _posts 文件夹中是我已发布的博客文章。
* _drafts 文件夹中是我尚未发布的博客文章。
* _wiki 文件夹中是我已发布的 wiki 页面。
* \_posts 文件夹中是我已发布的博客文章。
* \_drafts 文件夹中是我尚未发布的博客文章。
* \_wiki 文件夹中是我已发布的 wiki 页面。

5. 修改「关于」页面。

Expand Down
7 changes: 4 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------- #
# Main Configs #
# ---------------- #
baseurl:
baseurl:
url: http://mazhuang.org
date_format: "ordinal"
title: 码志
Expand All @@ -16,7 +16,7 @@ source_code: https://github.com/mzlogin/mzlogin.github.io
# ---------------- #
# Author #
# ---------------- #
author: Zhuang Ma
author: Zhuang Ma
organization: Sogou, Inc.
organization_url: https://www.sogou.com
location: Beijing, China
Expand Down Expand Up @@ -91,6 +91,8 @@ twitter_username: mzlogin
# ---------------- #
# support provider: disqus, duoshuo, changyan
comments_provider: disqus
# !!!重要!!! 请修改下面两个用户名为你自己申请的
# !!!Important!!! Please modify usernames below to yours
duoshuo_username: mazhuang
disqus_username: mzlogin

Expand All @@ -102,4 +104,3 @@ skill_mobile_app_keywords: [Android, Reverse Engineering]
skill_windows_keywords: [Win32 SDK, DuiLib, WTL, COM, WinDbg]
popular_repos: ['chinese-copywriting-guidelines','android-reverse-engineering', 'csdncommenter', 'mzlogin.github.io', 'vim-markdown-toc']
contribute_repos: ['sparanoid/chinese-copywriting-guidelines', 'waylife/RentCrawer']

68 changes: 39 additions & 29 deletions _includes/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,37 @@
{% case site.comments_provider %}
{% when 'disqus' %}
{% if site.disqus_username %}
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = '{{ site.url }}{{ page.url }}';
this.page.identifier = '{{ page.url }}';
this.page.title = '{{ page.title }}';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
{% assign load_disqus = true %}
<!-- Disqus Protection, see https://github.com/mzlogin/mzlogin.github.io/issues/2 -->
{% if site.disqus_username == 'mzlogin' %}
{% assign load_disqus = false %}
{% if site.url contains 'mazhuang.org' %}
{% assign load_disqus = true %}
{% endif %}
{% endif %}
{% if load_disqus %}
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = '{{ site.url }}{{ page.url }}';
this.page.identifier = '{{ page.url }}';
this.page.title = '{{ page.title }}';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');

s.type = 'text/javascript';
s.async = true;
var shortname = '{{ site.disqus_username }}';
s.type = 'text/javascript';
s.async = true;
var shortname = '{{ site.disqus_username }}';

s.src = '//' + shortname + '.disqus.com/embed.js';
s.src = '//' + shortname + '.disqus.com/embed.js';

s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
{% endif %}
{% endif %}
{% when 'duoshuo' %}
{% if site.duoshuo_username %}
Expand All @@ -47,17 +57,17 @@
{% endif %}
{% when 'changyan' %}
<!-- Changyan Comment BEGIN -->
<div id="SOHUCS" sid="{{ page.url }}"></div>
<script type="text/javascript">
(function(){
var appid = 'cyrQPfEd5';
var conf = '6d39b373e0fa44eed17fc5e251dcdaff';
if (window.screen.width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="http://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>');
} else {
var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("http://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})});
}
})();
<div id="SOHUCS" sid="{{ page.url }}"></div>
<script type="text/javascript">
(function(){
var appid = 'cyrQPfEd5';
var conf = '6d39b373e0fa44eed17fc5e251dcdaff';
if (window.screen.width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="http://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>');
} else {
var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("http://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})});
}
})();
</script>
<!-- Changyan Comment END -->
{% endcase %}
Expand Down

0 comments on commit 03e32f1

Please sign in to comment.