Disqus script loads when needed. Fixes #9
This commit is contained in:
parent
a7e52f578d
commit
4ab4f63d64
4 changed files with 21 additions and 8 deletions
|
@ -12,6 +12,9 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
|
||||||
<meta http-equiv="cleartype" content="on">
|
<meta http-equiv="cleartype" content="on">
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var disqus_shortname = 'fmartingr';
|
||||||
|
</script>
|
||||||
{% block endhead %}{% endblock %}
|
{% block endhead %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body class="{% block body_class %}{% endblock %}">
|
<body class="{% block body_class %}{% endblock %}">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{% extends "blog/_base.html" %}
|
{% extends "blog/_base.html" %}
|
||||||
{% from "macros/blog.html" import render_blog_post %}
|
{% from "macros/blog.html" import render_blog_post %}
|
||||||
{% from "macros/pagination.html" import render_pagination %}
|
{% from "macros/pagination.html" import render_pagination %}
|
||||||
|
{% from "macros/comments.html" import render_count %}
|
||||||
|
|
||||||
{% block main_content %}
|
{% block main_content %}
|
||||||
{% for child in this.pagination.items %}
|
{% for child in this.pagination.items %}
|
||||||
|
@ -9,3 +10,8 @@
|
||||||
|
|
||||||
<div class="center">{{ render_pagination(this.pagination) }}</div>
|
<div class="center">{{ render_pagination(this.pagination) }}</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block endbody %}
|
||||||
|
{{ super() }}
|
||||||
|
{{ disqus_count_script() }}
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{% extends "blog/_base.html" %}
|
{% extends "blog/_base.html" %}
|
||||||
{% from "macros/blog.html" import render_blog_post %}
|
{% from "macros/blog.html" import render_blog_post %}
|
||||||
|
{% from "macros/comments.html" import disqus_comments_script %}
|
||||||
|
|
||||||
{% block body_class %}blog post{% endblock %}
|
{% block body_class %}blog post{% endblock %}
|
||||||
|
|
||||||
|
@ -9,11 +10,14 @@
|
||||||
{{ render_blog_post(this) }}
|
{{ render_blog_post(this) }}
|
||||||
{% if this.comments_enabled %}
|
{% if this.comments_enabled %}
|
||||||
<div class="comments center" id="disqus_thread"></div>
|
<div class="comments center" id="disqus_thread"></div>
|
||||||
{% from 'macros/comments.html' import disqus with context %}
|
|
||||||
{{ disqus() }}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="center block-info">
|
<div class="center block-info">
|
||||||
Comments have been disabled in this post, if you want to contact me please <a href="{{ '/contact'|url }}">go ahead</a>!
|
Comments have been disabled in this post, if you want to contact me please <a href="{{ '/contact'|url }}">go ahead</a>!
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block endbody %}
|
||||||
|
{{ super() }}
|
||||||
|
{{ disqus_comments_script() }}
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
{% macro disqus(shortname) -%}
|
{% macro disqus_comments_script() -%}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var disqus_shortname = 'fmartingr';
|
|
||||||
|
|
||||||
// Embed
|
|
||||||
(function() {
|
(function() {
|
||||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||||
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
||||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||||
})();
|
})();
|
||||||
|
</script>
|
||||||
|
{%- endmacro %}
|
||||||
|
|
||||||
// Count
|
{% macro disqus_count_script() %}
|
||||||
|
<script type="text/javascript">
|
||||||
(function () {
|
(function () {
|
||||||
var s = document.createElement('script'); s.async = true;
|
var s = document.createElement('script'); s.async = true;
|
||||||
s.type = 'text/javascript';
|
s.type = 'text/javascript';
|
||||||
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
|
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
|
||||||
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue