Files
site/themes/custom/layouts/partials/comments.html
2018-07-16 21:46:31 -04:00

138 lines
5.8 KiB
HTML

{{ if and .IsPage (ne .Params.comment false) }}
{{- if and .Site.Params.disqus.name .Site.Params.disqus.lazy -}}
<div onclick="showDisqus();" id="disqus_title" class="disqus_title">Load Comments</div>
{{- end -}}
<!-- gitalk -->
{{- if .Site.Params.gitalk.owner -}}
<div id="gitalk-container" class="gitalk-container"></div>
<link rel="stylesheet" href="{{ "lib/gitalk/gitalk-1.2.2.min.css" | relURL }}">
<script src="{{ "lib/gitalk/gitalk-1.2.2.min.js" | relURL }}"></script>
<script type="text/javascript">
var gitalk = new Gitalk({
id: '{{md5 .URL}}',
title: '{{ .Title }}',
clientID: '{{ .Site.Params.gitalk.clientId }}',
clientSecret: '{{ .Site.Params.gitalk.clientSecret }}',
repo: '{{ .Site.Params.gitalk.repo }}',
owner: '{{ .Site.Params.gitalk.owner }}',
admin: ['{{ .Site.Params.gitalk.owner }}'],
body: decodeURI(location.href)
});
gitalk.render('gitalk-container');
</script>
<noscript>Please enable JavaScript to view the
<a href="https://github.com/gitalk/gitalk">comments powered by gitalk.</a>
</noscript>
{{- end -}}
<!-- Disqus -->
{{- if .Site.Params.disqus.name -}}
<div id="disqus_thread"></div>
<script type="text/javascript">
// function checkDisqus() {
// // var dsp = $.trim($("#dsq-app1").attr("id"));
// var dsp = $.trim($('iframe[id^=dsq-app]').attr("id"));
// if (dsp == "") {
// $("#disqus_thread").append('<div style="text-align: center;" id="reload_div">Loaded Disqus Failured. Please Ensure You Can Access [disqus.com] ! Then <a href="javascript:void(0);" onclick="showDisqus();">Reload</a>!</div>');
// }
// }
function showDisqus() {
$("#disqus_title").attr("style", "display:none");
// Don't ever inject Disqus on localhost--it creates unwanted
// discussions from 'localhost:1313' on your Disqus account...
// if (window.location.hostname === 'localhost') return;
// setTimeout("checkDisqus()", 20000);
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = false;
var disqus_shortname = '{{ .Site.Params.disqus.name }}';
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
window.location.hash = "#disqus_thread";
}
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{{- if not .Site.Params.disqus.lazy -}}
<script type="text/javascript">
// $(document).ready(function () {
window.onload = function () {
showDisqus();
}
// })
</script>
{{- end -}}
{{- end -}}
<!-- changyan -->
{{- if and .Site.Params.changyanAppid .Site.Params.changyanAppkey -}}
<div id="SOHUCS"></div>
<script type="text/javascript">
(function(){
if (window.location.hostname === 'localhost') return;
var appid = '{{ .Site.Params.changyanAppid }}';
var conf = '{{ .Site.Params.changyanAppkey }}';
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>
{{- end -}}
<!-- LiveRe -->
{{- if .Site.Params.livereUID -}}
<div id="lv-container" data-id="city" data-uid="{{ .Site.Params.livereUID }}">
<script type="text/javascript">
(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>
<noscript>Please enable JavaScript to view the comments powered by <a href="https://livere.com/">LiveRe.</a></noscript>
</div>
{{- end -}}
<!-- gitment -->
{{- if .Site.Params.gitment.owner -}}
<div id="comments-gitment"></div>
{{ if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.gitmentCSS | safeHTML }}
{{ .Site.Params.publicCDN.gitmentJS | safeHTML }}
{{- else -}}
<link rel="stylesheet" href="{{ "lib/gitment/gitment-0.0.3.min.css" | relURL }}">
<script src="{{ "lib/gitment/gitment-0.0.3.min.js" | relURL }}"></script>
{{- end }}
<script type="text/javascript">
const gitment = new Gitment({
id: '{{ .Date }}',
title: '{{ .Title }}',
link: decodeURI(location.href),
desc: '{{ .Summary }}',
owner: '{{ .Site.Params.gitment.owner }}',
repo: '{{ .Site.Params.gitment.repo }}',
oauth: {
client_id: '{{ .Site.Params.gitment.clientId }}',
client_secret: '{{ .Site.Params.gitment.clientSecret }}'
}
})
gitment.render('comments-gitment')
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/imsun/gitment">comments powered by gitment.</a></noscript>
{{- end }}
{{- end }}