initial
This commit is contained in:
18
themes/next/layout/_third-party/comments/changyan.swig
vendored
Normal file
18
themes/next/layout/_third-party/comments/changyan.swig
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{% if is_home() %}
|
||||
<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{ theme.changyan.appid }}"></script>
|
||||
{% elif page.comments %}
|
||||
<script>
|
||||
(function() {
|
||||
var appid = '{{ theme.changyan.appid }}';
|
||||
var conf = '{{ theme.changyan.appkey }}';
|
||||
var width = window.innerWidth || document.documentElement.clientWidth;
|
||||
if (width < 960) {
|
||||
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://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("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script src="https://assets.changyan.sohu.com/upload/plugins/plugins.count.js"></script>
|
||||
{% endif %}
|
44
themes/next/layout/_third-party/comments/disqus.swig
vendored
Normal file
44
themes/next/layout/_third-party/comments/disqus.swig
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
{% if theme.disqus.count %}
|
||||
<script id="dsq-count-scr" src="https://{{ theme.disqus.shortname }}.disqus.com/count.js" async></script>
|
||||
{% endif %}
|
||||
{% if page.comments %}
|
||||
<script>
|
||||
var disqus_config = function() {
|
||||
this.page.url = {{ page.permalink | json }};
|
||||
this.page.identifier = {{ page.path | json }};
|
||||
this.page.title = '{{ page.title | addslashes }}';
|
||||
{% if __('disqus') !== 'disqus' -%}
|
||||
this.language = '{{ __('disqus') }}';
|
||||
{% endif -%}
|
||||
};
|
||||
function loadComments() {
|
||||
var d = document, s = d.createElement('script');
|
||||
s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', '' + +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
}
|
||||
{% if theme.disqus.lazyload %}
|
||||
$(function() {
|
||||
var offsetTop = $('#comments').offset().top - $(window).height();
|
||||
if (offsetTop <= 0) {
|
||||
// load directly when there's no a scrollbar
|
||||
loadComments();
|
||||
} else {
|
||||
$(window).on('scroll.disqus_scroll', function() {
|
||||
// offsetTop may changes because of manually resizing browser window or lazy loading images.
|
||||
var offsetTop = $('#comments').offset().top - $(window).height();
|
||||
var scrollTop = $(window).scrollTop();
|
||||
|
||||
// pre-load comments a bit? (margin or anything else)
|
||||
if (offsetTop - scrollTop < 60) {
|
||||
$(window).off('.disqus_scroll');
|
||||
loadComments();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
{% else %}
|
||||
loadComments();
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endif %}
|
19
themes/next/layout/_third-party/comments/disqusjs.swig
vendored
Normal file
19
themes/next/layout/_third-party/comments/disqusjs.swig
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{% set disqusjs_css_url = '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css' %}
|
||||
{% if theme.vendors.disqusjs_css %}
|
||||
{% set disqusjs_css_url = theme.vendors.disqusjs_css %}
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="{{ disqusjs_css_url }}"/>
|
||||
|
||||
{% set disqusjs_js_url = '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js' %}
|
||||
{% if theme.vendors.disqusjs_js %}
|
||||
{% set disqusjs_js_url = theme.vendors.disqusjs_js %}
|
||||
{% endif %}
|
||||
<script src="{{ disqusjs_js_url }}"></script>
|
||||
|
||||
<script>
|
||||
var dsqjs = new DisqusJS({
|
||||
api: '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/',
|
||||
apikey: '{{ theme.disqusjs.apikey }}',
|
||||
shortname: '{{ theme.disqusjs.shortname }}'
|
||||
});
|
||||
</script>
|
35
themes/next/layout/_third-party/comments/gitalk.swig
vendored
Normal file
35
themes/next/layout/_third-party/comments/gitalk.swig
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{% set gitalk_js_url = '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js' %}
|
||||
{% if theme.vendors.gitalk_js %}
|
||||
{% set gitalk_js_url = theme.vendors.gitalk_js %}
|
||||
{% endif %}
|
||||
<script src="{{ gitalk_js_url }}"></script>
|
||||
|
||||
{% set gitalk_css_url = '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css' %}
|
||||
{% if theme.vendors.gitalk_css %}
|
||||
{% set gitalk_css_url = theme.vendors.gitalk_css %}
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="{{ gitalk_css_url }}"/>
|
||||
|
||||
{% set md5_url = '//cdn.jsdelivr.net/npm/js-md5@0.7.3/src/md5.min.js' %}
|
||||
{% if theme.vendors.md5 %}
|
||||
{% set md5_url = theme.vendors.md5 %}
|
||||
{% endif %}
|
||||
<script src="{{ md5_url }}"></script>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '{{ theme.gitalk.client_id }}',
|
||||
clientSecret: '{{ theme.gitalk.client_secret }}',
|
||||
repo: '{{ theme.gitalk.repo }}',
|
||||
owner: '{{ theme.gitalk.github_id }}',
|
||||
admin: ['{{ theme.gitalk.admin_user }}'],
|
||||
id: md5(location.pathname),
|
||||
{% if theme.gitalk.language == '' %}
|
||||
language: window.navigator.language || window.navigator.userLanguage,
|
||||
{% else %}
|
||||
language: '{{ theme.gitalk.language }}',
|
||||
{% endif %}
|
||||
distractionFreeMode: '{{ theme.gitalk.distraction_free_mode }}'
|
||||
});
|
||||
gitalk.render('gitalk-container');
|
||||
</script>
|
45
themes/next/layout/_third-party/comments/gitment.swig
vendored
Normal file
45
themes/next/layout/_third-party/comments/gitment.swig
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<!-- LOCAL: You can save these files to your site and update links -->
|
||||
{% if theme.gitment.mint %}
|
||||
{% set CommentsClass = 'Gitmint' %}
|
||||
<script src="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/gitmint.browser.js"></script>
|
||||
{% else %}
|
||||
{% set CommentsClass = 'Gitment' %}
|
||||
<script src="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/gitment.browser.js"></script>
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/default.css"/>
|
||||
<!-- END LOCAL -->
|
||||
|
||||
<script>
|
||||
function renderGitment() {
|
||||
var gitment = new {{ CommentsClass }}({
|
||||
id: window.location.pathname,
|
||||
owner: '{{ theme.gitment.github_user }}',
|
||||
repo: '{{ theme.gitment.github_repo }}',
|
||||
{% if theme.gitment.mint %}
|
||||
lang: '{{ theme.gitment.language }}' || navigator.language || navigator.systemLanguage || navigator.userLanguage,
|
||||
{% endif %}
|
||||
oauth: {
|
||||
{% if theme.gitment.mint and theme.gitment.redirect_protocol %}
|
||||
redirect_protocol: '{{ theme.gitment.redirect_protocol }}',
|
||||
{% endif %}
|
||||
{% if theme.gitment.mint and theme.gitment.proxy_gateway %}
|
||||
proxy_gateway: '{{ theme.gitment.proxy_gateway }}',
|
||||
{% else %}
|
||||
client_secret: '{{ theme.gitment.client_secret }}',
|
||||
{% endif %}
|
||||
client_id: '{{ theme.gitment.client_id }}'
|
||||
}
|
||||
});
|
||||
gitment.render('gitment-container');
|
||||
}
|
||||
|
||||
{% if not theme.gitment.lazy %}
|
||||
renderGitment();
|
||||
{% else %}
|
||||
function showGitment() {
|
||||
document.getElementById('gitment-display-button').style.display = 'none';
|
||||
document.getElementById('gitment-container').style.display = 'block';
|
||||
renderGitment();
|
||||
}
|
||||
{% endif %}
|
||||
</script>
|
19
themes/next/layout/_third-party/comments/index.swig
vendored
Normal file
19
themes/next/layout/_third-party/comments/index.swig
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{% if theme.disqus.enable %}
|
||||
{% include 'disqus.swig' %}
|
||||
{% elif theme.changyan.enable and theme.changyan.appid and theme.changyan.appkey %}
|
||||
{% include 'changyan.swig' %}
|
||||
{% elif theme.valine.enable and theme.valine.appid and theme.valine.appkey %}
|
||||
{% include 'valine.swig' %}
|
||||
{% endif %}
|
||||
|
||||
{% if page.comments %}
|
||||
{% if theme.livere_uid %}
|
||||
{% include 'livere.swig' %}
|
||||
{% elif theme.gitment.enable and theme.gitment.client_id %}
|
||||
{% include 'gitment.swig' %}
|
||||
{% elif theme.gitalk.enable %}
|
||||
{% include 'gitalk.swig' %}
|
||||
{% elif theme.disqusjs.enable and theme.disqusjs.apikey and theme.disqusjs.shortname %}
|
||||
{% include 'disqusjs.swig' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
13
themes/next/layout/_third-party/comments/livere.swig
vendored
Normal file
13
themes/next/layout/_third-party/comments/livere.swig
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
window.livereOptions = {
|
||||
refer: '{{ page.path }}'
|
||||
};
|
||||
(function(d, s) {
|
||||
var j, e = d.getElementsByTagName(s)[0];
|
||||
if (typeof LivereTower === 'function') { return; }
|
||||
j = d.createElement(s);
|
||||
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
|
||||
j.async = true;
|
||||
e.parentNode.insertBefore(j, e);
|
||||
})(document, 'script');
|
||||
</script>
|
32
themes/next/layout/_third-party/comments/valine.swig
vendored
Normal file
32
themes/next/layout/_third-party/comments/valine.swig
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{% set leancloud_uri = '//cdn1.lncld.net/static/js/3.11.1/av-min.js' %}
|
||||
{% if theme.vendors.leancloud %}
|
||||
{% set leancloud_uri = theme.vendors.leancloud %}
|
||||
{% endif %}
|
||||
<script src="{{ leancloud_uri }}"></script>
|
||||
|
||||
{% set valine_uri = '//unpkg.com/valine/dist/Valine.min.js' %}
|
||||
{% if theme.vendors.valine %}
|
||||
{% set valine_uri = theme.vendors.valine %}
|
||||
{% endif %}
|
||||
<script src="{{ valine_uri }}"></script>
|
||||
|
||||
<script>
|
||||
var GUEST = ['nick', 'mail', 'link'];
|
||||
var guest = '{{ theme.valine.guest_info }}';
|
||||
guest = guest.split(',').filter(function(item) {
|
||||
return GUEST.indexOf(item) > -1;
|
||||
});
|
||||
new Valine({
|
||||
el: '#comments',
|
||||
verify: {{ theme.valine.verify }},
|
||||
notify: {{ theme.valine.notify }},
|
||||
appId: '{{ theme.valine.appid }}',
|
||||
appKey: '{{ theme.valine.appkey }}',
|
||||
placeholder: '{{ theme.valine.placeholder }}',
|
||||
avatar: '{{ theme.valine.avatar }}',
|
||||
meta: guest,
|
||||
pageSize: '{{ theme.valine.pageSize }}' || 10,
|
||||
visitor: {{ theme.valine.visitor }},
|
||||
lang: '{{ theme.valine.language }}' || 'zh-cn'
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user