aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/data/themes/base/templates/disqus_helper.tmpl
blob: 74187b0ae35b8c130e3f3d0449edd3316e9e80c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## -*- coding: utf-8 -*-
<%!
    import json
    translations = {
        'es': 'es_ES',
    }
%>

<%def name="comment_form(url, title, identifier)">
    %if comment_system_id:
        <div id="disqus_thread"></div>
        <script>
        var disqus_shortname ="${comment_system_id}",
        %if url:
            disqus_url="${url}",
        %endif
        disqus_title=${json.dumps(title)},
        disqus_identifier="${identifier}",
        disqus_config = function () {
            this.language = "${translations.get(lang, lang)}";
        };
        (function() {
            var dsq = document.createElement('script'); dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
    <a href="http://disqus.com" class="dsq-brlink" rel="nofollow">Comments powered by <span class="logo-disqus">Disqus</span></a>
    %endif
</%def>

<%def name="comment_link(link, identifier)">
    <p>
    %if comment_system_id:
        <a href="${link}#disqus_thread" data-disqus-identifier="${identifier}">Comments</a>
    %endif
</%def>


<%def name="comment_link_script()">
    %if comment_system_id:
       <script>var disqus_shortname="${comment_system_id}";(function(){var a=document.createElement("script");a.async=true;a.src="//"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)}());</script>
    %endif
</%def>

## FIXME: remove aliases in v7
<%def name="html_disqus(url, title, identifier)">
    ${comment_form(url, title, identifier)}
</%def>

<%def name="html_disqus_link(link, identifier)">
    ${comment_link(link, identifier)}
</%def>

<%def name="html_disqus_script()">
    ${comment_link_script()}
</%def>